about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorkoka <koka.code@gmail.com>2023-10-04 00:13:53 +0900
committerkoka <koka.code@gmail.com>2023-10-04 00:13:53 +0900
commitc7152679efd5cd7c433f77eae2109170e4cc34e8 (patch)
tree3cd14d6393b3cede0e4268574f83706af4ce64ce /tests
parent1a56f90ee5ff65020e9992dd6e434e9ec0e46435 (diff)
downloadrust-c7152679efd5cd7c433f77eae2109170e4cc34e8.tar.gz
rust-c7152679efd5cd7c433f77eae2109170e4cc34e8.zip
Apply review suggestions from @y21
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/redundant_locals.rs26
-rw-r--r--tests/ui/redundant_locals.stderr10
2 files changed, 28 insertions, 8 deletions
diff --git a/tests/ui/redundant_locals.rs b/tests/ui/redundant_locals.rs
index 985bc739b26..e81db300f15 100644
--- a/tests/ui/redundant_locals.rs
+++ b/tests/ui/redundant_locals.rs
@@ -124,14 +124,34 @@ impl Drop for WithDrop {
     fn drop(&mut self) {}
 }
 
+struct InnerDrop(WithDrop);
+
+struct ComposeDrop {
+    d: WithDrop,
+}
+
 struct WithoutDrop(usize);
 
 fn drop_trait() {
     let a = WithDrop(1);
     let b = WithDrop(2);
     let a = a;
+}
 
-    let c = WithoutDrop(1);
-    let d = WithoutDrop(2);
-    let c = c;
+fn without_drop() {
+    let a = WithoutDrop(1);
+    let b = WithoutDrop(2);
+    let a = a;
+}
+
+fn drop_inner() {
+    let a = InnerDrop(WithDrop(1));
+    let b = InnerDrop(WithDrop(2));
+    let a = a;
+}
+
+fn drop_compose() {
+    let a = ComposeDrop { d: WithDrop(1) };
+    let b = ComposeDrop { d: WithDrop(1) };
+    let a = a;
 }
diff --git a/tests/ui/redundant_locals.stderr b/tests/ui/redundant_locals.stderr
index 9f8dc6e6162..6e9da8fccbd 100644
--- a/tests/ui/redundant_locals.stderr
+++ b/tests/ui/redundant_locals.stderr
@@ -134,15 +134,15 @@ LL |         let x = x;
    = help: remove the redefinition of `x`
 
 error: redundant redefinition of a binding
-  --> $DIR/redundant_locals.rs:134:9
+  --> $DIR/redundant_locals.rs:142:9
    |
-LL |     let c = WithoutDrop(1);
+LL |     let a = WithoutDrop(1);
    |         ^
-LL |     let d = WithoutDrop(2);
-LL |     let c = c;
+LL |     let b = WithoutDrop(2);
+LL |     let a = a;
    |     ^^^^^^^^^^
    |
-   = help: remove the redefinition of `c`
+   = help: remove the redefinition of `a`
 
 error: aborting due to 14 previous errors