Replace unused bindings with anonymous binding in lower/testdata. (#6479)

This updates lower/testdata to use _ instead of proper names, in order
to avoid the "unused binding" warnings from #2022 which are being
implemented. These changes do not depend on the implementation which
should make everything easier to review.

See #6460 with part 1 of the implementation. It was split upon request
in order to make reviewing easier, the original state of the PR was
updating hundreds of test cases.
The PR has thus been split, part 2 including test cases changes can be
viewed at
https://github.com/burakemir/carbon-lang/tree/unused_pattern_bindings_p2022_impl_part2
... many tests need to be updated, so it seems best to get those tests
out of the way that are not interesting.

These are not all tests in lower/testdata - a few of them are
interesting in the sense that they cannot use '_' because it leads to
failed redeclaration check. This is exactly the scenario described in
#3763 which requires the 'unused' marker. Those are left untouched here
but are updated in
https://github.com/burakemir/carbon-lang/tree/unused_pattern_bindings_p2022_impl_part2
This commit is contained in:
Burak Emir
2025-12-17 15:43:04 +00:00
committed by GitHub
parent fec6ce2f9f
commit 992d435023
65 changed files with 721 additions and 698 deletions
+4 -4
View File
@@ -62,7 +62,7 @@ auto TakePtrWithThunk(C*, int = 0) -> void;
auto ReturnPtrWithThunk(int = 0) -> C*;
''';
fn PassPtr(p: Core.Optional(Cpp.C*)) {
fn PassPtr(_: Core.Optional(Cpp.C*)) {
// TODO: Add support for passing an optional here.
// Cpp.TakePtr(p);
}
@@ -77,7 +77,7 @@ fn ReturnPtr() -> Core.Optional(Cpp.C*) {
return Cpp.ReturnPtr();
}
fn PassPtrWithThunk(p: Core.Optional(Cpp.C*)) {
fn PassPtrWithThunk(_: Core.Optional(Cpp.C*)) {
// TODO: Add support for passing an optional here.
// Cpp.TakePtrWithThunk(p);
}
@@ -189,7 +189,7 @@ fn ReturnPtrWithThunk() -> Core.Optional(Cpp.C*) {
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define void @_CPassPtr.Main(ptr %p) #0 !dbg !7 {
// CHECK:STDOUT: define void @_CPassPtr.Main(ptr %_) #0 !dbg !7 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret void, !dbg !13
// CHECK:STDOUT: }
@@ -218,7 +218,7 @@ fn ReturnPtrWithThunk() -> Core.Optional(Cpp.C*) {
// CHECK:STDOUT: declare ptr @_Z9ReturnPtrv()
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define void @_CPassPtrWithThunk.Main(ptr %p) #0 !dbg !25 {
// CHECK:STDOUT: define void @_CPassPtrWithThunk.Main(ptr %_) #0 !dbg !25 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret void, !dbg !28
// CHECK:STDOUT: }