]> Cypherpunks repositories - gostls13.git/commitdiff
go: various minor cleanups with the help of Goland
authorkumakichi <xyesan@gmail.com>
Tue, 27 Apr 2021 18:38:55 +0000 (18:38 +0000)
committerRobert Griesemer <gri@golang.org>
Tue, 27 Apr 2021 18:57:27 +0000 (18:57 +0000)
    • fix some typos
    • remove superfluous conversions/parentheses
    • remove superfluous nil checks

Change-Id: I428bf6a7be551b79270567047878c3076dd6f2ff
GitHub-Last-Rev: 3b1c7573cfdf89ac184fd6ae44bca4be78b0cd64
GitHub-Pull-Request: golang/go#45799
Reviewed-on: https://go-review.googlesource.com/c/go/+/314069
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>

src/go/internal/srcimporter/srcimporter.go
src/go/parser/error_test.go
src/go/parser/parser.go
src/go/printer/printer.go
src/go/scanner/errors.go
src/go/scanner/scanner.go
src/go/types/infer.go

index 438ae0ff2ee7de290df6510ebb5edcf7539ab243..e4225eb4d7861c192dd42da6e1f684fb7d707e34 100644 (file)
@@ -30,7 +30,7 @@ type Importer struct {
        packages map[string]*types.Package
 }
 
-// NewImporter returns a new Importer for the given context, file set, and map
+// New returns a new Importer for the given context, file set, and map
 // of packages. The context is used to resolve import paths to package paths,
 // and identifying the files belonging to the package. If the context provides
 // non-nil file system functions, they are used instead of the regular package
index 5d45a7b817b62af0cd10a12128fbd8c48c7a76f6..f4f0a5240ac801e71ce64c7e868025afb97780b4 100644 (file)
@@ -90,7 +90,7 @@ func expectedErrors(fset *token.FileSet, filename string, src []byte) map[token.
                                if s[1] == "HERE" {
                                        pos = here
                                }
-                               errors[pos] = string(s[2])
+                               errors[pos] = s[2]
                        }
                case token.SEMICOLON:
                        // don't use the position of auto-inserted (invisible) semicolons
index a4db57170ba76168c5ad6a9200936891335cdaf5..36a044e3a29fc09b1206e936e81dcb4c74919c21 100644 (file)
@@ -891,7 +891,7 @@ func (p *parser) parseParameters(acceptTParams bool) (tparams, params *ast.Field
                rbrack := p.expect(token.RBRACK)
                tparams = &ast.FieldList{Opening: opening, List: list, Closing: rbrack}
                // Type parameter lists must not be empty.
-               if tparams != nil && tparams.NumFields() == 0 {
+               if tparams.NumFields() == 0 {
                        p.error(tparams.Closing, "empty type parameter list")
                        tparams = nil // avoid follow-on errors
                }
index f02c1b847b66f9c987a7cdaf65e1f3cd84454778..ba61f782267ad8ed27ab5b2252f06bdf70cc5252 100644 (file)
@@ -844,7 +844,7 @@ func (p *printer) writeWhitespace(n int) {
 // ----------------------------------------------------------------------------
 // Printing interface
 
-// nlines limits n to maxNewlines.
+// nlimit limits n to maxNewlines.
 func nlimit(n int) int {
        if n > maxNewlines {
                n = maxNewlines
index bf7bfa30e4bcc261f1985bb02cf8193a6822c6cb..3114f4b645d91da154031f73caa147a8153aee51 100644 (file)
@@ -86,7 +86,7 @@ func (p *ErrorList) RemoveMultiples() {
                        i++
                }
        }
-       (*p) = (*p)[0:i]
+       *p = (*p)[0:i]
 }
 
 // An ErrorList implements the error interface.
index 299c03fc9710f4f700ffb321d8ea0b52a2d13993..29cbf39721f6d2746142c5728fe1dfd6c1ea387f 100644 (file)
@@ -430,7 +430,7 @@ func (s *Scanner) digits(base int, invalid *int) (digsep int) {
                        if s.ch == '_' {
                                ds = 2
                        } else if s.ch >= max && *invalid < 0 {
-                               *invalid = int(s.offset) // record invalid rune offset
+                               *invalid = s.offset // record invalid rune offset
                        }
                        digsep |= ds
                        s.next()
index 8b491eb3ba8aad68f9ad46efcdfd7a6d4d619b95..9a45d5e9940e6760cef8047c5d82358702bddb76 100644 (file)
@@ -215,7 +215,7 @@ func (check *Checker) infer(posn positioner, tparams []*TypeName, targs []Type,
        }
 
        // At least one type argument couldn't be inferred.
-       assert(targs != nil && index >= 0 && targs[index] == nil)
+       assert(index >= 0 && targs[index] == nil)
        tpar := tparams[index]
        if report {
                check.errorf(posn, _Todo, "cannot infer %s (%v) (%v)", tpar.name, tpar.pos, targs)