Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2c0409c

Browse files
Remove unused must_use
1 parent ca77504 commit 2c0409c

File tree

13 files changed

+358
-198
lines changed

13 files changed

+358
-198
lines changed

‎compiler/rustc_expand/src/expand.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,6 +2157,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
21572157
attr_name,
21582158
macro_name: pprust::path_to_string(&call.path),
21592159
invoc_span: call.path.span,
2160+
attr_span: attr.span,
21602161
},
21612162
);
21622163
}

‎compiler/rustc_lint/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ lint_unused_allocation_mut = unnecessary allocation, use `&mut` instead
982982
983983
lint_unused_builtin_attribute = unused attribute `{$attr_name}`
984984
.note = the built-in attribute `{$attr_name}` will be ignored, since it's applied to the macro invocation `{$macro_name}`
985+
.suggestion = remove the attribute
985986
986987
lint_unused_closure =
987988
unused {$pre}{$count ->

‎compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,14 @@ pub fn decorate_builtin_lint(
205205
}
206206
.decorate_lint(diag);
207207
}
208-
BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
209-
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name }.decorate_lint(diag);
208+
BuiltinLintDiag::UnusedBuiltinAttribute {
209+
attr_name,
210+
macro_name,
211+
invoc_span,
212+
attr_span,
213+
} => {
214+
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name, attr_span }
215+
.decorate_lint(diag);
210216
}
211217
BuiltinLintDiag::TrailingMacro(is_trailing, name) => {
212218
lints::TrailingMacro { is_trailing, name }.decorate_lint(diag);

‎compiler/rustc_lint/src/lints.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2935,9 +2935,10 @@ pub(crate) struct RawPrefix {
29352935
pub(crate) struct UnusedBuiltinAttribute {
29362936
#[note]
29372937
pub invoc_span: Span,
2938-
29392938
pub attr_name: Symbol,
29402939
pub macro_name: String,
2940+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
2941+
pub attr_span: Span,
29412942
}
29422943

29432944
#[derive(LintDiagnostic)]

‎compiler/rustc_lint_defs/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ pub enum BuiltinLintDiag {
647647
attr_name: Symbol,
648648
macro_name: String,
649649
invoc_span: Span,
650+
attr_span: Span,
650651
},
651652
PatternsInFnsWithoutBody {
652653
span: Span,

‎compiler/rustc_passes/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ passes_must_not_suspend =
510510
511511
passes_must_use_no_effect =
512512
`#[must_use]` has no effect when applied to {$article} {$target}
513+
.suggestion = remove the attribute
513514
514515
passes_no_link =
515516
attribute should be applied to an `extern crate` item

‎compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
16211621
UNUSED_ATTRIBUTES,
16221622
hir_id,
16231623
attr_span,
1624-
errors::MustUseNoEffect { article, target },
1624+
errors::MustUseNoEffect { article, target, attr_span },
16251625
);
16261626
}
16271627

‎compiler/rustc_passes/src/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ pub(crate) struct FfiConstInvalidTarget {
469469
pub(crate) struct MustUseNoEffect {
470470
pub article: &'static str,
471471
pub target: rustc_hir::Target,
472+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
473+
pub attr_span: Span,
472474
}
473475

474476
#[derive(Diagnostic)]

‎tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
//~^^ WARN this was previously accepted by the compiler
7272
#![must_use]
7373
//~^ WARN `#[must_use]` has no effect
74+
//~| HELP remove the attribute
7475
// see issue-43106-gating-of-stable.rs
7576
// see issue-43106-gating-of-unstable.rs
7677
// see issue-43106-gating-of-deprecated.rs
@@ -599,16 +600,20 @@ mod deprecated {
599600
}
600601

601602
#[must_use] //~ WARN `#[must_use]` has no effect
603+
//~^ HELP remove the attribute
602604
mod must_use {
603605
mod inner { #![must_use] } //~ WARN `#[must_use]` has no effect
606+
//~^ HELP remove the attribute
604607

605608
#[must_use] fn f() { }
606609

607610
#[must_use] struct S;
608611

609612
#[must_use] type T = S; //~ WARN `#[must_use]` has no effect
613+
//~^ HELP remove the attribute
610614

611615
#[must_use] impl S { } //~ WARN `#[must_use]` has no effect
616+
//~^ HELP remove the attribute
612617
}
613618

614619
#[windows_subsystem = "windows"]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /