Skip to content

Commit 8088b6d

Browse files
committed
slices: explicitly discard results of some functions
This will otherwise trigger an "unusedresult" vet check. Fixes #64978 Change-Id: Ie19aded0f808d394f389452c3ff7f3edc1ed710d Reviewed-on: https://go-review.googlesource.com/c/go/+/554196 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent c0693f6 commit 8088b6d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/slices/slices_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ func TestInsertPanics(t *testing.T) {
557557
{"with out-of-bounds index and = cap", a[:1:2], 2, b[:]},
558558
{"with out-of-bounds index and < cap", a[:1:3], 2, b[:]},
559559
} {
560-
if !panics(func() { Insert(test.s, test.i, test.v...) }) {
560+
if !panics(func() { _ = Insert(test.s, test.i, test.v...) }) {
561561
t.Errorf("Insert %s: got no panic, want panic", test.name)
562562
}
563563
}
@@ -684,7 +684,7 @@ func TestDeletePanics(t *testing.T) {
684684
{"s[i:j] is valid and j > len(s)", s, 0, 4},
685685
{"s[i:j] is valid and i == j > len(s)", s, 3, 3},
686686
} {
687-
if !panics(func() { Delete(test.s, test.i, test.j) }) {
687+
if !panics(func() { _ = Delete(test.s, test.i, test.j) }) {
688688
t.Errorf("Delete %s: got no panic, want panic", test.name)
689689
}
690690
}
@@ -906,10 +906,10 @@ func TestGrow(t *testing.T) {
906906
}
907907

908908
// Test number of allocations.
909-
if n := testing.AllocsPerRun(100, func() { Grow(s2, cap(s2)-len(s2)) }); n != 0 {
909+
if n := testing.AllocsPerRun(100, func() { _ = Grow(s2, cap(s2)-len(s2)) }); n != 0 {
910910
t.Errorf("Grow should not allocate when given sufficient capacity; allocated %v times", n)
911911
}
912-
if n := testing.AllocsPerRun(100, func() { Grow(s2, cap(s2)-len(s2)+1) }); n != 1 {
912+
if n := testing.AllocsPerRun(100, func() { _ = Grow(s2, cap(s2)-len(s2)+1) }); n != 1 {
913913
errorf := t.Errorf
914914
if race.Enabled || testenv.OptimizationOff() {
915915
errorf = t.Logf // this allocates multiple times in race detector mode
@@ -921,7 +921,7 @@ func TestGrow(t *testing.T) {
921921
var gotPanic bool
922922
func() {
923923
defer func() { gotPanic = recover() != nil }()
924-
Grow(s1, -1)
924+
_ = Grow(s1, -1)
925925
}()
926926
if !gotPanic {
927927
t.Errorf("Grow(-1) did not panic; expected a panic")
@@ -1037,7 +1037,7 @@ func TestReplacePanics(t *testing.T) {
10371037
{"s[i:j] is valid and j > len(s)", s, nil, 0, 4},
10381038
} {
10391039
ss, vv := Clone(test.s), Clone(test.v)
1040-
if !panics(func() { Replace(ss, test.i, test.j, vv...) }) {
1040+
if !panics(func() { _ = Replace(ss, test.i, test.j, vv...) }) {
10411041
t.Errorf("Replace %s: should have panicked", test.name)
10421042
}
10431043
}

0 commit comments

Comments
 (0)