-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
run borrowck tests on BIDs and emit tail-expr-drop-order lints for
potential violations
- Loading branch information
1 parent
3bf62cc
commit 054769b
Showing
6 changed files
with
155 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Edition 2024 lint for change in drop order at tail expression | ||
// This lint is to capture potential borrow-checking errors | ||
// due to implementation of RFC 3606 <https://github.com/rust-lang/rfcs/pull/3606> | ||
//@ edition: 2021 | ||
|
||
#![deny(tail_expr_drop_order)] //~ NOTE: the lint level is defined here | ||
|
||
fn should_lint_with_potential_borrowck_err() { | ||
let _ = { String::new().as_str() }.len(); | ||
//~^ ERROR: a temporary value will be dropped here | ||
//~| WARN: this changes meaning in Rust 2024 | ||
//~| NOTE: consider using a `let` binding | ||
//~| NOTE: for more information, see | ||
} | ||
|
||
fn should_lint_with_unsafe_block() { | ||
fn f(_: usize) {} | ||
f(unsafe { String::new().as_str() }.len()); | ||
//~^ ERROR: a temporary value will be dropped here | ||
//~| WARN: this changes meaning in Rust 2024 | ||
//~| NOTE: consider using a `let` binding | ||
//~| NOTE: for more information, see | ||
} | ||
|
||
#[rustfmt::skip] | ||
fn should_lint_with_big_block() { | ||
fn f<T>(_: T) {} | ||
f({ | ||
&mut || 0 | ||
//~^ ERROR: a temporary value will be dropped here | ||
//~| WARN: this changes meaning in Rust 2024 | ||
//~| NOTE: consider using a `let` binding | ||
//~| NOTE: for more information, see | ||
}) | ||
} | ||
|
||
fn main() {} |
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,40 @@ | ||
error: a temporary value will be dropped here before the execution exits the block in Edition 2024, which will raise borrow checking error | ||
--> $DIR/lint-tail-expr-drop-order-borrowck.rs:9:36 | ||
| | ||
LL | let _ = { String::new().as_str() }.len(); | ||
| ------------- ^ | ||
| | | ||
| consider using a `let` binding to create a longer lived value; or replacing the `{ .. }` block with curly brackets `( .. )`; or folding the rest of the expression into the surrounding `unsafe { .. }` | ||
| | ||
= warning: this changes meaning in Rust 2024 | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> | ||
note: the lint level is defined here | ||
--> $DIR/lint-tail-expr-drop-order-borrowck.rs:6:9 | ||
| | ||
LL | #![deny(tail_expr_drop_order)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: a temporary value will be dropped here before the execution exits the block in Edition 2024, which will raise borrow checking error | ||
--> $DIR/lint-tail-expr-drop-order-borrowck.rs:18:37 | ||
| | ||
LL | f(unsafe { String::new().as_str() }.len()); | ||
| ------------- ^ | ||
| | | ||
| consider using a `let` binding to create a longer lived value; or replacing the `{ .. }` block with curly brackets `( .. )`; or folding the rest of the expression into the surrounding `unsafe { .. }` | ||
| | ||
= warning: this changes meaning in Rust 2024 | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> | ||
|
||
error: a temporary value will be dropped here before the execution exits the block in Edition 2024, which will raise borrow checking error | ||
--> $DIR/lint-tail-expr-drop-order-borrowck.rs:29:17 | ||
| | ||
LL | &mut || 0 | ||
| --------^ | ||
| | | ||
| consider using a `let` binding to create a longer lived value; or replacing the `{ .. }` block with curly brackets `( .. )`; or folding the rest of the expression into the surrounding `unsafe { .. }` | ||
| | ||
= warning: this changes meaning in Rust 2024 | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> | ||
|
||
error: aborting due to 3 previous errors | ||
|