Skip to content

Commit f4c8ab5

Browse files
authored
Rollup merge of rust-lang#120470 - estebank:issue-54196, r=compiler-errors
Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
2 parents 1bc6c50 + 8ebd47e commit f4c8ab5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/rustc_passes/src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ pub struct UnusedVariableTryPrefix {
17391739

17401740
#[derive(Subdiagnostic)]
17411741
pub enum UnusedVariableSugg {
1742-
#[multipart_suggestion(passes_suggestion, applicability = "machine-applicable")]
1742+
#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
17431743
TryPrefixSugg {
17441744
#[suggestion_part(code = "_{name}")]
17451745
spans: Vec<Span>,
@@ -1778,7 +1778,7 @@ pub struct UnusedVarTryIgnore {
17781778
}
17791779

17801780
#[derive(Subdiagnostic)]
1781-
#[multipart_suggestion(passes_suggestion, applicability = "machine-applicable")]
1781+
#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
17821782
pub struct UnusedVarTryIgnoreSugg {
17831783
#[suggestion_part(code = "{name}: _")]
17841784
pub shorthands: Vec<Span>,

tests/ui/lint/future-incompat-json-test.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{"$message_type":"future_incompat","future_incompat_report":[{"diagnostic":{"$message_type":"diagnostic","message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-A unused-variables` implied by `-A unused`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"to override `-A unused` add `#[allow(unused_variables)]`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `x`
1+
{"$message_type":"future_incompat","future_incompat_report":[{"diagnostic":{"$message_type":"diagnostic","message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-A unused-variables` implied by `-A unused`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"to override `-A unused` add `#[allow(unused_variables)]`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `x`
22
--> $DIR/future-incompat-json-test.rs:9:9
33
|
44
LL | let x = 1;

0 commit comments

Comments
 (0)