code: func ShimLegacyState(legacy *State) (*states.State, error) {
  	if legacy == nil {
  		return nil, nil
  	}
  	var buf bytes.Buffer
  	err := WriteState(legacy, &buf)
  	if err != nil {
  		return nil, err
  	}
  	f, err := statefile.Read(&buf)
  	if err != nil {
  		return nil, err
  	}
  	return f.State, err
  }
docs: // ShimLegacyState is a helper that takes the legacy state type and
  // converts it to the new state type.
  //
  // This is implemented as a state file upgrade, so it will not preserve
  // parts of the state structure that are not included in a serialized state,
  // such as the resolved results of any local values, outputs in non-root
  // modules, etc.