diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-01-19 10:27:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-19 10:27:56 +0100 |
| commit | 348997a05f169908c3555396dd0d8f383be3a7d9 (patch) | |
| tree | 00a50fd6ce61e539ff97aef742d2c45a00c3a036 /src/test/ui/error-codes | |
| parent | 6af6c40a12e42e9a21c98df4d8d5ba052e2e4b69 (diff) | |
| parent | 70a43e07f6887dd1de62a9bbbc77b4a0c6e8d0d8 (diff) | |
| download | rust-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.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 |
