mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 22:02:45 +01:00
Implement unused pattern bindings, continued (#6518)
Implementation of unused pattern bindings #2022, continued. Whereas previous PR #6460 took care of parsing, and PR #6479 prepared the stage by using _ in some test cases, this PR has the the actual implementation, using a simple dataflow analysis. --------- Co-authored-by: Burak Emir <bqe@google.com> Co-authored-by: jonmeow <jperkins@google.com>
This commit is contained in:
co-authored by
Burak Emir
jonmeow
parent
bea24a8bee
commit
fdb188ccfd
+16
-16
@@ -248,7 +248,7 @@ import Cpp library "return_lvalue_ref.h";
|
||||
|
||||
fn F() {
|
||||
//@dump-sem-ir-begin
|
||||
let ref s: Cpp.S = Cpp.ReturnsLValue();
|
||||
let unused ref s: Cpp.S = Cpp.ReturnsLValue();
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ import Cpp library "return_rvalue_ref.h";
|
||||
|
||||
fn F() {
|
||||
//@dump-sem-ir-begin
|
||||
let ref s: Cpp.S = Cpp.ReturnsRValue();
|
||||
let unused ref s: Cpp.S = Cpp.ReturnsRValue();
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ import Cpp library "return_const_lvalue_ref.h";
|
||||
|
||||
fn F() {
|
||||
//@dump-sem-ir-begin
|
||||
let ref s: const Cpp.S = Cpp.ReturnConstLValue();
|
||||
let unused ref s: const Cpp.S = Cpp.ReturnConstLValue();
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
@@ -303,14 +303,14 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp library "return_const_lvalue_ref.h";
|
||||
|
||||
fn F() {
|
||||
// CHECK:STDERR: fail_call_return_const_lvalue_ref_const_correctness.carbon:[[@LINE+7]]:22: error: cannot implicitly convert expression of type `const Cpp.S` to `Cpp.S` [ConversionFailure]
|
||||
// CHECK:STDERR: let ref s: Cpp.S = Cpp.ReturnConstLValue();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_call_return_const_lvalue_ref_const_correctness.carbon:[[@LINE+4]]:22: note: type `const Cpp.S` does not implement interface `Core.ImplicitAs(Cpp.S)` [MissingImplInMemberAccessNote]
|
||||
// CHECK:STDERR: let ref s: Cpp.S = Cpp.ReturnConstLValue();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_call_return_const_lvalue_ref_const_correctness.carbon:[[@LINE+7]]:29: error: cannot implicitly convert expression of type `const Cpp.S` to `Cpp.S` [ConversionFailure]
|
||||
// CHECK:STDERR: let unused ref s: Cpp.S = Cpp.ReturnConstLValue();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_call_return_const_lvalue_ref_const_correctness.carbon:[[@LINE+4]]:29: note: type `const Cpp.S` does not implement interface `Core.ImplicitAs(Cpp.S)` [MissingImplInMemberAccessNote]
|
||||
// CHECK:STDERR: let unused ref s: Cpp.S = Cpp.ReturnConstLValue();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
let ref s: Cpp.S = Cpp.ReturnConstLValue();
|
||||
let unused ref s: Cpp.S = Cpp.ReturnConstLValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -856,11 +856,11 @@ fn F() {
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %s.patt: %pattern_type = ref_binding_pattern s [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_22: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_29: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %ReturnsLValue.ref: %ReturnsLValue.cpp_overload_set.type = name_ref ReturnsLValue, imports.%ReturnsLValue.cpp_overload_set.value [concrete = constants.%ReturnsLValue.cpp_overload_set.value]
|
||||
// CHECK:STDOUT: %ReturnsLValue.call: ref %S = call imports.%ReturnsLValue.decl()
|
||||
// CHECK:STDOUT: %.loc8: type = splice_block %S.ref [concrete = constants.%S] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_14: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_21: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %s: ref %S = ref_binding s, %ReturnsLValue.call
|
||||
@@ -894,11 +894,11 @@ fn F() {
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %s.patt: %pattern_type = ref_binding_pattern s [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_22: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_29: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %ReturnsRValue.ref: %ReturnsRValue.cpp_overload_set.type = name_ref ReturnsRValue, imports.%ReturnsRValue.cpp_overload_set.value [concrete = constants.%ReturnsRValue.cpp_overload_set.value]
|
||||
// CHECK:STDOUT: %ReturnsRValue.call: ref %S = call imports.%ReturnsRValue.decl()
|
||||
// CHECK:STDOUT: %.loc8: type = splice_block %S.ref [concrete = constants.%S] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_14: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_21: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %s: ref %S = ref_binding s, %ReturnsRValue.call
|
||||
@@ -933,11 +933,11 @@ fn F() {
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %s.patt: %pattern_type = ref_binding_pattern s [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_28: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_35: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %ReturnConstLValue.ref: %ReturnConstLValue.cpp_overload_set.type = name_ref ReturnConstLValue, imports.%ReturnConstLValue.cpp_overload_set.value [concrete = constants.%ReturnConstLValue.cpp_overload_set.value]
|
||||
// CHECK:STDOUT: %ReturnConstLValue.call: ref %const = call imports.%ReturnConstLValue.decl()
|
||||
// CHECK:STDOUT: %.loc8: type = splice_block %const [concrete = constants.%const] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8_27: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
|
||||
// CHECK:STDOUT: %const: type = const_type %S.ref [concrete = constants.%const]
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
Reference in New Issue
Block a user