apply suggestions
This commit is contained in:
parent
6d1a25ad7e
commit
ed5443fcdf
@ -260,7 +260,8 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
|
||||
// if let .. { body } else { break; }
|
||||
// }
|
||||
// ```
|
||||
// There is no observable from the `{ break; }` block so the edition change
|
||||
// There is no observable change in drop order on the overall `if let` expression
|
||||
// given that the `{ break; }` block is trivial so the edition change
|
||||
// means nothing substantial to this `while` statement.
|
||||
self.skip.insert(value.hir_id);
|
||||
return;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//@ run-rustfix
|
||||
|
||||
#![deny(if_let_rescope)]
|
||||
#![feature(if_let_rescope)]
|
||||
#![feature(if_let_rescope, stmt_expr_attributes)]
|
||||
#![allow(irrefutable_let_patterns, unused_parens)]
|
||||
|
||||
fn droppy() -> Droppy {
|
||||
@ -69,16 +69,29 @@ fn main() {
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
if (match droppy().get() { Some(_value) => { true } _ => { false }}) {
|
||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||
//~| WARN: this changes meaning in Rust 2024
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
//~| HELP: the value is now dropped here in Edition 2024
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
// do something
|
||||
} else if (((match droppy().get() { Some(_value) => { true } _ => { false }}))) {
|
||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||
//~| WARN: this changes meaning in Rust 2024
|
||||
//~| HELP: the value is now dropped here in Edition 2024
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
}
|
||||
|
||||
while let Some(_value) = droppy().get() {
|
||||
// Should not lint
|
||||
break;
|
||||
}
|
||||
|
||||
while (match droppy().get() { Some(_value) => { false } _ => { true }}) {
|
||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||
//~| WARN: this changes meaning in Rust 2024
|
||||
//~| HELP: the value is now dropped here in Edition 2024
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//@ run-rustfix
|
||||
|
||||
#![deny(if_let_rescope)]
|
||||
#![feature(if_let_rescope)]
|
||||
#![feature(if_let_rescope, stmt_expr_attributes)]
|
||||
#![allow(irrefutable_let_patterns, unused_parens)]
|
||||
|
||||
fn droppy() -> Droppy {
|
||||
@ -69,16 +69,29 @@ fn main() {
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
if (if let Some(_value) = droppy().get() { true } else { false }) {
|
||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||
//~| WARN: this changes meaning in Rust 2024
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
//~| HELP: the value is now dropped here in Edition 2024
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
// do something
|
||||
} else if (((if let Some(_value) = droppy().get() { true } else { false }))) {
|
||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||
//~| WARN: this changes meaning in Rust 2024
|
||||
//~| HELP: the value is now dropped here in Edition 2024
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
}
|
||||
|
||||
while let Some(_value) = droppy().get() {
|
||||
// Should not lint
|
||||
break;
|
||||
}
|
||||
|
||||
while (if let Some(_value) = droppy().get() { false } else { true }) {
|
||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||
//~| WARN: this changes meaning in Rust 2024
|
||||
//~| HELP: the value is now dropped here in Edition 2024
|
||||
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ LL | if let () = { match Droppy.get() { Some(_value) => {} _ => {}} } {
|
||||
| ~~~~~ +++++++++++++++++ ++++++++
|
||||
|
||||
error: `if let` assigns a shorter lifetime since Edition 2024
|
||||
--> $DIR/lint-if-let-rescope.rs:72:12
|
||||
--> $DIR/lint-if-let-rescope.rs:73:12
|
||||
|
|
||||
LL | if (if let Some(_value) = droppy().get() { true } else { false }) {
|
||||
| ^^^^^^^^^^^^^^^^^^^--------^^^^^^
|
||||
@ -142,7 +142,7 @@ LL | if (if let Some(_value) = droppy().get() { true } else { false }) {
|
||||
= warning: this changes meaning in Rust 2024
|
||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||
help: the value is now dropped here in Edition 2024
|
||||
--> $DIR/lint-if-let-rescope.rs:72:53
|
||||
--> $DIR/lint-if-let-rescope.rs:73:53
|
||||
|
|
||||
LL | if (if let Some(_value) = droppy().get() { true } else { false }) {
|
||||
| ^
|
||||
@ -151,5 +151,45 @@ help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
LL | if (match droppy().get() { Some(_value) => { true } _ => { false }}) {
|
||||
| ~~~~~ +++++++++++++++++ ~~~~ +
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: `if let` assigns a shorter lifetime since Edition 2024
|
||||
--> $DIR/lint-if-let-rescope.rs:79:21
|
||||
|
|
||||
LL | } else if (((if let Some(_value) = droppy().get() { true } else { false }))) {
|
||||
| ^^^^^^^^^^^^^^^^^^^--------^^^^^^
|
||||
| |
|
||||
| this value has a significant drop implementation which may observe a major change in drop order and requires your discretion
|
||||
|
|
||||
= warning: this changes meaning in Rust 2024
|
||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||
help: the value is now dropped here in Edition 2024
|
||||
--> $DIR/lint-if-let-rescope.rs:79:62
|
||||
|
|
||||
LL | } else if (((if let Some(_value) = droppy().get() { true } else { false }))) {
|
||||
| ^
|
||||
help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
|
|
||||
LL | } else if (((match droppy().get() { Some(_value) => { true } _ => { false }}))) {
|
||||
| ~~~~~ +++++++++++++++++ ~~~~ +
|
||||
|
||||
error: `if let` assigns a shorter lifetime since Edition 2024
|
||||
--> $DIR/lint-if-let-rescope.rs:91:15
|
||||
|
|
||||
LL | while (if let Some(_value) = droppy().get() { false } else { true }) {
|
||||
| ^^^^^^^^^^^^^^^^^^^--------^^^^^^
|
||||
| |
|
||||
| this value has a significant drop implementation which may observe a major change in drop order and requires your discretion
|
||||
|
|
||||
= warning: this changes meaning in Rust 2024
|
||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||
help: the value is now dropped here in Edition 2024
|
||||
--> $DIR/lint-if-let-rescope.rs:91:57
|
||||
|
|
||||
LL | while (if let Some(_value) = droppy().get() { false } else { true }) {
|
||||
| ^
|
||||
help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||
|
|
||||
LL | while (match droppy().get() { Some(_value) => { false } _ => { true }}) {
|
||||
| ~~~~~ +++++++++++++++++ ~~~~ +
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user