Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
746c872
Add performance notes for the floating-point round method
joonas-001 Aug 25, 2026
c447e2e
open issues when scheduled linkcheck fails
jyn514 Aug 29, 2026
9565ced
Add regression test for importing block-scoped traits
chenyukang Sep 7, 2026
c9e2b67
Avoid suggesting imports of traits declared inside bodies
chenyukang Sep 7, 2026
c18476f
fix: typo in thir.md
000wahab000 Sep 8, 2026
40dc2a3
Merge pull request rust-lang/rustc-dev-guide#3005 from 000wahab000/fi…
reddevilmidzy Sep 9, 2026
7878498
address review comments
jyn514 Sep 10, 2026
b1c6599
Merge pull request #2993 from jyn514/track-broken-links
jyn514 Sep 10, 2026
4aee1dc
spelling
supercooltest2024 Sep 10, 2026
68ddb1e
Merge pull request #3011 from supercooltest2024/patch-1
BoxyUwU Sep 10, 2026
fe47365
Add the alternatives parts in `Cache::paths`
GuillaumeGomez Sep 11, 2026
3ddd7e4
adjust docs to latest offload usage
ZuseZ4 Sep 11, 2026
e5d963f
Merge pull request #3012 from rust-lang/offload-usage-update
ZuseZ4 Sep 11, 2026
10e1f7e
adjust docs to latest offload install
ZuseZ4 Sep 11, 2026
301f62f
Merge pull request #3013 from rust-lang/offload-install-update
ZuseZ4 Sep 11, 2026
1629bcd
Add useful APIs to `Unique(Arc|Rc)`
maxdexh Sep 13, 2026
7e37472
Prepare for merging from rust-lang/rust
invalid-email-address Sep 14, 2026
93c39bc
Merge ref '4b6d04e70610' from rust-lang/rust
invalid-email-address Sep 14, 2026
bfbf4b1
Merge pull request #3014 from rust-lang/rustc-pull
tshepang Sep 14, 2026
a74f1e7
fix generic offload usage
ZuseZ4 Sep 15, 2026
b88268a
Merge pull request #3015 from rust-lang/offload-usage-update2
ZuseZ4 Sep 15, 2026
a1864bd
Ping T-libs-ping instead of T-libs-fcp for backports
clarfonthey Sep 16, 2026
f68cc95
Fix formatting, and make wording consistent
Urhengulas Sep 16, 2026
ba736a0
Provide the "preferred name" when generating `href` and `title` for i…
GuillaumeGomez Sep 11, 2026
cd6287f
Add regression test for inlined same item with different names
GuillaumeGomez Sep 11, 2026
005aa45
Mini optimization in `restrict_precision_for_drop_types`
Jules-Bertholet Sep 17, 2026
085678a
Add address_space and byref to abi PassMode::Indirect
Flakebi Sep 1, 2026
fff83c5
Prepare for merging from rust-lang/rust
invalid-email-address Sep 17, 2026
359cb6c
Merge ref 'c999cef531ea' from rust-lang/rust
invalid-email-address Sep 17, 2026
093dd66
Merge pull request #3019 from rust-lang/rustc-pull
tshepang Sep 17, 2026
2cce379
Merge pull request #3018 from Urhengulas/patch-1
tshepang Sep 17, 2026
677806f
Remove applying inline attributes at the callsite
Jamesbarford Sep 17, 2026
6d00f27
Add a new `-Ztrack-diagnostics` test
nnethercote Sep 18, 2026
0e617d4
Adjust `bug!`/`span_bug!` emission
nnethercote Sep 16, 2026
bf91751
Pre-commit amdgpu gpu-kernel ABI test
Flakebi Sep 3, 2026
c498254
Properly implement the gpu-kernel ABI for amdgpu
Flakebi Sep 15, 2026
653076c
yeet AliasConstKind::opt_def_id
khyperia Sep 18, 2026
44d6e57
sembr src/offload/installation.md
tshepang Sep 18, 2026
ae341a2
sembr src/test-implementation.md
tshepang Sep 18, 2026
9327b11
redundant
tshepang Sep 18, 2026
8a9db74
whitespace
tshepang Sep 18, 2026
ec49841
reflow
tshepang Sep 18, 2026
9e7d4b2
Don't double-allocate `OwnerInfo`
nnethercote Sep 1, 2026
9a03326
Convert some `&mut self` to `&self` in the lowerer
nnethercote Sep 1, 2026
990c292
Reduce the scope of a local
nnethercote Sep 1, 2026
9b817c5
Rename `LoweringContext::current_item`
nnethercote Sep 1, 2026
3ee39bd
Fix an inconsistent comment
nnethercote Sep 1, 2026
6e7d014
Inline and remove `lower_delim_args`
nnethercote Sep 1, 2026
f1b023a
sembr src/solve/sharing-crates-with-rust-analyzer.md
tshepang Sep 18, 2026
11b373e
Eliminate `ItemLowerer`
nnethercote Sep 1, 2026
d3f8246
whitespace
tshepang Sep 18, 2026
1b9a608
sembr src/tests/ecosystem.md
tshepang Sep 18, 2026
a3afbd8
use spawned `SBDebugger` instance
Walnut356 Sep 18, 2026
cff4b1a
reduce indentation
tshepang Sep 18, 2026
6f51268
split some more lines on commas
tshepang Sep 18, 2026
0999e10
generic
tshepang Sep 18, 2026
bf9557a
sembr src/tests/intro.md
tshepang Sep 18, 2026
5539256
respect indents
tshepang Sep 18, 2026
6e5231a
sembr src/tests/compiletest.md
tshepang Sep 18, 2026
55ec44e
missing pause
tshepang Sep 18, 2026
65ee597
sembr src/tests/ecosystem-test-jobs/rust-for-linux.md
tshepang Sep 18, 2026
6c549a9
sembr src/tests/ecosystem-test-jobs/fuchsia.md
tshepang Sep 18, 2026
9f09251
improve tests/ecosystem-test-jobs/fuchsia.md
tshepang Sep 18, 2026
04357ed
sembr src/closure.md
tshepang Sep 18, 2026
b0f83b7
Update `browser-ui-test` version to `0.25.2`
GuillaumeGomez Sep 18, 2026
14e479d
improve closure.md
tshepang Sep 18, 2026
d6c1c9c
Merge pull request #3020 from rust-lang/tshepang/misc
tshepang Sep 18, 2026
f8f15cf
fix whitespace
tshepang Sep 18, 2026
d142688
Merge pull request #3021 from rust-lang/tshepang-patch-1
tshepang Sep 18, 2026
c60430f
Add missing `#[repr(C)]` in UI, codegen and assembly tests
beetrees Sep 18, 2026
e7d3a6a
Move parse error recovery from some invalid expr ops out of line
fmease Sep 10, 2026
b945d68
Don't needlessly pass the operand through some recovery functions by …
fmease Sep 10, 2026
ceede0b
Remove odd special case of some parse error recovery functions
fmease Sep 6, 2026
6c0ab88
Dismantle bespoke diagnostic suggestion wrapper API
fmease Sep 6, 2026
ddb9380
Move parse error recovery from C-style inc/dec ops out of line
fmease Sep 10, 2026
1adccf2
Inline fns & data types related to parse error recovery from C-style …
fmease Sep 10, 2026
d85d3f5
Refactor the way we finish parsing expr ops
fmease Sep 10, 2026
f0ae097
Refactor `check_assoc_op` to make it more legible
fmease Aug 25, 2026
2815872
Don't mistake `<->` for `<>`
fmease Sep 11, 2026
c99166f
Revert "improve tests/ecosystem-test-jobs/fuchsia.md"
tshepang Sep 18, 2026
2e95aa2
Revert "sembr src/tests/ecosystem-test-jobs/fuchsia.md"
tshepang Sep 18, 2026
68b9e16
Merge pull request #3022 from rust-lang/tshepang/reverts
tshepang Sep 18, 2026
cec9479
Prepare for merging from rust-lang/rust
invalid-email-address Sep 18, 2026
c684a2f
Merge ref '420ed2a0c3d7' from rust-lang/rust
invalid-email-address Sep 18, 2026
079eba0
Merge pull request #3023 from rust-lang/rustc-pull
tshepang Sep 18, 2026
6863838
improve closure.md
tshepang Sep 18, 2026
b8c15ce
sembr src/tests/ecosystem-test-jobs/fuchsia.md
tshepang Sep 18, 2026
d9d1b3e
improve tests/ecosystem-test-jobs/fuchsia.md
tshepang Sep 18, 2026
40060e4
Merge pull request #3024 from rust-lang/tshepang/misc
tshepang Sep 18, 2026
b7bad07
Add Natvis visualiser and debuginfo tests for `f128`
beetrees Aug 25, 2026
3d281d4
implement `VaArgSafe` for `f128`
folkertdev Sep 3, 2026
a3ad87e
mark `f128` as reliable on `powerpc` with `+vsx`
folkertdev Sep 18, 2026
b2c6d2d
Refactor LivenessResults into LivenessComputation, without typeck
jackh726 Aug 28, 2026
22bb11e
Rollup merge of #162880 - Jules-Bertholet:mini-upvar-refactor, r=nnet…
JonathanBrouwer Sep 19, 2026
626be09
Rollup merge of #161424 - folkertdev:va-arg-f128, r=tgross35
JonathanBrouwer Sep 19, 2026
f6ffecc
Rollup merge of #161777 - beetrees:f128-debuginfo, r=JohnTitor
JonathanBrouwer Sep 19, 2026
a554888
Rollup merge of #162177 - Flakebi:amdgpu-kernel-cc, r=bjorn3
JonathanBrouwer Sep 19, 2026
64abfe9
Rollup merge of #162506 - chenyukang:yukang-fix-134146-block-scoped-t…
JonathanBrouwer Sep 19, 2026
5559aa8
Rollup merge of #162591 - fmease:out-of-line-recovery, r=petrochenkov
JonathanBrouwer Sep 19, 2026
6b93ec0
Rollup merge of #162669 - GuillaumeGomez:inline-same-item-with-differ…
JonathanBrouwer Sep 19, 2026
15119a2
Rollup merge of #162733 - maxdexh:unique-arc-pub-apis, r=nia-e
JonathanBrouwer Sep 19, 2026
ab52a76
Rollup merge of #162913 - jackh726:trace-refactor, r=lqd
JonathanBrouwer Sep 19, 2026
e0dfcea
Rollup merge of #162924 - Jamesbarford:fix/remove-inline-attributes-a…
JonathanBrouwer Sep 19, 2026
13bfded
Rollup merge of #162940 - Walnut356:alt_exit, r=Kobzol
JonathanBrouwer Sep 19, 2026
985f6b1
Rollup merge of #162950 - nnethercote:more-lowering-cleanups, r=spast…
JonathanBrouwer Sep 19, 2026
d548996
Rollup merge of #162964 - GuillaumeGomez:update-browser-ui-test, r=ji…
JonathanBrouwer Sep 19, 2026
1e34b5f
Rollup merge of #162979 - folkertdev:ppc-enable-f128, r=beetrees
JonathanBrouwer Sep 19, 2026
3d93558
Rollup merge of #161743 - joonas-001:codex/round-ties-even-docs, r=Jo…
JonathanBrouwer Sep 19, 2026
a3653ff
Rollup merge of #162797 - khyperia:yeet-opt_def_id, r=BoxyUwU,bit-aloo
JonathanBrouwer Sep 19, 2026
b3ac812
Rollup merge of #162836 - clarfonthey:libs-ping, r=ChrisDenton
JonathanBrouwer Sep 19, 2026
35914fd
Rollup merge of #162873 - nnethercote:fix-emit_bug, r=mejrs
JonathanBrouwer Sep 19, 2026
55a43ad
Rollup merge of #162956 - beetrees:test-repr-c-struct, r=folkertdev
JonathanBrouwer Sep 19, 2026
65cb54e
Rollup merge of #162981 - tshepang:rdg-sync, r=tshepang
JonathanBrouwer Sep 19, 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
4 changes: 2 additions & 2 deletions compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
}

/// If this method returns `true`, then this type should always have a `PassMode` of
/// `Indirect { on_stack: false, .. }` when being used as the argument type of a function with a
/// non-Rustic ABI (this is true for structs annotated with the
/// `Indirect { mode: IndirectMode::Pointer, .. }` when being used as the argument type of a
/// function with a non-Rustic ABI (this is true for structs annotated with the
/// `#[rustc_pass_indirectly_in_non_rustic_abis]` attribute).
///
/// This is used to replicate some of the behaviour of C array-to-pointer decay; however unlike
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,10 @@ pub struct AddressSpace(pub u32);
impl AddressSpace {
/// LLVM's `0` address space.
pub const ZERO: Self = AddressSpace(0);
/// The address space for constant memory on nvptx and amdgpu.
/// This address space is used e.g. for kernel arguments that are constant throughout the
/// execution.
pub const GPU_CONSTANT: Self = AddressSpace(4);
/// The address space for workgroup memory on nvptx and amdgpu.
/// See e.g. the `gpu_launch_sized_workgroup_mem` intrinsic for details.
pub const GPU_WORKGROUP: Self = AddressSpace(3);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
expr.span,
hir::ExprKind::Err(self.dcx().emit_err(AwaitOnlyInAsyncFnAndBlocks {
await_kw_span,
item_span: self.current_item,
item_span: self.current_item_span,
})),
);
return hir::ExprKind::Block(
Expand Down Expand Up @@ -1712,7 +1712,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
Some(hir::CoroutineKind::Coroutine(_)) => false,
None => {
let suggestion = self.current_item.map(|s| s.shrink_to_lo());
let suggestion = self.current_item_span.map(|s| s.shrink_to_lo());
self.dcx().emit_err(YieldInClosure { span, suggestion });
self.coroutine_kind = Some(hir::CoroutineKind::Coroutine(Movability::Movable));

Expand Down
68 changes: 9 additions & 59 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ use rustc_errors::{E0570, ErrorGuaranteed, struct_span_code_err};
use rustc_hir::attrs::{AttributeKind, EiiImplResolution};
use rustc_hir::def::{DefKind, PerNS, Res};
use rustc_hir::{
self as hir, CRATE_OWNER_ID, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin, Target,
find_attr,
self as hir, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin, Target, find_attr,
};
use rustc_middle::middle::resolve::ResolverAstLowering;
use rustc_middle::ty::TyCtxt;
use rustc_middle::ty::data_structures::IndexMap;
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::edit_distance::find_best_match_for_name;
Expand All @@ -28,14 +25,9 @@ use super::{
};
use crate::diagnostics::{ConstComptimeFn, ResolvingRestrictionKind, RestrictionAncestorOnly};

pub(super) struct ItemLowerer<'a, 'hir> {
pub(super) tcx: TyCtxt<'hir>,
pub(super) resolver: &'a ResolverAstLowering<'hir>,
}

/// When we have a ty alias we *may* have two where clauses. To give the best diagnostics, we set the span
/// to the where clause that is preferred, if it exists. Otherwise, it sets the span to the other where
/// clause if it exists.
/// When we have a ty alias we *may* have two where clauses. To give the best diagnostics, we set
/// the span to the where clause that is preferred, if it exists. Otherwise, it sets the span to
/// the other where clause if it exists.
fn add_ty_alias_where_clause(
generics: &mut ast::Generics,
after_where_clause: &ast::WhereClause,
Expand All @@ -52,48 +44,6 @@ fn add_ty_alias_where_clause(
if before.0 || !after.0 { before } else { after };
}

impl<'hir> ItemLowerer<'_, 'hir> {
fn with_lctx(
&mut self,
owner: NodeId,
f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
) -> hir::MaybeOwner<'hir> {
let mut lctx = LoweringContext::new(self.tcx, self.resolver, owner);

let item = f(&mut lctx);

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.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)
})
}

#[instrument(level = "debug", skip(self))]
pub(super) fn lower_item(&mut self, item: &Item) -> hir::MaybeOwner<'hir> {
self.with_lctx(item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
}

pub(super) fn lower_trait_item(&mut self, item: &AssocItem) -> hir::MaybeOwner<'hir> {
self.with_lctx(item.id, |lctx| hir::OwnerNode::TraitItem(lctx.lower_trait_item(item)))
}

pub(super) fn lower_impl_item(&mut self, item: &AssocItem) -> hir::MaybeOwner<'hir> {
self.with_lctx(item.id, |lctx| hir::OwnerNode::ImplItem(lctx.lower_impl_item(item)))
}

pub(super) fn lower_foreign_item(&mut self, item: &ForeignItem) -> hir::MaybeOwner<'hir> {
self.with_lctx(item.id, |lctx| hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item)))
}
}

impl<'hir> LoweringContext<'_, 'hir> {
pub(super) fn lower_mod(
&mut self,
Expand Down Expand Up @@ -203,7 +153,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

fn lower_item(&mut self, i: &Item) -> &'hir hir::Item<'hir> {
pub(super) fn lower_item(&mut self, i: &Item) -> &'hir hir::Item<'hir> {
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 @@ -544,7 +494,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 body = body.clone();
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 {
Expand Down Expand Up @@ -730,7 +680,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

fn lower_foreign_item(&mut self, i: &ForeignItem) -> &'hir hir::ForeignItem<'hir> {
pub(super) fn lower_foreign_item(&mut self, i: &ForeignItem) -> &'hir hir::ForeignItem<'hir> {
let owner_id = self.curr_owner.owner_id();
let hir_id: HirId = owner_id.into();
let attrs =
Expand Down Expand Up @@ -911,7 +861,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

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

fn lower_impl_item(&mut self, i: &AssocItem) -> &'hir hir::ImplItem<'hir> {
pub(super) fn lower_impl_item(&mut self, i: &AssocItem) -> &'hir hir::ImplItem<'hir> {
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);
Expand Down
71 changes: 44 additions & 27 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
use rustc_hir::definitions::PerParentDisambiguatorState;
use rustc_hir::lints::DelayedLint;
use rustc_hir::{
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr,
self as hir, AngleBrackets, CRATE_OWNER_ID, ConstArg, GenericArg, HirId, ItemLocalMap,
LifetimeSource, LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate,
find_attr,
};
use rustc_index::{Idx, IndexSlice, IndexVec};
use rustc_macros::extension;
Expand Down Expand Up @@ -296,7 +297,7 @@ struct LoweringContext<'a, 'hir> {

/// Used to get the current `fn`'s def span to point to when using `await`
/// outside of an `async fn`.
current_item: Option<Span>,
current_item_span: Option<Span>,

try_block_scope: TryBlockScope,
loop_scope: Option<HirId>,
Expand Down Expand Up @@ -366,7 +367,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
is_in_dyn_type: false,
coroutine_kind: None,
task_context: None,
current_item: None,
current_item_span: None,

move_expr_bindings: Vec::new(),
lowering_move_expr_initializer: false,
Expand Down Expand Up @@ -783,15 +784,37 @@ fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
return fallback_to_ancestor(tcx.local_parent(def_id));
};

let mut item_lowerer = item::ItemLowerer { tcx, resolver: &*resolver };
fn with_lctx<'hir>(
tcx: TyCtxt<'hir>,
resolver: &ResolverAstLowering<'hir>,
owner: NodeId,
f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
) -> hir::MaybeOwner<'hir> {
let mut lctx = LoweringContext::new(tcx, resolver, owner);
let item = f(&mut lctx);
hir::MaybeOwner::Owner(lctx.curr_owner.into_owner_info(tcx, item))
}

let item = match &node {
// The item existed in the AST.
AstOwner::Crate(c) => item_lowerer.lower_crate(&c),
AstOwner::Item(item) => item_lowerer.lower_item(&item),
AstOwner::TraitItem(item) => item_lowerer.lower_trait_item(&item),
AstOwner::ImplItem(item) => item_lowerer.lower_impl_item(&item),
AstOwner::ForeignItem(item) => item_lowerer.lower_foreign_item(&item),
AstOwner::Crate(c) => with_lctx(tcx, &*resolver, CRATE_NODE_ID, |lctx| {
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)
}),
AstOwner::Item(item) => {
with_lctx(tcx, &*resolver, item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
}
AstOwner::TraitItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
hir::OwnerNode::TraitItem(lctx.lower_trait_item(item))
}),
AstOwner::ImplItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
hir::OwnerNode::ImplItem(lctx.lower_impl_item(item))
}),
AstOwner::ForeignItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item))
}),
AstOwner::NestedUseTree(owner_id) => fallback_to_ancestor(*owner_id),
// The item existed in the AST, but is not a HIR owner.
// Fetch the correct information from its parent.
Expand Down Expand Up @@ -824,7 +847,7 @@ enum GenericArgsMode {
ParenSugar,
/// Allow RTN, don't allow paren sugar.
ReturnTypeNotation,
// Error if parenthesized generics or RTN are encountered.
/// Error if parenthesized generics or RTN are encountered.
Err,
/// Silence errors when lowering generics. Only used with `Res::Err`.
Silence,
Expand Down Expand Up @@ -982,7 +1005,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

#[instrument(level = "trace", skip(self))]
fn lower_res(&mut self, res: Res<NodeId>) -> Res {
fn lower_res(&self, res: Res<NodeId>) -> Res {
let res: Result<Res, ()> = res.apply_id(|id| {
let owner = self.curr_owner.owner_id();
let local_id =
Expand All @@ -999,11 +1022,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
res.unwrap_or(Res::Err)
}

fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
fn expect_full_res(&self, id: NodeId) -> Res<NodeId> {
self.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res())
}

fn lower_import_res(&mut self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
fn lower_import_res(&self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
debug_assert_eq!(id, self.curr_owner.owner.id);
let per_ns = self.curr_owner.owner.import_res.map(|res| res.map(|res| self.lower_res(res)));
if per_ns.is_empty() {
Expand Down Expand Up @@ -1154,8 +1177,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn with_new_scopes<T>(&mut self, scope_span: Span, f: impl FnOnce(&mut Self) -> T) -> T {
let current_item = self.current_item;
self.current_item = Some(scope_span);
let current_item_span = self.current_item_span;
self.current_item_span = Some(scope_span);

let was_in_loop_condition = self.is_in_loop_condition;
self.is_in_loop_condition = false;
Expand All @@ -1172,7 +1195,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

self.is_in_loop_condition = was_in_loop_condition;

self.current_item = current_item;
self.current_item_span = current_item_span;

ret
}
Expand Down Expand Up @@ -1261,10 +1284,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

fn lower_delim_args(&self, args: &DelimArgs) -> DelimArgs {
args.clone()
}

/// Lower an associated item constraint.
#[instrument(level = "debug", skip_all)]
fn lower_assoc_item_constraint(
Expand Down Expand Up @@ -1647,8 +1666,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.lower_array_length_to_const_arg(length),
),
TyKind::TraitObject(bounds, kind) => {
let mut lifetime_bound = None;
let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
let mut lifetime_bound = None;
let bounds =
this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| match bound {
// We can safely ignore constness here since AST validation
Expand Down Expand Up @@ -1681,9 +1700,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
None
}
}));
let lifetime_bound =
lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span));
(bounds, lifetime_bound)
(bounds, lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span)))
});
hir::TyKind::TraitObject(bounds, TaggedRef::new(lifetime_bound, *kind))
}
Expand Down Expand Up @@ -3058,15 +3075,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
}))
}

fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
fn lower_unsafe_source(&self, u: UnsafeSource) -> hir::UnsafeSource {
match u {
CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
UserProvided => hir::UnsafeSource::UserProvided,
}
}

fn lower_trait_bound_modifiers(
&mut self,
&self,
modifiers: TraitBoundModifiers,
) -> hir::TraitBoundModifiers {
let constness = match modifiers.constness {
Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,6 @@ impl<'tcx, N: Idx> RegionValues<'tcx, N> {
}
}

/// For debugging purposes, returns a pretty-printed string of the given points.
pub(crate) fn pretty_print_points(
location_map: &DenseLocationMap,
points: impl IntoIterator<Item = PointIndex>,
) -> String {
pretty_print_region_elements(
points.into_iter().map(|p| location_map.to_location(p)).map(RegionElement::Location),
)
}

/// For debugging purposes, returns a pretty-printed string of the given region elements.
fn pretty_print_region_elements<'tcx>(
elements: impl IntoIterator<Item = RegionElement<'tcx>>,
Expand Down
20 changes: 19 additions & 1 deletion compiler/rustc_borrowck/src/type_check/liveness/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use itertools::{Either, Itertools};
use rustc_data_structures::fx::FxHashSet;
use rustc_index::interval::IntervalSet;
use rustc_middle::mir::visit::{TyContext, Visitor};
use rustc_middle::mir::{Body, Local, Location, SourceInfo};
use rustc_middle::ty::relate::Relate;
use rustc_middle::ty::{GenericArgsRef, Region, RegionVid, Ty, TyCtxt, TypeVisitable};
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
use rustc_span::span_bug;
use rustc_trait_selection::traits::outlives_for_liveness::FreeRegionsVisitor;
use tracing::debug;

use super::TypeChecker;
use crate::BorrowckInferCtxt;
use crate::constraints::OutlivesConstraintSet;
use crate::polonius::{PoloniusContext, record_live_region_variance};
use crate::region_infer::values::LivenessValues;
Expand Down Expand Up @@ -229,3 +232,18 @@ impl<'a, 'tcx> LiveVariablesVisitor<'a, 'tcx> {
}
}
}

pub(crate) fn make_all_regions_live<'tcx>(
infcx: &BorrowckInferCtxt<'tcx>,
universal_regions: &UniversalRegions<'tcx>,
liveness: &mut LivenessValues,
value: impl TypeVisitable<TyCtxt<'tcx>>,
live_at: &IntervalSet<PointIndex>,
) {
debug!("make_all_regions_live(value={value:?})");
value.visit_with(&mut FreeRegionsVisitor {
tcx: infcx.tcx,
param_env: infcx.param_env,
op: |r| liveness.add_points(universal_regions.to_region_vid(r), live_at),
});
}
Loading
Loading