forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of macro arguments within the `dropping_copy_types lint
- Loading branch information
Showing
4 changed files
with
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//@ check-fail | ||
//@ run-rustfix | ||
|
||
#![deny(dropping_copy_types)] | ||
|
||
use std::fmt::Write; | ||
|
||
fn main() { | ||
let mut msg = String::new(); | ||
let _ = writeln!(&mut msg, "test"); | ||
//~^ 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,12 @@ | ||
//@ check-fail | ||
//@ run-rustfix | ||
|
||
#![deny(dropping_copy_types)] | ||
|
||
use std::fmt::Write; | ||
|
||
fn main() { | ||
let mut msg = String::new(); | ||
drop(writeln!(&mut msg, "test")); | ||
//~^ 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,21 @@ | ||
error: calls to `std::mem::drop` with a value that implements `Copy` does nothing | ||
--> $DIR/dropping_copy_types-macros.rs:10:5 | ||
| | ||
LL | drop(writeln!(&mut msg, "test")); | ||
| ^^^^^--------------------------^ | ||
| | | ||
| argument has type `Result<(), std::fmt::Error>` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dropping_copy_types-macros.rs:4:9 | ||
| | ||
LL | #![deny(dropping_copy_types)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
help: use `let _ = ...` to ignore the expression or result | ||
| | ||
LL - drop(writeln!(&mut msg, "test")); | ||
LL + let _ = writeln!(&mut msg, "test"); | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
|