about summary refs log tree commit diff
path: root/src/test/ui/error-codes
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-01-19 10:27:56 +0100
committerGitHub <noreply@github.com>2021-01-19 10:27:56 +0100
commit348997a05f169908c3555396dd0d8f383be3a7d9 (patch)
tree00a50fd6ce61e539ff97aef742d2c45a00c3a036 /src/test/ui/error-codes
parent6af6c40a12e42e9a21c98df4d8d5ba052e2e4b69 (diff)
parent70a43e07f6887dd1de62a9bbbc77b4a0c6e8d0d8 (diff)
downloadrust-348997a05f169908c3555396dd0d8f383be3a7d9.tar.gz
rust-348997a05f169908c3555396dd0d8f383be3a7d9.zip
Rollup merge of #81147 - estebank:drop-suggestion, r=varkor
Fix structured suggestion for explicit `drop` call
Diffstat (limited to 'src/test/ui/error-codes')
-rw-r--r--src/test/ui/error-codes/E0040.fixed18
-rw-r--r--src/test/ui/error-codes/E0040.rs3
-rw-r--r--src/test/ui/error-codes/E0040.stderr10
3 files changed, 26 insertions, 5 deletions
diff --git a/src/test/ui/error-codes/E0040.fixed b/src/test/ui/error-codes/E0040.fixed
new file mode 100644
index 00000000000..139dc8f9496
--- /dev/null
+++ b/src/test/ui/error-codes/E0040.fixed
@@ -0,0 +1,18 @@
+// run-rustfix
+struct Foo {
+    x: i32,
+}
+
+impl Drop for Foo {
+    fn drop(&mut self) {
+        println!("kaboom");
+    }
+}
+
+fn main() {
+    let mut x = Foo { x: -7 };
+    x.x = 0;
+    println!("{}", x.x);
+    drop(x);
+    //~^ ERROR E0040
+}
diff --git a/src/test/ui/error-codes/E0040.rs b/src/test/ui/error-codes/E0040.rs
index 113efae82c5..9ffc42d0c78 100644
--- a/src/test/ui/error-codes/E0040.rs
+++ b/src/test/ui/error-codes/E0040.rs
@@ -1,3 +1,4 @@
+// run-rustfix
 struct Foo {
     x: i32,
 }
@@ -10,6 +11,8 @@ impl Drop for Foo {
 
 fn main() {
     let mut x = Foo { x: -7 };
+    x.x = 0;
+    println!("{}", x.x);
     x.drop();
     //~^ ERROR E0040
 }
diff --git a/src/test/ui/error-codes/E0040.stderr b/src/test/ui/error-codes/E0040.stderr
index 69cf28b2970..9fcda1a9385 100644
--- a/src/test/ui/error-codes/E0040.stderr
+++ b/src/test/ui/error-codes/E0040.stderr
@@ -1,11 +1,11 @@
 error[E0040]: explicit use of destructor method
-  --> $DIR/E0040.rs:13:7
+  --> $DIR/E0040.rs:16:7
    |
 LL |     x.drop();
-   |       ^^^^
-   |       |
-   |       explicit destructor calls not allowed
-   |       help: consider using `drop` function: `drop(x)`
+   |     --^^^^--
+   |     | |
+   |     | explicit destructor calls not allowed
+   |     help: consider using `drop` function: `drop(x)`
 
 error: aborting due to previous error