mirror of
https://github.com/golang/go
synced 2025-09-26 12:55:01 +00:00
When slicing, ignore expressions which could be elided, as in slicing starting at 0 or ending at len(v). Fixes #75278 Change-Id: I9c18e29c3d4da9bef89bd25bb261d3cb60e66392 Reviewed-on: https://go-review.googlesource.com/c/go/+/701216 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com>
26 lines
553 B
Go
26 lines
553 B
Go
// errorcheck -0 -m=2
|
|
|
|
// Copyright 2025 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package p
|
|
|
|
var a, b []int
|
|
|
|
func NoIndices() { // ERROR "can inline NoIndices with cost 4 as:.*"
|
|
b = a[:]
|
|
}
|
|
|
|
func LowIndex() { // ERROR "can inline LowIndex with cost 4 as:.*"
|
|
b = a[0:]
|
|
}
|
|
|
|
func HighIndex() { // ERROR "can inline HighIndex with cost 4 as:.*"
|
|
b = a[:len(a)]
|
|
}
|
|
|
|
func BothIndices() { // ERROR "can inline BothIndices with cost 4 as:.*"
|
|
b = a[0:len(a)]
|
|
}
|