forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A small diagnostic improvement for dropping_copy_types
fixes rust-lang#125189
- Loading branch information
Showing
8 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//@ check-fail | ||
|
||
#![deny(dropping_copy_types)] | ||
|
||
fn main() { | ||
let y = 1; | ||
let z = 2; | ||
match y { | ||
1 => drop(3), //~ ERROR calls to `std::mem::drop` | ||
2 => drop(y), //~ ERROR calls to `std::mem::drop` | ||
3 => if drop(z) == () {}, //~ ERROR calls to `std::mem::drop` | ||
_ => (), | ||
} | ||
|
||
drop(3.2); //~ ERROR calls to `std::mem::drop` | ||
drop(y); //~ ERROR calls to `std::mem::drop` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
error: calls to `std::mem::drop` with a value that implements `Copy` does nothing | ||
--> $DIR/dropping_copy_types-issue-125189.rs:9:14 | ||
| | ||
LL | 1 => drop(3), | ||
| ^^^^^-^ | ||
| | | ||
| argument has type `i32` | ||
| | ||
= note: use `let _ = ...` to ignore the expression or result | ||
note: the lint level is defined here | ||
--> $DIR/dropping_copy_types-issue-125189.rs:3:9 | ||
| | ||
LL | #![deny(dropping_copy_types)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: calls to `std::mem::drop` with a value that implements `Copy` does nothing | ||
--> $DIR/dropping_copy_types-issue-125189.rs:10:14 | ||
| | ||
LL | 2 => drop(y), | ||
| ^^^^^-^ | ||
| | | ||
| argument has type `i32` | ||
| | ||
= note: use `let _ = ...` to ignore the expression or result | ||
|
||
error: calls to `std::mem::drop` with a value that implements `Copy` does nothing | ||
--> $DIR/dropping_copy_types-issue-125189.rs:11:17 | ||
| | ||
LL | 3 => if drop(z) == () {}, | ||
| ^^^^^-^ | ||
| | | ||
| argument has type `i32` | ||
| | ||
= note: use `let _ = ...` to ignore the expression or result | ||
|
||
error: calls to `std::mem::drop` with a value that implements `Copy` does nothing | ||
--> $DIR/dropping_copy_types-issue-125189.rs:15:5 | ||
| | ||
LL | drop(3.2); | ||
| ^^^^^---^ | ||
| | | ||
| argument has type `f64` | ||
| | ||
= note: use `let _ = ...` to ignore the expression or result | ||
help: ignore the value | ||
| | ||
LL | let _ = 3.2; | ||
| ~~~~~~~~~~~ | ||
|
||
error: calls to `std::mem::drop` with a value that implements `Copy` does nothing | ||
--> $DIR/dropping_copy_types-issue-125189.rs:16:5 | ||
| | ||
LL | drop(y); | ||
| ^^^^^-^ | ||
| | | ||
| argument has type `i32` | ||
| | ||
= note: use `let _ = ...` to ignore the expression or result | ||
help: ignore the value | ||
| | ||
LL | let _ = y; | ||
| ~~~~~~~~~ | ||
|
||
error: aborting due to 5 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters