From 7b4474a26502a0158d5b15029eddd3f8462ba029 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 2 Mar 2026 16:52:31 +1100 Subject: [PATCH 1/5] Remove `TaskDeps::phantom_data`. It has no effect. Presumably at some point in the past there were generics involved here? --- compiler/rustc_middle/src/dep_graph/graph.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/compiler/rustc_middle/src/dep_graph/graph.rs b/compiler/rustc_middle/src/dep_graph/graph.rs index a71373c62f38e..b0c1d188b9040 100644 --- a/compiler/rustc_middle/src/dep_graph/graph.rs +++ b/compiler/rustc_middle/src/dep_graph/graph.rs @@ -1,6 +1,5 @@ use std::fmt::Debug; use std::hash::Hash; -use std::marker::PhantomData; use std::sync::Arc; use std::sync::atomic::{AtomicU32, Ordering}; @@ -1353,8 +1352,6 @@ pub struct TaskDeps { /// scan. If the number is higher, a hashset has better perf. This field is that hashset. It's /// only used if the number of elements in `reads` exceeds `LINEAR_SCAN_MAX`. read_set: FxHashSet, - - phantom_data: PhantomData, } impl TaskDeps { @@ -1368,7 +1365,6 @@ impl TaskDeps { node, reads: EdgesVec::new(), read_set: FxHashSet::with_capacity_and_hasher(read_set_capacity, Default::default()), - phantom_data: PhantomData, } } } From 69042d166756d62a27e00c7e35af7414a2bad322 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 2 Mar 2026 17:17:24 +1100 Subject: [PATCH 2/5] Remove unused `Lift` impl. --- compiler/rustc_middle/src/ty/structural_impls.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 8707b03e4b8f2..9a2f1e8a13a1a 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -4,7 +4,6 @@ //! to help with the tedium. use std::fmt::{self, Debug}; -use std::marker::PhantomData; use rustc_abi::TyAndLayout; use rustc_hir::def::Namespace; @@ -270,13 +269,6 @@ TrivialTypeTraversalAndLiftImpls! { /////////////////////////////////////////////////////////////////////////// // Lift implementations -impl<'tcx> Lift> for PhantomData<&()> { - type Lifted = PhantomData<&'tcx ()>; - fn lift_to_interner(self, _: TyCtxt<'tcx>) -> Option { - Some(PhantomData) - } -} - impl<'tcx, T: Lift>> Lift> for Option { type Lifted = Option; fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option { From b3fddcbf28c9f45155b199ec989f7089285252b6 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 5 Mar 2026 09:10:58 +1100 Subject: [PATCH 3/5] Add a comment explaining the 'tcx lifetime. --- compiler/rustc_interface/src/passes.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 5d4db9aef003c..cdfe80e1fe963 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -964,6 +964,17 @@ pub fn create_and_enter_global_ctxt FnOnce(TyCtxt<'tcx>) -> T>( let incremental = dep_graph.is_fully_enabled(); + // Note: this function body is the origin point of the widely-used 'tcx lifetime. + // + // `gcx_cell` is defined here and `&gcx_cell` is passed to `create_global_ctxt`, which then + // actually creates the `GlobalCtxt` with a `gcx_cell.get_or_init(...)` call. This is done so + // that the resulting reference has the type `&'tcx GlobalCtxt<'tcx>`, which is what `TyCtxt` + // needs. If we defined and created the `GlobalCtxt` within `create_global_ctxt` then its type + // would be `&'a GlobalCtxt<'tcx>`, with two lifetimes. + // + // Similarly, by creating `arena` here and passing in `&arena`, that reference has the type + // `&'tcx WorkerLocal>`, also with one lifetime. And likewise for `hir_arena`. + let gcx_cell = OnceLock::new(); let arena = WorkerLocal::new(|_| Arena::default()); let hir_arena = WorkerLocal::new(|_| rustc_hir::Arena::default()); From e26974ca33aa322bbc60db5d1010899e40f6d624 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Fri, 9 Jan 2026 08:35:43 +1000 Subject: [PATCH 4/5] bootstrap: minimal fix for ./x install src with build.docs = false When running the `install src` command I'm seeing failures as the `builder.doc_out(host)` directory does not exist. This is because `match_paths_to_steps_and_run()` doesn't actually build any documentation as the `paths.is_empty()` causes an early return. This results in install failures as the `*/doc` src directory doesn't exist. This patch ensures that the builder.doc_out(host) directory exists. This fixes installing the Rust source when `build.docs = false`. This fixes installing the Rust source code in OpenEmbedded. Signed-off-by: Alistair Francis Signed-off-by: Jieyou Xu --- src/bootstrap/src/core/build_steps/dist.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 2e291f7c2c320..28a7afd6c61a6 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -87,6 +87,12 @@ impl Step for Docs { // from a shared directory. builder.run_default_doc_steps(); + // In case no default doc steps are run for host, it is possible that `/doc` directory + // is never created. + if !builder.config.dry_run() { + t!(fs::create_dir_all(builder.doc_out(host))); + } + let dest = "share/doc/rust/html"; let mut tarball = Tarball::new(builder, "rust-docs", &host.triple); From 169dd72d476b415a974f8c37416af1bb80f29de3 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Thu, 5 Mar 2026 10:38:56 +0300 Subject: [PATCH 5/5] Fix obtaining def_id from unresolved segment --- compiler/rustc_hir_analysis/src/delegation.rs | 10 ++++------ .../generics/unresolved-segment-ice-153389.rs | 13 +++++++++++++ .../generics/unresolved-segment-ice-153389.stderr | 9 +++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 tests/ui/delegation/generics/unresolved-segment-ice-153389.rs create mode 100644 tests/ui/delegation/generics/unresolved-segment-ice-153389.stderr diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index b1c03b824866e..3392a72daec14 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -572,17 +572,15 @@ fn get_delegation_user_specified_args<'tcx>( .opt_delegation_generics() .expect("Lowering delegation"); - let get_segment = |hir_id: HirId| -> (&'tcx PathSegment<'tcx>, DefId) { + let get_segment = |hir_id: HirId| -> Option<(&'tcx PathSegment<'tcx>, DefId)> { let segment = tcx.hir_node(hir_id).expect_path_segment(); - let def_id = segment.res.def_id(); - - (segment, def_id) + segment.res.opt_def_id().map(|def_id| (segment, def_id)) }; let ctx = ItemCtxt::new(tcx, delegation_id); let lowerer = ctx.lowerer(); - let parent_args = info.parent_args_segment_id.map(get_segment).map(|(segment, def_id)| { + let parent_args = info.parent_args_segment_id.and_then(get_segment).map(|(segment, def_id)| { let self_ty = get_delegation_self_ty(tcx, delegation_id); lowerer @@ -598,7 +596,7 @@ fn get_delegation_user_specified_args<'tcx>( .as_slice() }); - let child_args = info.child_args_segment_id.map(get_segment).map(|(segment, def_id)| { + let child_args = info.child_args_segment_id.and_then(get_segment).map(|(segment, def_id)| { let parent_args = if let Some(parent_args) = parent_args { parent_args } else { diff --git a/tests/ui/delegation/generics/unresolved-segment-ice-153389.rs b/tests/ui/delegation/generics/unresolved-segment-ice-153389.rs new file mode 100644 index 0000000000000..431184923887d --- /dev/null +++ b/tests/ui/delegation/generics/unresolved-segment-ice-153389.rs @@ -0,0 +1,13 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +trait Trait{ + fn bar(); +} + +impl Trait for () { + reuse missing::<> as bar; + //~^ ERROR: cannot find function `missing` in this scope +} + +fn main() {} diff --git a/tests/ui/delegation/generics/unresolved-segment-ice-153389.stderr b/tests/ui/delegation/generics/unresolved-segment-ice-153389.stderr new file mode 100644 index 0000000000000..b69917117fce9 --- /dev/null +++ b/tests/ui/delegation/generics/unresolved-segment-ice-153389.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `missing` in this scope + --> $DIR/unresolved-segment-ice-153389.rs:9:11 + | +LL | reuse missing::<> as bar; + | ^^^^^^^ not found in this scope + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0425`.