Rollup merge of #145274 - compiler-errors:unused-must-use, r=fmease

Remove unused `#[must_use]`

Self-explanatory

Fixes https://github.com/rust-lang/rust/issues/145257
This commit is contained in:
Jakub Beránek
2025-08-13 07:03:49 +02:00
committed by GitHub
13 changed files with 366 additions and 206 deletions

View File

@@ -2155,6 +2155,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
attr_name,
macro_name: pprust::path_to_string(&call.path),
invoc_span: call.path.span,
attr_span: attr.span,
},
);
}

View File

@@ -983,6 +983,7 @@ lint_unused_allocation_mut = unnecessary allocation, use `&mut` instead
lint_unused_builtin_attribute = unused attribute `{$attr_name}`
.note = the built-in attribute `{$attr_name}` will be ignored, since it's applied to the macro invocation `{$macro_name}`
.suggestion = remove the attribute
lint_unused_closure =
unused {$pre}{$count ->

View File

@@ -205,8 +205,14 @@ pub fn decorate_builtin_lint(
}
.decorate_lint(diag);
}
BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name }.decorate_lint(diag);
BuiltinLintDiag::UnusedBuiltinAttribute {
attr_name,
macro_name,
invoc_span,
attr_span,
} => {
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name, attr_span }
.decorate_lint(diag);
}
BuiltinLintDiag::TrailingMacro(is_trailing, name) => {
lints::TrailingMacro { is_trailing, name }.decorate_lint(diag);

View File

@@ -2938,9 +2938,10 @@ pub(crate) struct RawPrefix {
pub(crate) struct UnusedBuiltinAttribute {
#[note]
pub invoc_span: Span,
pub attr_name: Symbol,
pub macro_name: String,
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
pub attr_span: Span,
}
#[derive(LintDiagnostic)]

View File

@@ -647,6 +647,7 @@ pub enum BuiltinLintDiag {
attr_name: Symbol,
macro_name: String,
invoc_span: Span,
attr_span: Span,
},
PatternsInFnsWithoutBody {
span: Span,

View File

@@ -510,6 +510,7 @@ passes_must_not_suspend =
passes_must_use_no_effect =
`#[must_use]` has no effect when applied to {$article} {$target}
.suggestion = remove the attribute
passes_no_link =
attribute should be applied to an `extern crate` item

View File

@@ -1622,7 +1622,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
UNUSED_ATTRIBUTES,
hir_id,
attr_span,
errors::MustUseNoEffect { article, target },
errors::MustUseNoEffect { article, target, attr_span },
);
}

View File

@@ -469,6 +469,8 @@ pub(crate) struct FfiConstInvalidTarget {
pub(crate) struct MustUseNoEffect {
pub article: &'static str,
pub target: rustc_hir::Target,
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
pub attr_span: Span,
}
#[derive(Diagnostic)]