internal: deprecate LegacyModuleInfo

For golang/go#39629

Change-Id: I157a325cfb4be06d77860ef5eb77b7bdb15a532a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/258800
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/discovery.go b/internal/discovery.go
index cf97ed4..7b6e3b2 100644
--- a/internal/discovery.go
+++ b/internal/discovery.go
@@ -94,7 +94,7 @@
 
 // A Module is a specific, reproducible build of a module.
 type Module struct {
-	LegacyModuleInfo
+	ModuleInfo
 	// Licenses holds all licenses within this module version, including those
 	// that may be contained in nested subdirectories.
 	Licenses []*licenses.License
diff --git a/internal/fetch/fetch.go b/internal/fetch/fetch.go
index 0345c4f..444465a 100644
--- a/internal/fetch/fetch.go
+++ b/internal/fetch/fetch.go
@@ -289,15 +289,13 @@
 		})
 	}
 	return &internal.Module{
-		LegacyModuleInfo: internal.LegacyModuleInfo{
-			ModuleInfo: internal.ModuleInfo{
-				ModulePath:        modulePath,
-				Version:           resolvedVersion,
-				CommitTime:        commitTime,
-				IsRedistributable: d.ModuleIsRedistributable(),
-				HasGoMod:          hasGoMod,
-				SourceInfo:        sourceInfo,
-			},
+		ModuleInfo: internal.ModuleInfo{
+			ModulePath:        modulePath,
+			Version:           resolvedVersion,
+			CommitTime:        commitTime,
+			IsRedistributable: d.ModuleIsRedistributable(),
+			HasGoMod:          hasGoMod,
+			SourceInfo:        sourceInfo,
 		},
 		LegacyPackages: legacyPackages,
 		Licenses:       allLicenses,
diff --git a/internal/fetch/fetchdata_test.go b/internal/fetch/fetchdata_test.go
index e21e056..1651cdb 100644
--- a/internal/fetch/fetchdata_test.go
+++ b/internal/fetch/fetchdata_test.go
@@ -33,11 +33,9 @@
 	},
 	fr: &FetchResult{
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "github.com/basic",
-					HasGoMod:   false,
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "github.com/basic",
+				HasGoMod:   false,
 			},
 			Units: []*internal.Unit{
 				{
@@ -102,12 +100,10 @@
 	},
 	fr: &FetchResult{
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "github.com/my/module",
-					HasGoMod:   true,
-					SourceInfo: source.NewGitHubInfo("https://github.com/my/module", "", "v1.0.0"),
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "github.com/my/module",
+				HasGoMod:   true,
+				SourceInfo: source.NewGitHubInfo("https://github.com/my/module", "", "v1.0.0"),
 			},
 			Units: []*internal.Unit{
 				{
@@ -165,11 +161,9 @@
 	},
 	fr: &FetchResult{
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "no.mod/module",
-					HasGoMod:   false,
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "no.mod/module",
+				HasGoMod:   false,
 			},
 			Units: []*internal.Unit{
 				{
@@ -229,10 +223,8 @@
 	fr: &FetchResult{
 		Status: derrors.ToStatus(derrors.HasIncompletePackages),
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "bad.mod/module",
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "bad.mod/module",
 			},
 			Units: []*internal.Unit{
 				{
@@ -293,11 +285,9 @@
 	fr: &FetchResult{
 		Status: derrors.ToStatus(derrors.HasIncompletePackages),
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "build.constraints/module",
-					HasGoMod:   false,
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "build.constraints/module",
+				HasGoMod:   false,
 			},
 			Units: []*internal.Unit{
 				{
@@ -380,11 +370,9 @@
 	},
 	fr: &FetchResult{
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "nonredistributable.mod/module",
-					HasGoMod:   true,
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "nonredistributable.mod/module",
+				HasGoMod:   true,
 			},
 			Units: []*internal.Unit{
 				{
@@ -447,10 +435,8 @@
 	fr: &FetchResult{
 		Status: derrors.ToStatus(derrors.HasIncompletePackages),
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "bad.import.path.com",
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "bad.import.path.com",
 			},
 			Units: []*internal.Unit{
 				{
@@ -516,11 +502,9 @@
 	fr: &FetchResult{
 		GoModPath: "doc.test",
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "doc.test",
-					HasGoMod:   false,
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "doc.test",
+				HasGoMod:   false,
 			},
 			Units: []*internal.Unit{
 				{
@@ -557,11 +541,9 @@
 		Status:    derrors.ToStatus(derrors.HasIncompletePackages),
 		GoModPath: "bigdoc.test",
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "bigdoc.test",
-					HasGoMod:   false,
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "bigdoc.test",
+				HasGoMod:   false,
 			},
 			Units: []*internal.Unit{
 				{
@@ -604,11 +586,9 @@
 	},
 	fr: &FetchResult{
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "github.com/my/module/js",
-					SourceInfo: source.NewGitHubInfo("https://github.com/my/module", "js", "js/v1.0.0"),
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "github.com/my/module/js",
+				SourceInfo: source.NewGitHubInfo("https://github.com/my/module", "js", "js/v1.0.0"),
 			},
 			Units: []*internal.Unit{
 				{
@@ -653,14 +633,12 @@
 	},
 	fr: &FetchResult{
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "std",
-					Version:    "v1.12.5",
-					CommitTime: stdlib.TestCommitTime,
-					HasGoMod:   true,
-					SourceInfo: source.NewGitHubInfo("https://github.com/golang/go", "src", "go1.12.5"),
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "std",
+				Version:    "v1.12.5",
+				CommitTime: stdlib.TestCommitTime,
+				HasGoMod:   true,
+				SourceInfo: source.NewGitHubInfo("https://github.com/golang/go", "src", "go1.12.5"),
 			},
 			Units: []*internal.Unit{
 				{
@@ -796,12 +774,10 @@
 	fr: &FetchResult{
 		RequestedVersion: "master",
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "github.com/my/module",
-					Version:    "v0.0.0-20200706064627-355bc3f705ed",
-					SourceInfo: source.NewGitHubInfo("https://github.com/my/module", "", "355bc3f705ed"),
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "github.com/my/module",
+				Version:    "v0.0.0-20200706064627-355bc3f705ed",
+				SourceInfo: source.NewGitHubInfo("https://github.com/my/module", "", "355bc3f705ed"),
 			},
 			Units: []*internal.Unit{
 				{
@@ -834,12 +810,10 @@
 	fr: &FetchResult{
 		RequestedVersion: "latest",
 		Module: &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath: "github.com/my/module",
-					Version:    "v1.2.4",
-					SourceInfo: source.NewGitHubInfo("https://github.com/my/module", "", "v1.2.4"),
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath: "github.com/my/module",
+				Version:    "v1.2.4",
+				SourceInfo: source.NewGitHubInfo("https://github.com/my/module", "", "v1.2.4"),
 			},
 			Units: []*internal.Unit{
 				{
@@ -887,11 +861,9 @@
 		fr: &FetchResult{
 			GoModPath: path,
 			Module: &internal.Module{
-				LegacyModuleInfo: internal.LegacyModuleInfo{
-					ModuleInfo: internal.ModuleInfo{
-						ModulePath: path,
-						HasGoMod:   false,
-					},
+				ModuleInfo: internal.ModuleInfo{
+					ModulePath: path,
+					HasGoMod:   false,
 				},
 				Units: []*internal.Unit{
 					{
diff --git a/internal/frontend/header_test.go b/internal/frontend/header_test.go
index f66e724..0b07c1e 100644
--- a/internal/frontend/header_test.go
+++ b/internal/frontend/header_test.go
@@ -94,8 +94,8 @@
 func TestCreatePackage(t *testing.T) {
 	vpkg := func(modulePath, suffix, name string) *internal.LegacyVersionedPackage {
 		vp := &internal.LegacyVersionedPackage{
-			LegacyModuleInfo: *sample.LegacyModuleInfo(modulePath, sample.VersionString),
-			LegacyPackage:    *sample.LegacyPackage(modulePath, suffix),
+			ModuleInfo:    *sample.ModuleInfo(modulePath, sample.VersionString),
+			LegacyPackage: *sample.LegacyPackage(modulePath, suffix),
 		}
 		if name != "" {
 			vp.LegacyPackage.Name = name
diff --git a/internal/frontend/search_test.go b/internal/frontend/search_test.go
index 3b3129f..b754210 100644
--- a/internal/frontend/search_test.go
+++ b/internal/frontend/search_test.go
@@ -24,13 +24,11 @@
 	var (
 		now       = sample.NowTruncated()
 		moduleFoo = &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath:        "github.com/mod/foo",
-					Version:           "v1.0.0",
-					CommitTime:        now,
-					IsRedistributable: true,
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath:        "github.com/mod/foo",
+				Version:           "v1.0.0",
+				CommitTime:        now,
+				IsRedistributable: true,
 			},
 			Units: []*internal.Unit{
 				{
@@ -54,13 +52,11 @@
 			},
 		}
 		moduleBar = &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					ModulePath:        "github.com/mod/bar",
-					Version:           "v1.0.0",
-					CommitTime:        now,
-					IsRedistributable: true,
-				},
+			ModuleInfo: internal.ModuleInfo{
+				ModulePath:        "github.com/mod/bar",
+				Version:           "v1.0.0",
+				CommitTime:        now,
+				IsRedistributable: true,
 			},
 			Units: []*internal.Unit{
 				{
diff --git a/internal/frontend/versions_test.go b/internal/frontend/versions_test.go
index 3cb6f79..a47a03d 100644
--- a/internal/frontend/versions_test.go
+++ b/internal/frontend/versions_test.go
@@ -157,16 +157,16 @@
 	)
 
 	pkg1 := &internal.LegacyVersionedPackage{
-		LegacyModuleInfo: *sample.LegacyModuleInfo(modulePath1, "v1.2.1"),
-		LegacyPackage:    *sample.LegacyPackage(modulePath1, sample.Suffix),
+		ModuleInfo:    *sample.ModuleInfo(modulePath1, "v1.2.1"),
+		LegacyPackage: *sample.LegacyPackage(modulePath1, sample.Suffix),
 	}
 	pkg2 := &internal.LegacyVersionedPackage{
-		LegacyModuleInfo: *sample.LegacyModuleInfo(modulePath2, "v2.2.1-alpha.1"),
-		LegacyPackage:    *sample.LegacyPackage(modulePath2, sample.Suffix),
+		ModuleInfo:    *sample.ModuleInfo(modulePath2, "v2.2.1-alpha.1"),
+		LegacyPackage: *sample.LegacyPackage(modulePath2, sample.Suffix),
 	}
 	nethttpPkg := &internal.LegacyVersionedPackage{
-		LegacyModuleInfo: *sample.LegacyModuleInfo("std", "v1.12.5"),
-		LegacyPackage:    *sample.LegacyPackage("std", "net/http"),
+		ModuleInfo:    *sample.ModuleInfo("std", "v1.12.5"),
+		LegacyPackage: *sample.LegacyPackage("std", "net/http"),
 	}
 	makeList := func(pkgPath, modulePath, major string, versions []string) *VersionList {
 		return &VersionList{
@@ -288,7 +288,7 @@
 	for _, test := range tests {
 		mi := sample.ModuleInfo(test.modulePath, sample.VersionString)
 		if got := pathInVersion(test.v1Path, mi); got != test.want {
-			t.Errorf("pathInVersion(%q, LegacyModuleInfo{...ModulePath:%q}) = %s, want %v",
+			t.Errorf("pathInVersion(%q, ModuleInfo{...ModulePath:%q}) = %s, want %v",
 				test.v1Path, mi.ModulePath, got, test.want)
 		}
 	}
diff --git a/internal/legacy_discovery.go b/internal/legacy_discovery.go
index f3e3776..ca0f529 100644
--- a/internal/legacy_discovery.go
+++ b/internal/legacy_discovery.go
@@ -9,15 +9,10 @@
 	"golang.org/x/pkgsite/internal/licenses"
 )
 
-// LegacyModuleInfo holds metadata associated with a module.
-type LegacyModuleInfo struct {
-	ModuleInfo
-}
-
 // LegacyDirectory represents a directory in a module version, and all of the
 // packages inside that directory.
 type LegacyDirectory struct {
-	LegacyModuleInfo
+	ModuleInfo
 	Path     string
 	Packages []*LegacyPackage
 }
@@ -46,5 +41,5 @@
 // information.
 type LegacyVersionedPackage struct {
 	LegacyPackage
-	LegacyModuleInfo
+	ModuleInfo
 }
diff --git a/internal/postgres/path_test.go b/internal/postgres/path_test.go
index b783ae3..b25f5f8 100644
--- a/internal/postgres/path_test.go
+++ b/internal/postgres/path_test.go
@@ -40,13 +40,11 @@
 		pkgName := path.Base(testModule.packageSuffix)
 		pkgPath := path.Join(testModule.module, testModule.packageSuffix)
 		m := &internal.Module{
-			LegacyModuleInfo: internal.LegacyModuleInfo{
-				ModuleInfo: internal.ModuleInfo{
-					CommitTime: sample.CommitTime,
-					ModulePath: testModule.module,
-					Version:    testModule.version,
-					SourceInfo: source.NewGitHubInfo("https://"+testModule.module, "", testModule.version),
-				},
+			ModuleInfo: internal.ModuleInfo{
+				CommitTime: sample.CommitTime,
+				ModulePath: testModule.module,
+				Version:    testModule.version,
+				SourceInfo: source.NewGitHubInfo("https://"+testModule.module, "", testModule.version),
 			},
 			LegacyPackages: []*internal.LegacyPackage{{
 				Name:     pkgName,
diff --git a/internal/testing/sample/legacy.go b/internal/testing/sample/legacy.go
index ca3e052..0b897ce 100644
--- a/internal/testing/sample/legacy.go
+++ b/internal/testing/sample/legacy.go
@@ -38,13 +38,6 @@
 	}
 }
 
-func LegacyModuleInfo(modulePath, versionString string) *internal.LegacyModuleInfo {
-	mi := ModuleInfo(modulePath, versionString)
-	return &internal.LegacyModuleInfo{
-		ModuleInfo: *mi,
-	}
-}
-
 func LegacyDefaultModule() *internal.Module {
 	return LegacyAddPackage(
 		LegacyModule(ModulePath, VersionString),
@@ -54,11 +47,11 @@
 // LegacyModule creates a Module with the given path and version.
 // The list of suffixes is used to create LegacyPackages within the module.
 func LegacyModule(modulePath, version string, suffixes ...string) *internal.Module {
-	mi := LegacyModuleInfo(modulePath, version)
+	mi := ModuleInfo(modulePath, version)
 	m := &internal.Module{
-		LegacyModuleInfo: *mi,
-		LegacyPackages:   nil,
-		Licenses:         Licenses,
+		ModuleInfo:     *mi,
+		LegacyPackages: nil,
+		Licenses:       Licenses,
 	}
 	m.Units = []*internal.Unit{legacyUnitForModuleRoot(mi)}
 	for _, s := range suffixes {
@@ -101,7 +94,7 @@
 	return m
 }
 
-func legacyUnitForModuleRoot(m *internal.LegacyModuleInfo) *internal.Unit {
+func legacyUnitForModuleRoot(m *internal.ModuleInfo) *internal.Unit {
 	u := &internal.Unit{
 		UnitMeta:        *UnitMeta(m.ModulePath, m.ModulePath, m.Version, "", m.IsRedistributable),
 		LicenseContents: Licenses,