about summary refs log tree commit diff
path: root/tests/ui/methods
diff options
context:
space:
mode:
authorsurechen <chenshuo17@huawei.com>2024-04-23 15:31:54 +0800
committersurechen <chenshuo17@huawei.com>2024-05-20 18:53:17 +0800
commitb092b5d02b9e2aea72d5993d36c1cbe60e4e9b6b (patch)
tree2564d66fdaf57a7c688fdfb3048b8a542ea45372 /tests/ui/methods
parent20483b68265f64de79442cf489a5316f918578f0 (diff)
downloadrust-b092b5d02b9e2aea72d5993d36c1cbe60e4e9b6b.tar.gz
rust-b092b5d02b9e2aea72d5993d36c1cbe60e4e9b6b.zip
Note for E0599 if shadowed bindings has the method.
implement #123558
Diffstat (limited to 'tests/ui/methods')
-rw-r--r--tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.rs7
-rw-r--r--tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.stderr17
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.rs b/tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.rs
new file mode 100644
index 00000000000..a08bbf1fdbe
--- /dev/null
+++ b/tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.rs
@@ -0,0 +1,7 @@
+fn main() {
+    let x = Some(3);
+    let y = vec![1, 2];
+    if let Some(y) = x {
+        y.push(y); //~ ERROR E0599
+    }
+}
diff --git a/tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.stderr b/tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.stderr
new file mode 100644
index 00000000000..aecad201c7b
--- /dev/null
+++ b/tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.stderr
@@ -0,0 +1,17 @@
+error[E0599]: no method named `push` found for type `{integer}` in the current scope
+  --> $DIR/account-for-shadowed-bindings-issue-123558.rs:5:11
+   |
+LL |         y.push(y);
+   |           ^^^^ method not found in `{integer}`
+   |
+note: there's an earlier shadowed binding `y` of type `Vec<{integer}>` that has method `push` available
+  --> $DIR/account-for-shadowed-bindings-issue-123558.rs:3:9
+   |
+LL |     let y = vec![1, 2];
+   |         ^ `y` of type `Vec<{integer}>` that has method `push` defined earlier here
+LL |     if let Some(y) = x {
+   |                 - earlier `y` shadowed here with type `{integer}`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0599`.