Fix the misleading diagnostic for let_underscore_drop on type without Drop implementation
This commit is contained in:
parent
3f99982c63
commit
58921874cb
@ -531,7 +531,7 @@ lint_non_binding_let_multi_suggestion =
|
|||||||
consider immediately dropping the value
|
consider immediately dropping the value
|
||||||
|
|
||||||
lint_non_binding_let_on_drop_type =
|
lint_non_binding_let_on_drop_type =
|
||||||
non-binding let on a type that implements `Drop`
|
non-binding let on a type that has a destructor
|
||||||
|
|
||||||
lint_non_binding_let_on_sync_lock = non-binding let on a synchronization lock
|
lint_non_binding_let_on_sync_lock = non-binding let on a synchronization lock
|
||||||
.label = this lock is not assigned to a binding and is immediately dropped
|
.label = this lock is not assigned to a binding and is immediately dropped
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
/// intent.
|
/// intent.
|
||||||
pub LET_UNDERSCORE_DROP,
|
pub LET_UNDERSCORE_DROP,
|
||||||
Allow,
|
Allow,
|
||||||
"non-binding let on a type that implements `Drop`"
|
"non-binding let on a type that has a destructor"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#![deny(let_underscore_drop)]
|
#![deny(let_underscore_drop)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = foo(); //~ ERROR non-binding let on a type that implements `Drop`
|
let _ = foo(); //~ ERROR non-binding let on a type that has a destructor
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn from_config(_: Config) {}
|
async fn from_config(_: Config) {}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: non-binding let on a type that implements `Drop`
|
error: non-binding let on a type that has a destructor
|
||||||
--> $DIR/issue-119696-err-on-fn.rs:5:5
|
--> $DIR/issue-119696-err-on-fn.rs:5:5
|
||||||
|
|
|
|
||||||
LL | let _ = foo();
|
LL | let _ = foo();
|
||||||
|
@ -12,9 +12,9 @@ pub fn ice_cold(beverage: Tait) {
|
|||||||
// Must destructure at least one field of `Foo`
|
// Must destructure at least one field of `Foo`
|
||||||
let Foo { field } = beverage;
|
let Foo { field } = beverage;
|
||||||
// boom
|
// boom
|
||||||
_ = field; //~ ERROR non-binding let on a type that implements `Drop`
|
_ = field; //~ ERROR non-binding let on a type that has a destructor
|
||||||
|
|
||||||
let _ = field; //~ ERROR non-binding let on a type that implements `Drop`
|
let _ = field; //~ ERROR non-binding let on a type that has a destructor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: non-binding let on a type that implements `Drop`
|
error: non-binding let on a type that has a destructor
|
||||||
--> $DIR/issue-119697-extra-let.rs:15:5
|
--> $DIR/issue-119697-extra-let.rs:15:5
|
||||||
|
|
|
|
||||||
LL | _ = field;
|
LL | _ = field;
|
||||||
@ -18,7 +18,7 @@ help: consider immediately dropping the value
|
|||||||
LL | drop(field);
|
LL | drop(field);
|
||||||
| ~~~~~ +
|
| ~~~~~ +
|
||||||
|
|
||||||
error: non-binding let on a type that implements `Drop`
|
error: non-binding let on a type that has a destructor
|
||||||
--> $DIR/issue-119697-extra-let.rs:17:5
|
--> $DIR/issue-119697-extra-let.rs:17:5
|
||||||
|
|
|
|
||||||
LL | let _ = field;
|
LL | let _ = field;
|
||||||
|
@ -10,7 +10,7 @@ fn drop(&mut self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = NontrivialDrop; //~WARNING non-binding let on a type that implements `Drop`
|
let _ = NontrivialDrop; //~WARNING non-binding let on a type that has a destructor
|
||||||
|
|
||||||
let (_, _) = (NontrivialDrop, NontrivialDrop); // This should be ignored.
|
let (_, _) = (NontrivialDrop, NontrivialDrop); // This should be ignored.
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
warning: non-binding let on a type that implements `Drop`
|
warning: non-binding let on a type that has a destructor
|
||||||
--> $DIR/let_underscore_drop.rs:13:5
|
--> $DIR/let_underscore_drop.rs:13:5
|
||||||
|
|
|
|
||||||
LL | let _ = NontrivialDrop;
|
LL | let _ = NontrivialDrop;
|
||||||
|
Loading…
Reference in New Issue
Block a user