Browse Source

cmd/protoc-gen-go, runtime/protoimpl: enforce minimum and maximum versions

Generate the needed infrastructure to ensure that we can statically
enforce minimum and maximum versions. This enables us to have a policy
when we release v2 where it fails to build for:
* new generated code with really old runtimes
* new runtimes with really old generated code

Change-Id: Ib699ad62c06dff8f9285806394a741c18db00288
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/178546
Reviewed-by: Damien Neil <dneil@google.com>
Joe Tsai 6 years ago
parent
commit
58b42d8892
63 changed files with 402 additions and 79 deletions
  1. 6 1
      cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
  2. 6 1
      cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
  3. 7 6
      cmd/protoc-gen-go/internal_gengo/main.go
  4. 6 1
      cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
  5. 1 1
      cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta
  6. 6 1
      cmd/protoc-gen-go/testdata/comments/comments.pb.go
  7. 6 1
      cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
  8. 6 1
      cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
  9. 6 1
      cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
  10. 6 1
      cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
  11. 6 1
      cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
  12. 6 1
      cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
  13. 6 1
      cmd/protoc-gen-go/testdata/import_public/a.pb.go
  14. 6 1
      cmd/protoc-gen-go/testdata/import_public/b.pb.go
  15. 6 1
      cmd/protoc-gen-go/testdata/import_public/c.pb.go
  16. 6 1
      cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
  17. 6 1
      cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
  18. 6 1
      cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
  19. 6 1
      cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
  20. 6 1
      cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
  21. 6 1
      cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
  22. 6 1
      cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
  23. 6 1
      cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
  24. 6 1
      cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
  25. 6 1
      cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
  26. 6 1
      cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
  27. 6 1
      cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
  28. 6 1
      cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
  29. 6 1
      cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
  30. 6 1
      cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
  31. 6 1
      cmd/protoc-gen-go/testdata/proto2/enum.pb.go
  32. 6 1
      cmd/protoc-gen-go/testdata/proto2/fields.pb.go
  33. 6 1
      cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
  34. 6 1
      cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
  35. 6 1
      cmd/protoc-gen-go/testdata/proto3/enum.pb.go
  36. 6 1
      cmd/protoc-gen-go/testdata/proto3/fields.pb.go
  37. 6 1
      encoding/testprotos/pb2/test.pb.go
  38. 6 1
      encoding/testprotos/pb3/test.pb.go
  39. 6 1
      internal/testprotos/conformance/conformance.pb.go
  40. 6 1
      internal/testprotos/conformance/test_messages_proto2.pb.go
  41. 6 1
      internal/testprotos/conformance/test_messages_proto3.pb.go
  42. 6 1
      internal/testprotos/legacy/legacy.pb.go
  43. 6 1
      internal/testprotos/test/ext.pb.go
  44. 6 1
      internal/testprotos/test/test.pb.go
  45. 6 1
      internal/testprotos/test/test_import.pb.go
  46. 6 1
      internal/testprotos/test/test_public.pb.go
  47. 6 1
      internal/testprotos/test/weak/test_weak.pb.go
  48. 6 1
      internal/testprotos/test3/test.pb.go
  49. 6 1
      internal/testprotos/test3/test_import.pb.go
  50. 6 1
      reflect/protoregistry/testprotos/test.pb.go
  51. 34 12
      runtime/protoimpl/impl.go
  52. 6 1
      types/descriptorpb/descriptor.pb.go
  53. 6 1
      types/known/anypb/any.pb.go
  54. 6 1
      types/known/apipb/api.pb.go
  55. 6 1
      types/known/durationpb/duration.pb.go
  56. 6 1
      types/known/emptypb/empty.pb.go
  57. 6 1
      types/known/fieldmaskpb/field_mask.pb.go
  58. 6 1
      types/known/sourcecontextpb/source_context.pb.go
  59. 6 1
      types/known/structpb/struct.pb.go
  60. 6 1
      types/known/timestamppb/timestamp.pb.go
  61. 6 1
      types/known/typepb/type.pb.go
  62. 6 1
      types/known/wrapperspb/wrappers.pb.go
  63. 6 1
      types/pluginpb/plugin.pb.go

+ 6 - 1
cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go

@@ -10,7 +10,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 var File_grpc_deprecation_proto protoreflect.FileDescriptor
 

+ 6 - 1
cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Request struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 7 - 6
cmd/protoc-gen-go/internal_gengo/main.go

@@ -20,15 +20,11 @@ import (
 	"google.golang.org/protobuf/internal/encoding/tag"
 	"google.golang.org/protobuf/internal/fieldnum"
 	"google.golang.org/protobuf/reflect/protoreflect"
+	"google.golang.org/protobuf/runtime/protoimpl"
 
 	"google.golang.org/protobuf/types/descriptorpb"
 )
 
-// minimumVersion is minimum version of the v2 proto package that is required.
-// This is incremented every time the generated code relies on some property
-// in the proto package that was introduced in a later version.
-const minimumVersion = 0
-
 const (
 	// generateEnumMapVars specifies whether to generate enum maps,
 	// which provide a bi-directional mapping between enum numbers and names.
@@ -110,7 +106,12 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
 	g.P()
 
 	// Emit a static check that enforces a minimum version of the proto package.
-	g.P("const _ = ", protoimplPackage.Ident("EnforceVersion"), "(", protoimplPackage.Ident("Version"), " - ", minimumVersion, ")")
+	g.P("const (")
+	g.P("// Verify that runtime/protoimpl is sufficiently up-to-date.")
+	g.P("_ = ", protoimplPackage.Ident("EnforceVersion"), "(", protoimplPackage.Ident("MaxVersion"), " - ", protoimpl.Version, ")")
+	g.P("// Verify that this generated code is sufficiently up-to-date.")
+	g.P("_ = ", protoimplPackage.Ident("EnforceVersion"), "(", protoimpl.Version, " - ", protoimplPackage.Ident("MinVersion"), ")")
+	g.P(")")
 	g.P()
 
 	for i, imps := 0, f.Desc.Imports(); i < imps.Len(); i++ {

+ 6 - 1
cmd/protoc-gen-go/testdata/annotations/annotations.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type AnnotationsTestEnum int32
 

+ 1 - 1
cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta

@@ -1 +1 @@
-annotation:{path:5 path:0 source_file:"annotations/annotations.proto" begin:449 end:468} annotation:{path:5 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:485 end:532} annotation:{path:4 path:0 source_file:"annotations/annotations.proto" begin:1913 end:1935} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:1946 end:1966} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:2987 end:3010}
+annotation:{path:5 path:0 source_file:"annotations/annotations.proto" begin:639 end:658} annotation:{path:5 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:675 end:722} annotation:{path:4 path:0 source_file:"annotations/annotations.proto" begin:2103 end:2125} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:2136 end:2156} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:3177 end:3200}

+ 6 - 1
cmd/protoc-gen-go/testdata/comments/comments.pb.go

@@ -13,7 +13,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // COMMENT: Message1
 type Message1 struct {

+ 6 - 1
cmd/protoc-gen-go/testdata/comments/deprecated.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type DeprecatedEnum int32 // Deprecated: Do not use.
 const (

+ 6 - 1
cmd/protoc-gen-go/testdata/extensions/base/base.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type BaseMessage struct {
 	Field                  *string                   `protobuf:"bytes,1,opt,name=field" json:"field,omitempty"`

+ 6 - 1
cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go

@@ -13,7 +13,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Enum int32
 

+ 6 - 1
cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type ExtraMessage struct {
 	Data                 []byte                  `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`

+ 6 - 1
cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Enum int32
 

+ 6 - 1
cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // Assorted edge cases in field name conflict resolution.
 //

+ 6 - 1
cmd/protoc-gen-go/testdata/import_public/a.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // Symbols defined in public import of import_public/sub/a.proto
 

+ 6 - 1
cmd/protoc-gen-go/testdata/import_public/b.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Local struct {
 	M                    *sub.M                  `protobuf:"bytes,1,opt,name=m" json:"m,omitempty"`

+ 6 - 1
cmd/protoc-gen-go/testdata/import_public/c.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type UsingPublicImport struct {
 	// Local is declared in b.proto, which is a public import of a.proto.

+ 6 - 1
cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go

@@ -13,7 +13,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // Symbols defined in public import of import_public/sub2/a.proto
 

+ 6 - 1
cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type M2 struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Sub2Message struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type M struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type E1 int32
 

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type M2 struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type M3 struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type M4 struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type M1 struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type M2 struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type A1M1 struct {
 	F                    *test_a_1.M1            `protobuf:"bytes,1,opt,name=f,proto3" json:"f,omitempty"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type A1M2 struct {
 	F                    *test_a_1.M2            `protobuf:"bytes,1,opt,name=f,proto3" json:"f,omitempty"`

+ 6 - 1
cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go

@@ -15,7 +15,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type All struct {
 	Am1                  *test_a_1.M1            `protobuf:"bytes,1,opt,name=am1,proto3" json:"am1,omitempty"`

+ 6 - 1
cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Foo struct {
 	// Types that are valid to be assigned to Bar:

+ 6 - 1
cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Enum int32
 

+ 6 - 1
cmd/protoc-gen-go/testdata/proto2/enum.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // EnumType1 comment.
 type EnumType1 int32

+ 6 - 1
cmd/protoc-gen-go/testdata/proto2/fields.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type FieldTestMessage_Enum int32
 

+ 6 - 1
cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Layer1 struct {
 	L2                   *Layer1_Layer2          `protobuf:"bytes,1,opt,name=l2" json:"l2,omitempty"`

+ 6 - 1
cmd/protoc-gen-go/testdata/proto2/proto2.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Message struct {
 	I32                  *int32                  `protobuf:"varint,1,opt,name=i32" json:"i32,omitempty"`

+ 6 - 1
cmd/protoc-gen-go/testdata/proto3/enum.pb.go

@@ -10,7 +10,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Enum int32
 

+ 6 - 1
cmd/protoc-gen-go/testdata/proto3/fields.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type FieldTestMessage_Enum int32
 

+ 6 - 1
encoding/testprotos/pb2/test.pb.go

@@ -18,7 +18,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Enum int32
 

+ 6 - 1
encoding/testprotos/pb3/test.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Enum int32
 

+ 6 - 1
internal/testprotos/conformance/conformance.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type WireFormat int32
 

+ 6 - 1
internal/testprotos/conformance/test_messages_proto2.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type ForeignEnumProto2 int32
 

+ 6 - 1
internal/testprotos/conformance/test_messages_proto3.pb.go

@@ -17,7 +17,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type ForeignEnum int32
 

+ 6 - 1
internal/testprotos/legacy/legacy.pb.go

@@ -23,7 +23,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Legacy struct {
 	F1                   *proto2_v0_0.Message    `protobuf:"bytes,1,opt,name=f1,proto3" json:"f1,omitempty"`

+ 6 - 1
internal/testprotos/test/ext.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 var file_test_ext_proto_extDescs = []protoiface.ExtensionDescV1{
 	{

+ 6 - 1
internal/testprotos/test/test.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type ForeignEnum int32
 

+ 6 - 1
internal/testprotos/test/test_import.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type ImportEnum int32
 

+ 6 - 1
internal/testprotos/test/test_public.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type PublicImportMessage struct {
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`

+ 6 - 1
internal/testprotos/test/weak/test_weak.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type WeakImportMessage struct {
 	A                    *int32                  `protobuf:"varint,1,opt,name=a" json:"a,omitempty"`

+ 6 - 1
internal/testprotos/test3/test.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type ForeignEnum int32
 

+ 6 - 1
internal/testprotos/test3/test_import.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type ImportEnum int32
 

+ 6 - 1
reflect/protoregistry/testprotos/test.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type Enum1 int32
 

+ 34 - 12
runtime/protoimpl/impl.go

@@ -16,26 +16,46 @@ import (
 	"google.golang.org/protobuf/internal/impl"
 )
 
-// Version is the current minor version of the package.
-// This is incremented every time the API of this package expands.
-const Version = 0 // v2.{Version}.x
+const (
+	// MaxVersion is the maximum supported version for generated .pb.go files;
+	// which is the current version of the package.
+	// This is incremented when the functionality of this package expands.
+	MaxVersion = 0
 
-var X impl.Export
+	// MinVersion is the minimum supported version for generated .pb.go files.
+	// This is incremented when the runtime drops support for old code.
+	MinVersion = 0
+
+	// Version is the current minor version of the runtime.
+	Version = MaxVersion // v2.{Version}.x
+
+	// TODO: Encode a date instead of the minor version?
+)
 
 type (
 	// EnforceVersion is used by code generated by protoc-gen-go
-	// to statically enforce a minimum version of this package.
-	// A compilation failure implies that this package is too old and
-	// needs to be updated to a more recent version.
+	// to statically enforce minimum and maximum versions of this package.
+	// A compilation failure implies either that:
+	//	* the runtime package is too old and needs to be updated OR
+	//	* the generated code is too old and needs to be regenerated.
 	//
-	// This package can be upgraded by running:
-	//	go get -u google.golang.org/protobuf/...
+	// The runtime package can be upgraded by running:
+	//	go get google.golang.org/protobuf
+	//
+	// The generated code can be regenerated by running:
+	//	protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES}
 	//
 	// Example usage by generated code:
-	//	const _ = protoimpl.EnforceVersion(protoimpl.Version - genVersion)
+	//	const (
+	//		// Verify that runtime/protoimpl is sufficiently up-to-date.
+	//		_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion)
+	//		// Verify that this generated code is sufficiently up-to-date.
+	//		_ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion)
+	//	)
 	//
-	// If genVersion is lower than Version, then this results in a negative
-	// integer overflow failure when evaluating the uint constant.
+	// The genVersion is the current version used to generated the code.
+	// This compile-time check relies on negative integer overflow of a uint
+	// being a compilation failure (guaranteed by the Go specification).
 	EnforceVersion uint
 
 	MessageInfo = impl.MessageInfo
@@ -48,3 +68,5 @@ type (
 
 	ExtensionFieldV1 = impl.ExtensionFieldV1
 )
+
+var X impl.Export

+ 6 - 1
types/descriptorpb/descriptor.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 type FieldDescriptorProto_Type int32
 

+ 6 - 1
types/known/anypb/any.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // `Any` contains an arbitrary serialized protocol buffer message along with a
 // URL that describes the type of the serialized message.

+ 6 - 1
types/known/apipb/api.pb.go

@@ -13,7 +13,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // Api is a light-weight descriptor for an API Interface.
 //

+ 6 - 1
types/known/durationpb/duration.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // A Duration represents a signed, fixed-length span of time represented
 // as a count of seconds and fractions of seconds at nanosecond

+ 6 - 1
types/known/emptypb/empty.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // A generic empty message that you can re-use to avoid defining duplicated
 // empty messages in your APIs. A typical example is to use it as the request

+ 6 - 1
types/known/fieldmaskpb/field_mask.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // `FieldMask` represents a set of symbolic field paths, for example:
 //

+ 6 - 1
types/known/sourcecontextpb/source_context.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // `SourceContext` represents information about the source of a
 // protobuf element, like the file in which it is defined.

+ 6 - 1
types/known/structpb/struct.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // `NullValue` is a singleton enumeration to represent the null value for the
 // `Value` type union.

+ 6 - 1
types/known/timestamppb/timestamp.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // A Timestamp represents a point in time independent of any time zone or local
 // calendar, encoded as a count of seconds and fractions of seconds at

+ 6 - 1
types/known/typepb/type.pb.go

@@ -13,7 +13,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // The syntax in which a protocol buffer element is defined.
 type Syntax int32

+ 6 - 1
types/known/wrapperspb/wrappers.pb.go

@@ -11,7 +11,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // Wrapper message for `double`.
 //

+ 6 - 1
types/pluginpb/plugin.pb.go

@@ -12,7 +12,12 @@ import (
 	sync "sync"
 )
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+const (
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
+)
 
 // The version number of protocol compiler.
 type Version struct {