Skip to content
10 changes: 4 additions & 6 deletions compiler/rustc_hir_analysis/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,17 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> 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<Arena<'tcx>>`, 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());
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -1377,8 +1376,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<DepNodeIndex>,

phantom_data: PhantomData<DepNode>,
}

impl TaskDeps {
Expand All @@ -1392,7 +1389,6 @@ impl TaskDeps {
node,
reads: EdgesVec::new(),
read_set: FxHashSet::with_capacity_and_hasher(read_set_capacity, Default::default()),
phantom_data: PhantomData,
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_middle/src/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -270,13 +269,6 @@ TrivialTypeTraversalAndLiftImpls! {
///////////////////////////////////////////////////////////////////////////
// Lift implementations

impl<'tcx> Lift<TyCtxt<'tcx>> for PhantomData<&()> {
type Lifted = PhantomData<&'tcx ()>;
fn lift_to_interner(self, _: TyCtxt<'tcx>) -> Option<Self::Lifted> {
Some(PhantomData)
}
}

impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
type Lifted = Option<T::Lifted>;
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<host>/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);
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/delegation/generics/unresolved-segment-ice-153389.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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`.
Loading