internal/legacy, internal/encoding/tag: don't synthesize options

Stop adding options to legacy MessageDescriptors and FieldDescriptors.
We would synthesize options messages containing semantic options
(FieldOptions.is_packed, FieldOptions.is_weak, MessageOptions.map_entry).
This information is already contained in the protoreflect descriptors,
so there is no real need to define a correct options message.

If we do want to include options in legacy descriptors, then we should
get the original value out of the FileDescriptorProto, since it may
include additional extensions or other information.

This change completely removes the dependency from internal/legacy to
descriptor.proto.

Change-Id: Ib6bbe4ca6e0fe7ae501f3e9b11d5fa0222808410
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/171458
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/encoding/tag/tag.go b/internal/encoding/tag/tag.go
index 4a57adc..23c07f5 100644
--- a/internal/encoding/tag/tag.go
+++ b/internal/encoding/tag/tag.go
@@ -13,10 +13,7 @@
 
 	defval "github.com/golang/protobuf/v2/internal/encoding/defval"
 	ptype "github.com/golang/protobuf/v2/internal/prototype"
-	scalar "github.com/golang/protobuf/v2/internal/scalar"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
-
-	descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
 )
 
 var byteType = reflect.TypeOf(byte(0))
@@ -31,8 +28,7 @@
 //
 // This function is a best effort attempt; parsing errors are ignored.
 func Unmarshal(tag string, goType reflect.Type) ptype.Field {
-	opts := new(descriptorpb.FieldOptions)
-	f := ptype.Field{Options: opts}
+	f := ptype.Field{}
 	for len(tag) > 0 {
 		i := strings.IndexByte(tag, ',')
 		if i < 0 {
@@ -105,9 +101,9 @@
 		case strings.HasPrefix(s, "json="):
 			f.JSONName = s[len("json="):]
 		case s == "packed":
-			opts.Packed = scalar.Bool(true)
+			f.IsPacked = ptype.True
 		case strings.HasPrefix(s, "weak="):
-			opts.Weak = scalar.Bool(true)
+			f.IsWeak = true
 			f.MessageType = ptype.PlaceholderMessage(pref.FullName(s[len("weak="):]))
 		case strings.HasPrefix(s, "def="):
 			// The default tag is special in that everything afterwards is the
diff --git a/internal/legacy/message.go b/internal/legacy/message.go
index 39addc4..01bc053 100644
--- a/internal/legacy/message.go
+++ b/internal/legacy/message.go
@@ -14,10 +14,7 @@
 	ptag "github.com/golang/protobuf/v2/internal/encoding/tag"
 	pimpl "github.com/golang/protobuf/v2/internal/impl"
 	ptype "github.com/golang/protobuf/v2/internal/prototype"
-	scalar "github.com/golang/protobuf/v2/internal/scalar"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
-
-	descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
 )
 
 // wrapMessage wraps v as a protoreflect.ProtoMessage,
@@ -247,7 +244,6 @@
 			m := &ptype.StandaloneMessage{
 				Syntax:     parent.Syntax,
 				FullName:   parent.FullName.Append(mapEntryName(f.Name)),
-				Options:    &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
 				IsMapEntry: true,
 				Fields: []ptype.Field{
 					ms.parseField(tagKey, "", "", t.Key(), nil),