code: func (d *Diff) AddModule(path addrs.ModuleInstance) *ModuleDiff {
  	// Lower the new-style address into a legacy-style address.
  	// This requires that none of the steps have instance keys, which is
  	// true for all addresses at the time of implementing this because
  	// "count" and "for_each" are not yet implemented for modules.
  	legacyPath := make([]string, len(path))
  	for i, step := range path {
  		if step.InstanceKey != addrs.NoKey {
  			// FIXME: Once the rest of Terraform is ready to use count and
  			// for_each, remove all of this and just write the addrs.ModuleInstance
  			// value itself into the ModuleState.
  			panic("diff cannot represent modules with count or for_each keys")
  		}
  
  		legacyPath[i] = step.Name
  	}
  
  	m := &ModuleDiff{Path: legacyPath}
  	m.init()
  	d.Modules = append(d.Modules, m)
  	return m
  }
docs: // AddModule adds the module with the given path to the diff.
  //
  // This should be the preferred method to add module diffs since it
  // allows us to optimize lookups later as well as control sorting.