Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the misleading diagnostic for let_underscore_drop on type without Drop implementation #130833

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ lint_non_binding_let_multi_suggestion =
consider immediately dropping the value
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
.label = this lock is not assigned to a binding and is immediately dropped
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ declare_lint! {
/// intent.
pub LET_UNDERSCORE_DROP,
Allow,
"non-binding let on a type that implements `Drop`"
"non-binding let on a type that has a destructor"
}

declare_lint! {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/let_underscore/issue-119696-err-on-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![deny(let_underscore_drop)]
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) {}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/let_underscore/issue-119696-err-on-fn.stderr
Original file line number Diff line number Diff line change
@@ -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
|
LL | let _ = foo();
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/lint/let_underscore/issue-119697-extra-let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pub fn ice_cold(beverage: Tait) {
// Must destructure at least one field of `Foo`
let Foo { field } = beverage;
// 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
}


Expand Down
4 changes: 2 additions & 2 deletions tests/ui/lint/let_underscore/issue-119697-extra-let.stderr
Original file line number Diff line number Diff line change
@@ -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
|
LL | _ = field;
Expand All @@ -18,7 +18,7 @@ help: consider immediately dropping the value
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
|
LL | let _ = field;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/let_underscore/let_underscore_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Drop for NontrivialDrop {
}

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.
}
2 changes: 1 addition & 1 deletion tests/ui/lint/let_underscore/let_underscore_drop.stderr
Original file line number Diff line number Diff line change
@@ -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
|
LL | let _ = NontrivialDrop;
Expand Down
Loading