]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: update x/mod to CL 205497
authorBryan C. Mills <bcmills@google.com>
Tue, 5 Nov 2019 21:09:50 +0000 (16:09 -0500)
committerBryan C. Mills <bcmills@google.com>
Tue, 5 Nov 2019 21:26:19 +0000 (21:26 +0000)
Also revert an incidental 'gofmt' of a vendored file from CL 205240.

Updates #34822

Change-Id: I82a015d865db4d865b4776a8013312f25dbb9181
Reviewed-on: https://go-review.googlesource.com/c/go/+/205539
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go.mod
src/cmd/go.sum
src/cmd/vendor/golang.org/x/mod/modfile/read.go
src/cmd/vendor/golang.org/x/mod/modfile/rule.go
src/cmd/vendor/golang.org/x/tools/go/analysis/internal/facts/facts.go
src/cmd/vendor/modules.txt

index de81b9ac765cc1ac0ffb1b4b16a9da0b95291957..896b863d4e2c7ee581579b18da396a61ea0ad152 100644 (file)
@@ -7,7 +7,7 @@ require (
        github.com/ianlancetaylor/demangle v0.0.0-20180524225900-fc6590592b44 // indirect
        golang.org/x/arch v0.0.0-20190815191158-8a70ba74b3a1
        golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
-       golang.org/x/mod v0.1.1-0.20191101203923-a222b9651630
+       golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee
        golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82 // indirect
        golang.org/x/tools v0.0.0-20191104222624-6b7b8b79ae80
 )
index e93b9a98eb6660b725ea66ffde0820b1cfb630f2..16336df2722922b1a93c68f8a32358134a3c4e05 100644 (file)
@@ -9,6 +9,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq
 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/mod v0.1.1-0.20191101203923-a222b9651630 h1:QsMqsRXZFQT+jRZnwpEDIwGHWg0UY9ZrpWiplCOEK5I=
 golang.org/x/mod v0.1.1-0.20191101203923-a222b9651630/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
+golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
index bfa90a5a6449ef9fab7cd155c5984d8673a2fd7a..616d00efdb1b6d6022b08dd34b39537236f38946 100644 (file)
@@ -90,6 +90,19 @@ func (x *FileSyntax) Span() (start, end Position) {
        return start, end
 }
 
+// addLine adds a line containing the given tokens to the file.
+//
+// If the first token of the hint matches the first token of the
+// line, the new line is added at the end of the block containing hint,
+// extracting hint into a new block if it is not yet in one.
+//
+// If the hint is non-nil buts its first token does not match,
+// the new line is added after the block containing hint
+// (or hint itself, if not in a block).
+//
+// If no hint is provided, addLine appends the line to the end of
+// the last block with a matching first token,
+// or to the end of the file if no such block exists.
 func (x *FileSyntax) addLine(hint Expr, tokens ...string) *Line {
        if hint == nil {
                // If no hint given, add to the last statement of the given type.
@@ -111,11 +124,27 @@ func (x *FileSyntax) addLine(hint Expr, tokens ...string) *Line {
                }
        }
 
+       newLineAfter := func(i int) *Line {
+               new := &Line{Token: tokens}
+               if i == len(x.Stmt) {
+                       x.Stmt = append(x.Stmt, new)
+               } else {
+                       x.Stmt = append(x.Stmt, nil)
+                       copy(x.Stmt[i+2:], x.Stmt[i+1:])
+                       x.Stmt[i+1] = new
+               }
+               return new
+       }
+
        if hint != nil {
                for i, stmt := range x.Stmt {
                        switch stmt := stmt.(type) {
                        case *Line:
                                if stmt == hint {
+                                       if stmt.Token == nil || stmt.Token[0] != tokens[0] {
+                                               return newLineAfter(i)
+                                       }
+
                                        // Convert line to line block.
                                        stmt.InBlock = true
                                        block := &LineBlock{Token: stmt.Token[:1], Line: []*Line{stmt}}
@@ -125,15 +154,25 @@ func (x *FileSyntax) addLine(hint Expr, tokens ...string) *Line {
                                        block.Line = append(block.Line, new)
                                        return new
                                }
+
                        case *LineBlock:
                                if stmt == hint {
+                                       if stmt.Token[0] != tokens[0] {
+                                               return newLineAfter(i)
+                                       }
+
                                        new := &Line{Token: tokens[1:], InBlock: true}
                                        stmt.Line = append(stmt.Line, new)
                                        return new
                                }
+
                                for j, line := range stmt.Line {
                                        if line == hint {
-                                               // Add new line after hint.
+                                               if stmt.Token[0] != tokens[0] {
+                                                       return newLineAfter(i)
+                                               }
+
+                                               // Add new line after hint within the block.
                                                stmt.Line = append(stmt.Line, nil)
                                                copy(stmt.Line[j+2:], stmt.Line[j+1:])
                                                new := &Line{Token: tokens[1:], InBlock: true}
index 66b08d97238c2f6f0f70c477203d012bdc18153f..292d5b60b5770c3f75b3dd019ac963b59966bed8 100644 (file)
@@ -505,9 +505,13 @@ func (f *File) AddGoStmt(version string) error {
                return fmt.Errorf("invalid language version string %q", version)
        }
        if f.Go == nil {
+               var hint Expr
+               if f.Module != nil && f.Module.Syntax != nil {
+                       hint = f.Module.Syntax
+               }
                f.Go = &Go{
                        Version: version,
-                       Syntax:  f.Syntax.addLine(nil, "go", version),
+                       Syntax:  f.Syntax.addLine(hint, "go", version),
                }
        } else {
                f.Go.Version = version
index fe8e8f3884403f258af5e8a7fec252a79dce4a34..1fb69c615915b046fad7fe8606c884ffb2fba1d4 100644 (file)
@@ -231,6 +231,7 @@ func Decode(pkg *types.Package, read func(packagePath string) ([]byte, error)) (
 // It may fail if one of the Facts could not be gob-encoded, but this is
 // a sign of a bug in an Analyzer.
 func (s *Set) Encode() []byte {
+
        // TODO(adonovan): opt: use a more efficient encoding
        // that avoids repeating PkgPath for each fact.
 
index 10e142568f486a50ec82908323df581beba501b0..9bb8bd5a44537333088485fd094dd60b27b89e08 100644 (file)
@@ -29,7 +29,7 @@ golang.org/x/arch/x86/x86asm
 golang.org/x/crypto/ed25519
 golang.org/x/crypto/ed25519/internal/edwards25519
 golang.org/x/crypto/ssh/terminal
-# golang.org/x/mod v0.1.1-0.20191101203923-a222b9651630
+# golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee
 ## explicit
 golang.org/x/mod/internal/lazyregexp
 golang.org/x/mod/modfile