Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b7ed414
MirPatch: reduce new statement insertion complexity
tmiasko Nov 13, 2026
a73aaf4
`rustc_mir_build`: de-duplicate `local_temp_lifetime()`
Jules-Bertholet Nov 16, 2026
b0c9ab5
test asm const ptr operand of a vtable
folkertdev Nov 17, 2026
82638ac
lint: Avoid unused_parens warning for ref patterns with compound types
hardikxk Nov 13, 2026
1b8f8b0
Avoid linting all reference patterns binding an identifier
hardikxk Nov 14, 2026
4f844e2
Ignore pinned patterns
hardikxk Nov 14, 2026
4ec3020
Add tests for unused_parens warning on binding by reference patterns
hardikxk Nov 17, 2026
30ae715
Add `cd` alias to `std::env::set_current_dir`
MarioIlRosso Nov 17, 2026
23e72c7
Add test for unused variant in manual clone impl
tehforsch Nov 16, 2026
711c0ce
rustc_target: catch up with LLVM 24 movement on ppc64le bsd data layout
durin42 Nov 17, 2026
6f0ff78
Change the span building of qualified paths from first-to-last to cha…
FranciscoTGouveia Nov 17, 2026
d88bc8a
Fix dead-code not ignoring variants in patterns with `Self` type
tehforsch Nov 16, 2026
438f8b6
windows seek_write: document interaction with append mode
RalfJung Nov 18, 2026
2a94a9f
Go through `ShouldEmit` error path for invalid literals
JonathanBrouwer Nov 18, 2026
01f9f7a
Fold `UnusedDuplicate` and `UnusedMultiple` diagnostics into `Duplica…
petrak-at-canonical Nov 12, 2026
5795cdb
Fix SingleAttributeParser printing duplicate paths with .. instead of…
petrak-at-canonical Nov 13, 2026
3dc32c0
Collapse warn_unused_duplicate and warn_unused_duplicate_future_error
petrak-at-canonical Nov 16, 2026
fbeaa76
Rollup merge of #165913 - tmiasko:patch, r=dianqk
JonathanBrouwer Nov 18, 2026
a435bca
Rollup merge of #166081 - folkertdev:test-asm-const-vtable-ptr, r=Jon…
JonathanBrouwer Nov 18, 2026
0d331a8
Rollup merge of #166094 - FranciscoTGouveia:spans-qpath, r=petrochenkov
JonathanBrouwer Nov 18, 2026
2ce8ec0
Rollup merge of #166113 - tehforsch:fix-ignore-variant-stack-self-typ…
JonathanBrouwer Nov 18, 2026
a2741a5
Rollup merge of #166118 - durin42:llvm-24-ppc64le-unk-bsd-data-layout…
JonathanBrouwer Nov 18, 2026
a297341
Rollup merge of #166155 - RalfJung:windows-seek-write-append, r=Chris…
JonathanBrouwer Nov 18, 2026
e069349
Rollup merge of #165935 - petrak-at-canonical:duplicate-attr-diagnost…
JonathanBrouwer Nov 18, 2026
4f64560
Rollup merge of #165948 - hardikxk:lint/unused-parens, r=folkertdev
JonathanBrouwer Nov 18, 2026
e718520
Rollup merge of #166018 - Jules-Bertholet:no-duplication, r=dianne
JonathanBrouwer Nov 18, 2026
c8fe62f
Rollup merge of #166111 - MarioIlRosso:issue-130058-fix, r=JohnTitor
JonathanBrouwer Nov 18, 2026
260090f
Rollup merge of #166157 - JonathanBrouwer:recover-invalid-lit, r=pans…
JonathanBrouwer Nov 18, 2026
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
8 changes: 4 additions & 4 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl AttributeParser for NakedParser {

if let Some(earlier) = this.span {
let span = cx.attr_span;
cx.warn_unused_duplicate(earlier, span);
cx.warn_unused_duplicate(earlier, span, sym::naked, false);
} else {
this.span = Some(cx.attr_span);
}
Expand Down Expand Up @@ -505,22 +505,22 @@ impl AttributeParser for UsedParser {
UsedBy::Compiler => &mut group.first_compiler,
UsedBy::Linker => {
if let Some(prev) = group.first_default {
cx.warn_unused_duplicate(prev, attr_span);
cx.warn_unused_duplicate(prev, attr_span, sym::used, false);
return;
}
&mut group.first_linker
}
UsedBy::Default => {
if let Some(prev) = group.first_linker {
cx.warn_unused_duplicate(prev, attr_span);
cx.warn_unused_duplicate(prev, attr_span, sym::used, false);
return;
}
&mut group.first_default
}
};

if let Some(prev) = *target {
cx.warn_unused_duplicate(prev, attr_span);
cx.warn_unused_duplicate(prev, attr_span, sym::used, false);
} else {
*target = Some(attr_span);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc_attr_ir::AttributeKind;
use rustc_attr_ir::target::Target;
use rustc_feature::AttributeStability;
use rustc_lint_defs::builtin::MALFORMED_DIAGNOSTIC_ATTRIBUTES;
use rustc_span::{Span, sym};
use rustc_span::{Span, Symbol, sym};

use crate::attributes::diagnostic::gate_diagnostic_attr;
use crate::attributes::{AcceptMapping, AttributeParser};
Expand Down Expand Up @@ -52,7 +52,8 @@ impl OpaqueParser {
fn parse<'sess>(&mut self, cx: &mut AcceptContext<'_, 'sess>, args: &ArgParser) {
let attr_span = cx.attr_span;
if let Some(earlier_span) = self.attr_span {
cx.warn_unused_duplicate(earlier_span, attr_span);
let attr_path_interned = Symbol::intern(&cx.attr_path.to_string());
cx.warn_unused_duplicate(earlier_span, attr_span, attr_path_interned, false);
}
self.attr_span = Some(attr_span);

Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rustc_span::{Span, Symbol, edition, kw, sym};

use super::prelude::AllowedTargets;
use super::{AcceptMapping, AttributeParser, template};
use crate::DuplicateAttribute;
use crate::attributes::doc_comment::DOC_TARGETS;
use crate::context::{AcceptContext, FinalizeContext};
use crate::diagnostics::{
Expand All @@ -24,7 +25,7 @@ use crate::diagnostics::{
DocKeywordNotKeyword, DocTestLiteral, DocTestTakesList, DocTestUnknown, DocUnknownAny,
DocUnknownInclude, DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight,
DuplicateNotableTraitColor, ExpectedNameValue, ExpectedNoArgs, IllFormedAttributeInput,
InvalidNotableTraitAttr, InvalidNotableTraitColor, MalformedDoc, UnusedDuplicate,
InvalidNotableTraitAttr, InvalidNotableTraitColor, MalformedDoc,
};
use crate::parser::{
ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser,
Expand Down Expand Up @@ -279,7 +280,12 @@ impl DocParser {
let unused_span = path.span();
cx.emit_lint(
INVALID_DOC_ATTRIBUTES,
UnusedDuplicate { this: unused_span, other: used_span, warning: true },
DuplicateAttribute {
this: unused_span,
other: used_span,
name: sym::no_crate_inject,
warning: true,
},
unused_span,
);
return;
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_feature::AttributeStability;
use rustc_lint_defs::builtin::{ILL_FORMED_ATTRIBUTE_INPUT, UNUSED_ATTRIBUTES};

use super::prelude::*;
use crate::diagnostics::{InlineForceInlineConflict, InlineIgnoredForExported, UnusedMultiple};
use crate::diagnostics::{DuplicateAttribute, InlineForceInlineConflict, InlineIgnoredForExported};

#[derive(Default)]
pub(crate) struct InlineParser(Option<(InlineAttr, Span)>);
Expand Down Expand Up @@ -70,7 +70,7 @@ impl AttributeParser for InlineParser {
cx.emit_err(InlineForceInlineConflict { inline_span, force_inline_span });
}
Some((_, first_inline_span)) => {
cx.warn_unused_duplicate_future_error(first_inline_span, inline_span);
cx.warn_unused_duplicate(first_inline_span, inline_span, sym::inline, true);
}
}
},
Expand Down Expand Up @@ -108,10 +108,11 @@ impl AttributeParser for InlineParser {
match this.0 {
None => this.0 = Some((attr, force_inline_span)),
Some((InlineAttr::Force { .. }, first_force_inline_span)) => {
cx.emit_err(UnusedMultiple {
cx.emit_err(DuplicateAttribute {
this: force_inline_span,
other: first_force_inline_span,
name: sym::rustc_force_inline,
warning: false,
});
}
Some((_, inline_span)) => {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ impl AttributeParser for MacroUseParser {
"State is UseAll is some so this is not the first attribute",
);
// Since there is a `#[macro_use]` import already, give a warning
cx.warn_unused_duplicate(first_span, span);
cx.warn_unused_duplicate(first_span, span, sym::macro_use, false);
}
MacroUseArgs::UseSpecific(_) => {
group.state = MacroUseArgs::UseAll;
group.first_span = Some(span);
// If there is a `#[macro_use]` attribute, warn on all `#[macro_use(...)]` attributes since everything is already imported
for specific_use in group.uses_attr_spans.drain(..) {
cx.warn_unused_duplicate(span, specific_use);
cx.warn_unused_duplicate(span, specific_use, sym::macro_use, false);
}
}
}
Expand All @@ -81,7 +81,7 @@ impl AttributeParser for MacroUseParser {
let first_span = group.first_span.expect(
"State is UseAll is some so this is not the first attribute",
);
cx.warn_unused_duplicate(first_span, span);
cx.warn_unused_duplicate(first_span, span, sym::macro_use, false);
}
MacroUseArgs::UseSpecific(arguments) => {
// Store here so if we encounter a `UseAll` later we can still lint this attribute
Expand Down
18 changes: 7 additions & 11 deletions compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use rustc_span::{Span, Symbol};
use thin_vec::ThinVec;

use crate::context::{AcceptContext, FinalizeCheckContext, FinalizeCheckFn, FinalizeContext};
use crate::diagnostics::UnusedMultiple;
use crate::diagnostics::DuplicateAttribute;
use crate::parser::ArgParser;
use crate::target_checking::AllowedTargets;
use crate::{AttributeTemplate, template};
Expand Down Expand Up @@ -234,19 +234,15 @@ impl OnDuplicate {
used: Span,
unused: Span,
) {
let name =
Symbol::intern(&P::PATH.iter().map(|i| i.to_string()).collect::<Vec<_>>().join("::"));
match self {
OnDuplicate::Warn => cx.warn_unused_duplicate(used, unused),
OnDuplicate::WarnButFutureError => cx.warn_unused_duplicate_future_error(used, unused),
OnDuplicate::Ignore => {}
OnDuplicate::Warn => cx.warn_unused_duplicate(used, unused, name, false),
OnDuplicate::WarnButFutureError => cx.warn_unused_duplicate(used, unused, name, true),
OnDuplicate::Error => {
cx.emit_err(UnusedMultiple {
this: unused,
other: used,
name: Symbol::intern(
&P::PATH.iter().map(|i| i.to_string()).collect::<Vec<_>>().join(".."),
),
});
cx.emit_err(DuplicateAttribute { this: unused, other: used, name, warning: false });
}
OnDuplicate::Ignore => {}
}
}
}
Expand Down
18 changes: 6 additions & 12 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ use crate::attributes::unroll::*;
use crate::attributes::{AttributeParser as _, AttributeSafety, Combine, Single, WithoutArgs};
use crate::diagnostics::{
AttributeParseError, AttributeParseErrorReason, AttributeParseErrorSuggestions,
ParsedDescription, UnusedDuplicate,
ParsedDescription,
};
use crate::parser::{
ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser, NameValueParser,
RefPathParser,
};
use crate::target_checking::AllowedTargets;
use crate::{AttributeParser, AttributeTemplate, EmitAttribute};
use crate::{AttributeParser, AttributeTemplate, DuplicateAttribute, EmitAttribute};

type GroupType = LazyLock<GroupTypeInner>;

Expand Down Expand Up @@ -475,22 +475,16 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> {
(self.emit_lint)(LintId::of(lint), span.into(), kind);
}

pub(crate) fn warn_unused_duplicate(&mut self, used_span: Span, unused_span: Span) {
self.emit_lint(
UNUSED_ATTRIBUTES,
UnusedDuplicate { this: unused_span, other: used_span, warning: false },
unused_span,
)
}

pub(crate) fn warn_unused_duplicate_future_error(
pub(crate) fn warn_unused_duplicate(
&mut self,
used_span: Span,
unused_span: Span,
name: Symbol,
future_error: bool,
) {
self.emit_lint(
UNUSED_ATTRIBUTES,
UnusedDuplicate { this: unused_span, other: used_span, warning: true },
DuplicateAttribute { this: unused_span, other: used_span, name, warning: future_error },
unused_span,
)
}
Expand Down
21 changes: 6 additions & 15 deletions compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,14 +1350,18 @@ pub(crate) struct UnknownVersionLiteral {
}

#[derive(Diagnostic)]
#[diag("multiple `{$name}` attributes")]
pub struct UnusedMultiple {
#[diag("duplicate `{$name}` attributes")]
pub struct DuplicateAttribute {
#[primary_span]
#[suggestion("remove this attribute", code = "", applicability = "unspecified")]
pub this: Span,
#[note("attribute also specified here")]
pub other: Span,
pub name: Symbol,
#[warning(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
pub warning: bool,
}

#[derive(Diagnostic)]
Expand Down Expand Up @@ -2191,19 +2195,6 @@ pub(crate) struct AdditionalCommaSuggestion {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("unused attribute")]
pub(crate) struct UnusedDuplicate {
#[suggestion("remove this attribute", code = "", applicability = "unspecified")]
pub this: Span,
#[note("attribute also specified here")]
pub other: Span,
#[warning(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
pub warning: bool,
}

#[derive(Diagnostic)]
#[diag("`#[macro_export]` is not allowed on declarative macro definitions")]
#[note("declarative macros follow the same exporting rules as regular items")]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub use attributes::cfg_select::*;
pub use attributes::crate_level::PREDEFINED_TOOLS;
pub use attributes::util::{is_builtin_attr, parse_version};
pub use context::ShouldEmit;
pub use diagnostics::{ParsedDescription, UnusedMultiple};
pub use diagnostics::{DuplicateAttribute, ParsedDescription};
pub use interface::{AttributeParser, EmitAttribute};
pub use rustc_parse::parser::Recovery;
pub use template::AttributeTemplate;
22 changes: 2 additions & 20 deletions compiler/rustc_attr_parsing/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use std::sync::atomic::{AtomicBool, Ordering};

use rustc_ast::token::{self, Delimiter, MetaVarKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{
AttrArgs, Expr, ExprKind, LitKind, MetaItemLit, Path, PathSegment, StmtKind, UnOp,
};
use rustc_ast::{AttrArgs, Expr, ExprKind, MetaItemLit, Path, PathSegment, StmtKind, UnOp};
use rustc_ast_pretty::pprust;
use rustc_attr_ir::AttrPath;
use rustc_errors::{Applicability, Diag, PResult};
Expand Down Expand Up @@ -424,23 +422,7 @@ fn expr_to_lit<'sess>(
Err(psess.dcx().create_err(SuffixedLiteralInAttribute { span: lit.span }))
}
}
Err(err) => {
let err = create_lit_error(psess, err, token_lit, expr.span);
if matches!(
should_emit,
ShouldEmit::ErrorsAndLints { recovery: Recovery::Forbidden }
) {
Err(err)
} else {
let lit = MetaItemLit {
symbol: token_lit.symbol,
suffix: token_lit.suffix,
kind: LitKind::Err(err.emit_err()),
span: expr.span,
};
Ok(Some(lit))
}
}
Err(err) => Err(create_lit_error(psess, err, token_lit, expr.span)),
}
} else {
if matches!(should_emit, ShouldEmit::Nothing) || matches!(expr.kind, ExprKind::Err(_)) {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{self as ast, AttrStyle, Attribute, MetaItem, attr, token};
use rustc_attr_parsing::{AttributeTemplate, UnusedMultiple, validate_attr};
use rustc_attr_parsing::{AttributeTemplate, DuplicateAttribute, validate_attr};
use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt};
use rustc_expand::expand::AstFragment;
Expand Down Expand Up @@ -51,7 +51,7 @@ pub(crate) fn warn_on_duplicate_attribute(
DUPLICATE_MACRO_ATTRIBUTES,
attr.span,
ecx.current_expansion.lint_node_id,
UnusedMultiple { this: attr.span, other: span, name },
DuplicateAttribute { this: attr.span, other: span, name, warning: false },
);
}
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ fn init_module<'ll, 'tcx>(tcx: TyCtxt<'tcx>, llcx: llvm::Context<'ll>, llmod: ll
target_data_layout = target_data_layout
.replace("-p10:32:32-p11:32:32-p12:32:32-p13:32:32-p14:32:32-p15:32:32", "");
}
if sess.target.arch == Arch::PowerPC64 && sess.target.os == Os::FreeBsd {
// LLVM 24 updated the powerpc64 FreeBSD layout to use 16-byte stack and vector
// alignment: https://github.com/llvm/llvm-project/pull/232336
target_data_layout = target_data_layout.replace("-S128-v256:256:256-v512:512:512", "");
}
}
// Ensure the data-layout values hardcoded remain the defaults.
{
Expand Down
30 changes: 9 additions & 21 deletions compiler/rustc_hir/src/pat_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use std::iter::Enumerate;
use rustc_hir_id::HirId;
use rustc_span::{Ident, Span};

use crate::def::{CtorOf, DefKind, Res};
use crate::def_id::{DefId, DefIdSet};
use crate::QPath;
use crate::hir::{self, BindingMode, ByRef, PatKind};
pub struct EnumerateAndAdjust<I> {
enumerate: Enumerate<I>,
Expand Down Expand Up @@ -100,31 +99,20 @@ impl hir::Pat<'_> {
}
}

/// Returns variants that are necessary to exist for the pattern to match.
pub fn necessary_variants(&self) -> Vec<DefId> {
let mut variants = vec![];
/// Call 'f' on every variant which is necessary for the pattern to match
pub fn each_necessary_variant(&self, mut f: impl FnMut(&QPath<'_>, HirId)) {
self.walk(|p| match &p.kind {
PatKind::Or(_) => false,
PatKind::Expr(hir::PatExpr {
kind: hir::PatExprKind::Path(hir::QPath::Resolved(_, path)),
..
})
| PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..)
| PatKind::Struct(hir::QPath::Resolved(_, path), ..) => {
if let Res::Def(DefKind::Variant | DefKind::Ctor(CtorOf::Variant, ..), id) =
path.res
{
variants.push(id);
}
PatKind::Expr(hir::PatExpr { hir_id, kind: hir::PatExprKind::Path(qpath), .. }) => {
f(qpath, *hir_id);
true
}
PatKind::TupleStruct(qpath, ..) | PatKind::Struct(qpath, ..) => {
f(qpath, p.hir_id);
true
}
_ => true,
});
// We remove duplicates by inserting into a hash set to avoid re-ordering
// the bounds
let mut duplicates = DefIdSet::default();
variants.retain(|def_id| duplicates.insert(*def_id));
variants
}

/// Checks if the pattern contains any `ref` or `ref mut` bindings, and if
Expand Down
Loading
Loading