Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
dea80f7
Normalize .. and . in diagnostic file paths
arferreira Apr 20, 2026
0da8bd3
Print unnormalized diagnostic paths under --verbose
arferreira Aug 13, 2026
0768398
Fix async `#[track_caller]` feature gate tests
theemathas Aug 29, 2026
88fb17e
Add a test revision to panic-track-caller.rs
theemathas Aug 29, 2026
95ded56
In panic-track-caller.rs, split call and await into different lines.
theemathas Aug 29, 2026
40b84d3
Add manual polling test to panic-track-caller.rs
theemathas Aug 29, 2026
785e709
Also test async track_caller in miri
theemathas Aug 29, 2026
e9bdbfd
Exclude gcc from panic-track-caller test
theemathas Aug 29, 2026
d00696d
Add run-native to async-panic-track-caller.rs
theemathas Aug 30, 2026
1c44402
Preliminary cleanup in coverage codegen
Zalathar Aug 31, 2026
be8a828
Resolve spans to file-coordinates in a separate step
Zalathar Aug 29, 2026
16b206a
suggest calling a fn item used as the iterator of a `for` loop
Albab-Hasan Aug 23, 2026
a97dc31
suggest calling a function item that is being dereferenced
Albab-Hasan Sep 1, 2026
cb5e3df
std: don't reference `libc::O_NOFOLLOW` on VxWorks in `set_perm_nofol…
physwkim Sep 1, 2026
9ed2e0c
reformat itanium mangling test to be more readable
folkertdev Sep 1, 2026
7a44484
fuchsia: Add safestack as a supported sanitizer for x86_64 fuchsia
PiJoules Jul 24, 2026
1d08a6b
Prefer `LLVMGetVersion` for runtime info
cuviper Sep 1, 2026
45b97ea
itanium mangling: use minicore
folkertdev Sep 1, 2026
bb0bcf2
add itanium mangling test for `f16` and `f128`
folkertdev Sep 1, 2026
47fc75d
Revert "retrieve supported GCC targets from the sysroot"
folkertdev Sep 1, 2026
b0ba8b1
Introduce `PerOwnerLoweringState`
nnethercote Sep 1, 2026
1bd13e5
fix itanium mangling of `f128` on powerpc
folkertdev Sep 1, 2026
fa8bb67
ineffective_unstable_trait_impl: add tests for `fn(!)` & `fn(UnstableT)`
GrigorenkoPV Sep 1, 2026
3cc3682
Don't special-case `!` in stability checks
GrigorenkoPV Sep 1, 2026
52bd189
fix ICE in project_goals/inherent
khyperia Sep 2, 2026
fa646a1
volatile: allow accesses to trap
RalfJung Aug 5, 2026
67bf3eb
Explain LoongArch f16 NaN-boxing in inline asm
heiher Aug 13, 2026
7ee0fba
Render the `box` pattern removal diagnostic more actionable
fmease Sep 2, 2026
c81640d
Remove parse recovery for `box` expressions
fmease Aug 30, 2026
7a71a74
Add warnings to `can_begin_*` methods that affect stable macro matchi…
fmease Sep 2, 2026
64d9ac5
Rollup merge of #155569 - arferreira:normalize-diagnostic-paths, r=es…
Zalathar Sep 2, 2026
d71f054
Rollup merge of #160564 - RalfJung:volatile-with-trap, r=nikic
Zalathar Sep 2, 2026
75cd7bc
Rollup merge of #161579 - Albab-Hasan:suggest-calling-fn-item-in-for-…
Zalathar Sep 2, 2026
84c38d6
Rollup merge of #162044 - Zalathar:resolved, r=folkertdev
Zalathar Sep 2, 2026
f4fdd2d
Rollup merge of #162120 - nnethercote:PerOwnerLoweringState, r=spasto…
Zalathar Sep 2, 2026
36fa177
Rollup merge of #162151 - folkertdev:ppc-itanium, r=tgross35
Zalathar Sep 2, 2026
dd7c463
Rollup merge of #162162 - GrigorenkoPV:never-is-now, r=mejrs,WaffleLa…
Zalathar Sep 2, 2026
4240a5b
Rollup merge of #159873 - PiJoules:fuchsia-safestack, r=adwinwhite
Zalathar Sep 2, 2026
279bf32
Rollup merge of #161972 - theemathas:async-track_caller-tests, r=Shoy…
Zalathar Sep 2, 2026
4104ef3
Rollup merge of #162008 - fmease:actionable-box-pat-diag, r=fee1-dead
Zalathar Sep 2, 2026
9266a38
Rollup merge of #162065 - physwkim:vxworks-set-perm-nofollow, r=Chris…
Zalathar Sep 2, 2026
684bed5
Rollup merge of #162152 - folkertdev:revert-skip-gcc-tests, r=jieyouxu
Zalathar Sep 2, 2026
886f715
Rollup merge of #162153 - cuviper:llvm-get-version, r=wesleywiser
Zalathar Sep 2, 2026
8a0ca60
Rollup merge of #162168 - khyperia:ice-inherent-next, r=BoxyUwU
Zalathar Sep 2, 2026
ba1da9b
Rollup merge of #162171 - heiher:loong-f16-nan-box, r=folkertdev
Zalathar Sep 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
25 changes: 20 additions & 5 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,13 @@ impl LitKind {
}

pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
// WARNING: Take care when modifying this function! It will change the stable(!) set of
// tokens that are allowed to match an `expr` nonterminal which is user observable.

let ident_token = Token::new(Ident(name, is_raw), span);

// FIXME: Remove `box` from this list given we officially no longer support box expressions
// (#108471) (needs lang FCP as it affects stable macro matching behavior).
!ident_token.is_reserved_ident()
|| ident_token.is_path_segment_keyword()
|| [
Expand Down Expand Up @@ -340,6 +345,9 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: IdentIsRaw) -> boo
}

fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
// WARNING: Take care when modifying this function! It will change the stable(!) set of
// tokens that are allowed to match an `ty` nonterminal which is user observable.

let ident_token = Token::new(Ident(name, is_raw), span);

!ident_token.is_reserved_ident()
Expand Down Expand Up @@ -661,10 +669,10 @@ impl Token {
}

/// Returns `true` if the token can appear at the start of an expression.
///
/// **NB**: Take care when modifying this function, since it will change
/// the stable set of tokens that are allowed to match an expr nonterminal.
pub fn can_begin_expr(&self) -> bool {
// WARNING: Take care when modifying this function! It will change the stable(!) set of
// tokens that are allowed to match an `expr` nonterminal which is user observable.

match self.uninterpolate().kind {
Ident(name, is_raw) =>
ident_can_begin_expr(name, self.span, is_raw), // value name or keyword
Expand Down Expand Up @@ -695,9 +703,10 @@ impl Token {
}

/// Returns `true` if the token can appear at the start of a pattern.
///
/// Shamelessly borrowed from `can_begin_expr`.
pub fn can_begin_pattern(&self, pat_kind: NtPatKind) -> bool {
// WARNING: Take care when modifying this function! It will change the stable(!) set of
// tokens that are allowed to match an `pat` nonterminal which is user observable.

match &self.uninterpolate().kind {
// box, ref, mut, and other identifiers (can stricten)
Ident(..) | NtIdent(..) |
Expand Down Expand Up @@ -727,6 +736,12 @@ impl Token {

/// Returns `true` if the token can appear at the start of a type.
pub fn can_begin_type(&self) -> bool {
// WARNING: Take care when modifying this function! It will change the stable(!) set of
// tokens that are allowed to match an `ty` nonterminal which is user observable.

// FIXME: Arguably, `use` should be included in this list since it can begin bare trait
// object types (consider `use<>+` and `use<T> + Trait` for example).

match self.uninterpolate().kind {
Ident(name, is_raw) =>
ident_can_begin_type(name, self.span, is_raw), // type name or keyword
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_lowering/src/delegation/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
let &DelegationResolution { span, sig_id, .. } = resolution;

const PARENT_ID: hir::ItemLocalId = hir::ItemLocalId::ZERO;
let new_attrs = self.create_new_attrs(span, sig_id, self.attrs.get(&PARENT_ID));
let new_attrs = self.create_new_attrs(span, sig_id, self.curr_owner.attrs.get(&PARENT_ID));

if !new_attrs.is_empty() {
let new_attrs = match self.attrs.get(&PARENT_ID) {
let new_attrs = match self.curr_owner.attrs.get(&PARENT_ID) {
Some(existing_attrs) => self.arena.alloc_from_iter(
existing_attrs.iter().map(|a| a.clone()).chain(new_attrs.into_iter()),
),
None => self.arena.alloc_from_iter(new_attrs.into_iter()),
};

self.attrs.insert(PARENT_ID, new_attrs);
self.curr_owner.attrs.insert(PARENT_ID, new_attrs);
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/delegation/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
};

// Important: we don't use `self.next_id()` as we want to execute
// `lower_node_id` routine so param's id is added to `self.children`.
// `lower_node_id` routine so param's id is added to `self.curr_owner.children`.
let hir_id = self.lower_node_id(node_id);

Some(hir::GenericParam {
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_ast_lowering/src/delegation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
let id = match source {
DelegationSource::Single => None,
DelegationSource::List(expn_id) => Some(expn_id),
DelegationSource::Glob => {
Some(self.tcx.expn_that_defined(self.owner.def_id).expect_local())
}
DelegationSource::Glob => Some(
self.tcx
.expn_that_defined(self.curr_owner.owner.def_id)
.expect_local(),
),
};

id.map(|id| (id, unused_target_expr))
Expand Down Expand Up @@ -335,7 +337,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let overwrites = self_resolver.overwrites;

// Target expr needs to lower `self` path.
self.ident_and_label_to_local_id.insert(pat_node_id, param_local_id);
self.curr_owner.ident_and_label_to_local_id.insert(pat_node_id, param_local_id);

let block = cfg_select! {
debug_assertions => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/delegation/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(super) mod resolver {

#[inline]
pub(crate) fn owner_id(&self) -> LocalDefId {
self.0.owner.def_id
self.0.curr_owner.owner.def_id
}

/// (from `tests\ui\delegation\target-expr-removal-defs-inside.rs`):
Expand All @@ -91,7 +91,7 @@ pub(super) mod resolver {
#[inline]
pub(crate) fn is_definition(&self, id: NodeId) -> bool {
self.0.resolver.owners.contains_key(&id)
|| self.0.owner.node_id_to_def_id.contains_key(&id)
|| self.0.curr_owner.owner.node_id_to_def_id.contains_key(&id)
}

#[inline]
Expand Down
17 changes: 9 additions & 8 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
// Merge attributes into the inner expression.
if !e.attrs.is_empty() {
let old_attrs = self.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
let old_attrs =
self.curr_owner.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
let new_attrs = self
.lower_attrs_vec(&e.attrs, e.span, ex.hir_id, Target::from_expr(e))
.into_iter()
Expand All @@ -181,7 +182,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
if new_attrs.is_empty() {
return ex;
}
self.attrs.insert(ex.hir_id.local_id, new_attrs);
self.curr_owner.attrs.insert(ex.hir_id.local_id, new_attrs);
}
return ex;
}
Expand Down Expand Up @@ -884,15 +885,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
/// `inner_hir_id` in case the `async_fn_track_caller` feature is enabled.
pub(super) fn maybe_forward_track_caller(&mut self, outer_hir_id: HirId, inner_hir_id: HirId) {
if self.tcx.features().async_fn_track_caller()
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
&& let Some(attrs) = self.curr_owner.attrs.get(&outer_hir_id.local_id)
&& let Some(t) = attrs.iter().find(|a| {
matches!(
a,
rustc_attr_ir::Attribute::Parsed(rustc_attr_ir::AttributeKind::TrackCaller(_))
)
})
{
self.attrs.insert(inner_hir_id.local_id, std::slice::from_ref(t));
self.curr_owner.attrs.insert(inner_hir_id.local_id, std::slice::from_ref(t));
}
}

Expand Down Expand Up @@ -1505,16 +1506,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
dest_hir_id: hir::HirId,
) -> Option<Label> {
let label = opt_label?;
self.ident_and_label_to_local_id.insert(dest_id, dest_hir_id.local_id);
self.curr_owner.ident_and_label_to_local_id.insert(dest_id, dest_hir_id.local_id);
Some(Label { ident: self.lower_ident(label.ident) })
}

fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hir::Destination {
let target_id = match destination {
Some((id, _)) => {
if let Some(loop_id) = self.owner.get_label_res(id) {
let local_id = self.ident_and_label_to_local_id[&loop_id];
let loop_hir_id = HirId { owner: self.current_hir_id_owner, local_id };
if let Some(loop_id) = self.curr_owner.owner.get_label_res(id) {
let local_id = self.curr_owner.ident_and_label_to_local_id[&loop_id];
let loop_hir_id = HirId { owner: self.curr_owner.owner_id, local_id };
Ok(loop_hir_id)
} else {
Err(hir::LoopIdError::UnresolvedLabel)
Expand Down
42 changes: 20 additions & 22 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@ impl<'hir> ItemLowerer<'_, 'hir> {
let mut lctx = LoweringContext::new(self.tcx, self.resolver, owner);

let item = f(&mut lctx);
debug_assert_eq!(lctx.current_hir_id_owner, item.def_id());

let info = lctx.make_owner_info(item);

let info = lctx.curr_owner.into_owner_info(self.tcx, item);
hir::MaybeOwner::Owner(lctx.arena.alloc(info))
}

#[instrument(level = "debug", skip(self, c))]
pub(super) fn lower_crate(&mut self, c: &Crate) -> hir::MaybeOwner<'hir> {
self.with_lctx(CRATE_NODE_ID, |lctx| {
debug_assert_eq!(lctx.current_hir_id_owner, CRATE_OWNER_ID);
debug_assert_eq!(lctx.curr_owner.owner_id, CRATE_OWNER_ID);
let module = lctx.lower_mod(&c.items, &c.spans);
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, c.spans.inner_span, Target::Crate);
hir::OwnerNode::Crate(module)
Expand Down Expand Up @@ -206,7 +204,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_item(&mut self, i: &Item) -> &'hir hir::Item<'hir> {
let owner_id = self.current_hir_id_owner;
let owner_id = self.curr_owner.owner_id;
let hir_id: HirId = owner_id.into();
let vis_span = self.lower_span(i.vis.span);

Expand Down Expand Up @@ -399,7 +397,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ty,
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias {
parent: this.owner.def_id,
parent: this.curr_owner.owner.def_id,
in_assoc_ty: false,
},
},
Expand Down Expand Up @@ -547,7 +545,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ItemKind::MacroDef(ident, MacroDef { body, macro_rules, eii_declaration: _ }) => {
let ident = self.lower_ident(*ident);
let body = Box::new(self.lower_delim_args(body));
let def_id = self.owner.def_id;
let def_id = self.curr_owner.owner.def_id;
let def_kind = self.tcx.def_kind(def_id);
let DefKind::Macro(macro_kinds) = def_kind else {
unreachable!(
Expand Down Expand Up @@ -695,7 +693,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `ItemLocalId` and the new owner. (See `lower_node_id`)
let kind = this.lower_use_tree(use_tree, &prefix, id, vis_span, attrs);
if !attrs.is_empty() {
this.attrs.insert(hir::ItemLocalId::ZERO, attrs);
this.curr_owner.attrs.insert(hir::ItemLocalId::ZERO, attrs);
}

let item = hir::Item {
Expand Down Expand Up @@ -731,7 +729,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_foreign_item(&mut self, i: &ForeignItem) -> &'hir hir::ForeignItem<'hir> {
let owner_id = self.current_hir_id_owner;
let owner_id = self.curr_owner.owner_id;
let hir_id: HirId = owner_id.into();
let attrs =
self.lower_attrs(hir_id, &i.attrs, i.span, Target::from_foreign_item_kind(&i.kind));
Expand Down Expand Up @@ -914,7 +912,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_trait_item(&mut self, i: &AssocItem) -> &'hir hir::TraitItem<'hir> {
let trait_item_def_id = self.current_hir_id_owner;
let trait_item_def_id = self.curr_owner.owner_id;
let hir_id: HirId = trait_item_def_id.into();
let attrs = self.lower_attrs(
hir_id,
Expand Down Expand Up @@ -1169,7 +1167,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_impl_item(&mut self, i: &AssocItem) -> &'hir hir::ImplItem<'hir> {
let owner_id = self.current_hir_id_owner;
let owner_id = self.curr_owner.owner_id;
let hir_id: HirId = owner_id.into();
let parent_id = self.tcx.local_parent(owner_id.def_id);
let is_in_trait_impl =
Expand Down Expand Up @@ -1258,7 +1256,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ty,
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias {
parent: this.owner.def_id,
parent: this.curr_owner.owner.def_id,
in_assoc_ty: true,
},
},
Expand Down Expand Up @@ -1336,8 +1334,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
) -> hir::BodyId {
let body = hir::Body { params, value: self.arena.alloc(value) };
let id = body.id();
assert_eq!(id.hir_id.owner, self.current_hir_id_owner);
self.bodies.push((id.hir_id.local_id, self.arena.alloc(body)));
assert_eq!(id.hir_id.owner, self.curr_owner.owner_id);
self.curr_owner.bodies.push((id.hir_id.local_id, self.arena.alloc(body)));
id
}

Expand Down Expand Up @@ -1545,7 +1543,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
//
// If this is the simple case, this parameter will end up being the same as the
// original parameter, but with a different pattern id.
let stmt_attrs = self.attrs.get(&parameter.hir_id.local_id).copied();
let stmt_attrs = self.curr_owner.attrs.get(&parameter.hir_id.local_id).copied();
let (new_parameter_pat, new_parameter_id) = self.pat_ident(desugared_span, ident);
let new_parameter = hir::Param {
hir_id: parameter.hir_id,
Expand Down Expand Up @@ -1883,8 +1881,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
itctx: ImplTraitContext,
f: impl FnOnce(&mut Self) -> T,
) -> (&'hir hir::Generics<'hir>, T) {
assert!(self.impl_trait_defs.is_empty());
assert!(self.impl_trait_bounds.is_empty());
assert!(self.curr_owner.impl_trait_defs.is_empty());
assert!(self.curr_owner.impl_trait_bounds.is_empty());

let mut predicates: SmallVec<[hir::WherePredicate<'hir>; 4]> = SmallVec::new();
// We need to make sure that generic params don't have multiple relaxed bounds for the same trait
Expand Down Expand Up @@ -1914,7 +1912,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.collect();

// Introduce extra lifetimes if late resolution tells us to.
let extra_lifetimes = self.owner.extra_lifetime_params(self.owner.id);
let extra_lifetimes = self.curr_owner.owner.extra_lifetime_params(self.curr_owner.owner.id);
params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, kind)| {
self.lifetime_res_to_generic_param(
ident,
Expand All @@ -1929,10 +1927,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
let span = self.lower_span(generics.span);
let res = f(self);

let impl_trait_defs = std::mem::take(&mut self.impl_trait_defs);
let impl_trait_defs = std::mem::take(&mut self.curr_owner.impl_trait_defs);
params.extend(impl_trait_defs.into_iter());

let impl_trait_bounds = std::mem::take(&mut self.impl_trait_bounds);
let impl_trait_bounds = std::mem::take(&mut self.curr_owner.impl_trait_bounds);
predicates.extend(impl_trait_bounds.into_iter());

let lowered_generics = self.arena.alloc(hir::Generics {
Expand All @@ -1951,7 +1949,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir_id: HirId,
define_opaque: &Option<ThinVec<(NodeId, Path)>>,
) {
assert_eq!(self.define_opaque, None);
assert_eq!(self.curr_owner.define_opaque, None);
assert!(hir_id.is_owner());
let Some(define_opaque) = define_opaque.as_ref() else {
return;
Expand All @@ -1972,7 +1970,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
Some((self.lower_span(path.span), did))
});
let define_opaque = self.arena.alloc_from_iter(define_opaque);
self.define_opaque = Some(define_opaque);
self.curr_owner.define_opaque = Some(define_opaque);
}

pub(super) fn lower_generic_bound_predicate(
Expand Down
Loading
Loading