diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2021-01-17 16:48:52 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2021-01-17 16:48:52 -0800 |
| commit | 70a43e07f6887dd1de62a9bbbc77b4a0c6e8d0d8 (patch) | |
| tree | 4ecaa2af68e7fb2af8d66206321358e0328e4552 /src/test/ui/error-codes | |
| parent | 2e46cb38f174a4112fcfeecf6d4235f18830552f (diff) | |
| download | rust-70a43e07f6887dd1de62a9bbbc77b4a0c6e8d0d8.tar.gz rust-70a43e07f6887dd1de62a9bbbc77b4a0c6e8d0d8.zip | |
Fix structured suggestion for explicit `drop` call
Diffstat (limited to 'src/test/ui/error-codes')
| -rw-r--r-- | src/test/ui/error-codes/E0040.fixed | 18 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0040.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0040.stderr | 10 |
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 |
