Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2b8209a
Use verbose suggestion for type literal with wrong syntax
estebank Sep 20, 2026
c6bab65
Use verbose suggestion for method written as function
estebank Sep 20, 2026
2ed25fb
Tweak wording for unit struct literal suggestion
estebank Sep 20, 2026
2f09134
When pointing at variant definition in E0559, display enum def line too
estebank Sep 20, 2026
ba8670c
Display enum def line in E0532
estebank Sep 20, 2026
c6dcec1
Add regression coverage for multiple comma-separated patterns
chenyukang Sep 24, 2026
06b6926
Fix multiple pattern comma suggestions in diagnostics
chenyukang Sep 24, 2026
83bdaf9
Don't lint unused_qualifications when the unqualified path is ambiguous
chenyukang Sep 25, 2026
5b3e42a
Make the suggestion message of `unused_must_use` scarier.
kpreid Sep 15, 2026
d7cc26c
Improve unused_mut spans to avoid overlap
lsunsi Nov 1, 2026
576e161
Bless test changes for update
lsunsi Nov 1, 2026
863ff55
Forward `AbiAlign` `Debug` impl to `Align`
beetrees Nov 1, 2026
f6035a2
Remove unused `//@ normalize-stderr` for preferred alignment
beetrees Nov 1, 2026
9df62c0
unstable.rs: add missing `]` in description of `cfg_ub_checks`
DanielEScherzer Nov 1, 2026
5dd864e
Recover inner attributes in algebraic data types
JonathanBrouwer Nov 1, 2026
e84b595
Clarify AGENTS.md around pushing to a fork
Manishearth Nov 2, 2026
27a11b4
Rollup merge of #162018 - JonathanBrouwer:attr_empty_struct, r=fmease
jhpratt Nov 2, 2026
48fd217
Rollup merge of #162819 - kpreid:must-use-advice, r=fmease
jhpratt Nov 2, 2026
fb6bf5a
Rollup merge of #163053 - estebank:wrong-struct-literal, r=fmease
jhpratt Nov 2, 2026
bcb9583
Rollup merge of #163245 - chenyukang:yukang-fix-multiple-pattern-comm…
jhpratt Nov 2, 2026
540303a
Rollup merge of #163369 - chenyukang:yukang-fix-163310-unused-qualifi…
jhpratt Nov 2, 2026
55330de
Rollup merge of #165282 - lsunsi:issue165269, r=chenyukang
jhpratt Nov 2, 2026
ccf7855
Rollup merge of #165285 - beetrees:abi-align-debug, r=workingjubilee
jhpratt Nov 2, 2026
3726021
Rollup merge of #165294 - DanielEScherzer:unstable-cfg_ub_checks-desc…
jhpratt Nov 2, 2026
ab3fd54
Rollup merge of #165310 - Manishearth:Manishearth-patch-1, r=jieyouxu
jhpratt Nov 2, 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
7 changes: 7 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ made under this exemption, STOP and follow the gate-failure protocol.
Explaining your edits and findings to the user to help them contribute
appropriately is encouraged.

Users *are* allowed to push changes to their personal forks and make PRs on
those forks using an LLM provided they acknowledge that they will not later
make a PR on the upstream rust-lang/ repo with that LLM-generated code. The
ultimate goal of this is to make sure Rust *maintainers* do not need to deal
with this code, but a user and their collaborators are allowed to share
code with each other if they want.

[allowed use]: https://forge.rust-lang.org/policies/llm-usage.html#-allowed

### Before any edit
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,12 +1225,18 @@ impl Align {
///
/// An example of a rare thing actually affected by preferred alignment is aligning of statics.
/// It is of effectively no consequence for layout in structs and on the stack.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "nightly", derive(StableHash))]
pub struct AbiAlign {
pub abi: Align,
}

impl fmt::Debug for AbiAlign {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.abi, f)
}
}

impl AbiAlign {
#[inline]
pub fn new(align: Align) -> AbiAlign {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2756,6 +2756,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
}

let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
let span = span.trim_start(mut_span).unwrap_or(span);

tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ declare_features! (
(unstable, cfg_target_object_format, "1.97.0", Some(152586)),
/// Allows `cfg(target_thread_local)`.
(unstable, cfg_target_thread_local, "1.7.0", Some(29594)),
/// Allows the use of `#[cfg(ub_checks)` to check if UB checks are enabled.
/// Allows the use of `#[cfg(ub_checks)]` to check if UB checks are enabled.
(unstable, cfg_ub_checks, "1.79.0", Some(123499)),
/// Allow conditional compilation depending on rust version
(unstable, cfg_version, "1.45.0", Some(64796)),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2621,6 +2621,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match variant.ctor {
Some((CtorKind::Fn, def_id)) => match ty.kind() {
ty::Adt(adt, ..) if adt.is_enum() => {
err.span_context(self.tcx.def_span(adt.did()).shrink_to_lo());
err.span_label(
variant_ident_span,
format!(
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_lint/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2612,7 +2612,7 @@ pub(crate) struct UnusedOp<'a> {
#[derive(Subdiagnostic)]
pub(crate) enum UnusedOpSuggestion {
#[suggestion(
"use `let _ = ...` to ignore the resulting value",
"if you wish to disregard this recommendation, use `let _ = ...` to ignore the value",
style = "verbose",
code = "let _ = ",
applicability = "maybe-incorrect"
Expand All @@ -2622,7 +2622,7 @@ pub(crate) enum UnusedOpSuggestion {
span: Span,
},
#[multipart_suggestion(
"use `let _ = ...` to ignore the resulting value",
"if you wish to disregard this recommendation, use `let _ = ...` to ignore the value",
style = "verbose",
applicability = "maybe-incorrect"
)]
Expand Down Expand Up @@ -2686,7 +2686,7 @@ pub(crate) struct UnusedDef<'a, 'b> {
#[derive(Subdiagnostic)]
pub(crate) enum UnusedDefSuggestion {
#[suggestion(
"use `let _ = ...` to ignore the resulting value",
"if you wish to disregard this recommendation, use `let _ = ...` to ignore the value",
style = "verbose",
code = "let _ = ",
applicability = "maybe-incorrect"
Expand All @@ -2696,7 +2696,7 @@ pub(crate) enum UnusedDefSuggestion {
span: Span,
},
#[multipart_suggestion(
"use `let _ = ...` to ignore the resulting value",
"if you wish to disregard this recommendation, use `let _ = ...` to ignore the value",
style = "verbose",
applicability = "maybe-incorrect"
)]
Expand All @@ -2707,7 +2707,7 @@ pub(crate) enum UnusedDefSuggestion {
after_span: Span,
},
#[suggestion(
"use `let _unused = ...` to ignore the resulting value without dropping it immediately",
"if you wish to disregard this recommendation, use `let _unused = ...` to ignore the resulting value without dropping it immediately",
style = "verbose",
code = "let _unused = ",
applicability = "maybe-incorrect"
Expand All @@ -2717,7 +2717,7 @@ pub(crate) enum UnusedDefSuggestion {
span: Span,
},
#[multipart_suggestion(
"use `let _unused = ...` to ignore the resulting value without dropping it immediately",
"if you wish to disregard this recommendation, use `let _unused = ...` to ignore the resulting value without dropping it immediately",
style = "verbose",
applicability = "maybe-incorrect"
)]
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_parse/src/parser/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,4 +550,18 @@ impl<'a> Parser<'a> {

Ok(())
}

/// Parse inner attributes and error if they are present
/// Returns whether any inner attributes were discarded
pub fn recover_inner_attributes(&mut self) -> PResult<'a, bool> {
let attributes = self.parse_inner_attributes()?;
for attr in &attributes {
self.error_on_forbidden_inner_attr(
attr.span,
InnerAttrPolicy::Forbidden(Some(InnerAttrForbiddenReason::InCodeBlock)),
true,
);
}
Ok(!attributes.is_empty())
}
}
11 changes: 6 additions & 5 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2749,8 +2749,9 @@ impl<'a> Parser<'a> {
// parentheses in what should have been a tuple pattern; return a
// suggestion-enhanced error here rather than choking on the comma later.
let comma_span = self.token.span;
let mut comma_spans = vec![comma_span];
self.bump();
if let Err(err) = self.skip_pat_list() {
if let Err(err) = self.skip_pat_list(&mut comma_spans) {
// We didn't expect this to work anyway; we just wanted to advance to the
// end of the comma-sequence so we know the span to suggest parenthesizing.
err.cancel();
Expand All @@ -2769,10 +2770,9 @@ impl<'a> Parser<'a> {
Applicability::MachineApplicable,
);
if let CommaRecoveryMode::EitherTupleOrPipe = rt {
err.span_suggestion_verbose(
comma_span,
err.multipart_suggestion(
"...or a vertical bar to match on alternatives",
" |",
comma_spans.into_iter().map(|span| (span, " |".to_string())).collect(),
Applicability::MachineApplicable,
);
}
Expand Down Expand Up @@ -2955,12 +2955,13 @@ impl<'a> Parser<'a> {

/// Parse and throw away a parenthesized comma separated
/// sequence of patterns until `)` is reached.
fn skip_pat_list(&mut self) -> PResult<'a, ()> {
fn skip_pat_list(&mut self, comma_spans: &mut Vec<Span>) -> PResult<'a, ()> {
while !self.check(exp!(CloseParen)) {
self.parse_pat_no_top_alt(None, None)?;
if !self.eat(exp!(Comma)) {
return Ok(());
}
comma_spans.push(self.prev_token.span);
}
Ok(())
}
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,9 @@ impl<'a> Parser<'a> {
(thin_vec![], Trailing::No)
} else {
self.parse_delim_comma_seq(exp!(OpenBrace), exp!(CloseBrace), |p| {
if p.recover_inner_attributes()? && p.check(exp![CloseBrace]) {
return Ok(None);
}
p.parse_enum_variant(ident.span)
})
.map_err(|mut err| {
Expand Down Expand Up @@ -2165,6 +2168,9 @@ impl<'a> Parser<'a> {
let mut recovered = Recovered::No;
if self.eat(exp!(OpenBrace)) {
while self.token != token::CloseBrace {
if self.recover_inner_attributes()? && self.check(exp![CloseBrace]) {
break;
}
match self.parse_field_def(adt_ty, ident_span) {
Ok(field) => {
fields.push(field);
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5892,6 +5892,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
let ns = if i + 1 == path.len() { ns } else { TypeNS };
let res = self.r.partial_res_map.get(&seg.id?)?.full_res()?;
let binding = self.resolve_ident_in_lexical_scope(seg.ident, ns, None, None)?;
// Do not suggest removing the qualification if the unqualified path would be
// ambiguous, e.g. when several glob imports bring the same name into scope.
if let LateDecl::Decl(binding) = binding
&& binding.descent_to_ambiguity().is_some()
{
return None;
}
(res == binding.res()).then_some((seg, binding))
});

Expand Down
23 changes: 18 additions & 5 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2556,6 +2556,9 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
PathSource::Expr(_) | PathSource::TupleStruct(..) | PathSource::Pat => {
let span = find_span(&source, err);
err.span_label(this.r.def_span(def_id), format!("`{path_str}` defined here"));
if this.r.tcx.def_kind(def_id) == DefKind::Variant {
err.span_context(this.r.def_span(this.r.tcx.parent(def_id)).shrink_to_lo());
}

let (tail, descr, applicability, old_fields) = match source {
PathSource::Pat => ("", "pattern", Applicability::MachineApplicable, None),
Expand Down Expand Up @@ -2850,32 +2853,42 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
(Res::Def(DefKind::Union | DefKind::Variant, def_id), _) if ns == ValueNS => {
bad_struct_syntax_suggestion(self, err, def_id);
}
(Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id), _) if ns == ValueNS => {
(Res::Def(DefKind::Ctor(of, CtorKind::Const), def_id), _) if ns == ValueNS => {
match source {
PathSource::Expr(_) | PathSource::TupleStruct(..) | PathSource::Pat => {
let span = find_span(&source, err);
err.span_label(
self.r.def_span(def_id),
format!("`{path_str}` defined here"),
);
err.span_suggestion(
if of == CtorOf::Variant {
err.span_context(
self.r
.def_span(self.r.tcx.parent(self.r.tcx.parent(def_id)))
.shrink_to_lo(),
);
}
err.span_suggestion_verbose(
span,
"use this syntax instead",
"use the unit struct syntax instead",
path_str,
Applicability::MaybeIncorrect,
);
}
_ => return false,
}
}
(Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_def_id), _) if ns == ValueNS => {
(Res::Def(DefKind::Ctor(of, CtorKind::Fn), ctor_def_id), _) if ns == ValueNS => {
let def_id = self.r.tcx.parent(ctor_def_id);
err.span_label(self.r.def_span(def_id), format!("`{path_str}` defined here"));
if of == CtorOf::Variant {
err.span_context(self.r.def_span(self.r.tcx.parent(def_id)).shrink_to_lo());
}
let fields = self.r.field_idents(def_id).map_or_else(
|| "/* fields */".to_string(),
|field_ids| vec!["_"; field_ids.len()].join(", "),
);
err.span_suggestion(
err.span_suggestion_verbose(
span,
"use the tuple variant pattern syntax instead",
format!("{path_str}({fields})"),
Expand Down
8 changes: 2 additions & 6 deletions tests/ui/abi/c-zst.aarch64-darwin.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand All @@ -34,9 +32,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand Down
8 changes: 2 additions & 6 deletions tests/ui/abi/c-zst.powerpc-linux.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand All @@ -34,9 +32,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/abi/c-zst.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ add-minicore
//@ normalize-stderr: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
//@ normalize-stderr: "(align|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
/*!
C doesn't have zero-sized types... except it does.

Expand Down
8 changes: 2 additions & 6 deletions tests/ui/abi/c-zst.s390x-linux.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand All @@ -34,9 +32,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand Down
8 changes: 2 additions & 6 deletions tests/ui/abi/c-zst.sparc-linux.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand Down Expand Up @@ -45,9 +43,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand Down
8 changes: 2 additions & 6 deletions tests/ui/abi/c-zst.sparc-none.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand Down Expand Up @@ -45,9 +43,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
align: $SOME_ALIGN,
backend_repr: Memory {
sized: true,
},
Expand Down
Loading
Loading