mirror of
https://github.com/golang/go.git
synced 2024-09-21 18:38:37 +00:00
go: various minor cleanups with the help of Goland
• fix some typos
• remove superfluous conversions/parentheses
• remove superfluous nil checks
Change-Id: I428bf6a7be551b79270567047878c3076dd6f2ff
GitHub-Last-Rev: 3b1c7573cf
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>
This commit is contained in:
parent
0ae9c3b98b
commit
291eb0178f
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -86,7 +86,7 @@ func (p *ErrorList) RemoveMultiples() {
|
||||
i++
|
||||
}
|
||||
}
|
||||
(*p) = (*p)[0:i]
|
||||
*p = (*p)[0:i]
|
||||
}
|
||||
|
||||
// An ErrorList implements the error interface.
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user