forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#75056 - Veykril:path_statements_lint, r=oli…
…-obk Lint path statements to suggest using drop when the type needs drop Fixes rust-lang#48852. With this change the current lint description doesn't really fit entirely anymore I think.
- Loading branch information
Showing
3 changed files
with
44 additions
and
5 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 |
---|---|---|
@@ -1,6 +1,17 @@ | ||
// compile-flags: -D path-statements | ||
fn main() { | ||
struct Droppy; | ||
|
||
impl Drop for Droppy { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
fn main() { | ||
let x = 10; | ||
x; //~ ERROR path statement with no effect | ||
|
||
let y = Droppy; | ||
y; //~ ERROR path statement drops value | ||
|
||
let z = (Droppy,); | ||
z; //~ ERROR path statement drops value | ||
} |
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 |
---|---|---|
@@ -1,10 +1,22 @@ | ||
error: path statement with no effect | ||
--> $DIR/warn-path-statement.rs:5:5 | ||
--> $DIR/warn-path-statement.rs:10:5 | ||
| | ||
LL | x; | ||
| ^^ | ||
| | ||
= note: requested on the command line with `-D path-statements` | ||
|
||
error: aborting due to previous error | ||
error: path statement drops value | ||
--> $DIR/warn-path-statement.rs:13:5 | ||
| | ||
LL | y; | ||
| ^^ help: use `drop` to clarify the intent: `drop(y);` | ||
|
||
error: path statement drops value | ||
--> $DIR/warn-path-statement.rs:16:5 | ||
| | ||
LL | z; | ||
| ^^ help: use `drop` to clarify the intent: `drop(z);` | ||
|
||
error: aborting due to 3 previous errors | ||
|