Skip to content

Commit 9fc1408

Browse files
committed
Compile core.
1 parent 01ccab5 commit 9fc1408

File tree

31 files changed

+486
-697
lines changed

31 files changed

+486
-697
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+7-260
Large diffs are not rendered by default.

compiler/rustc_ast_lowering/src/lifetime_collector.rs

-118
This file was deleted.

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
829829
///
830830
/// [`OpaqueDef`]: hir::TyKind::OpaqueDef
831831
fn get_future_inner_return_ty(&self, hir_ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> {
832-
let hir::TyKind::OpaqueDef(opaque_ty, _) = hir_ty.kind else {
832+
let hir::TyKind::OpaqueDef(opaque_ty) = hir_ty.kind else {
833833
span_bug!(
834834
hir_ty.span,
835835
"lowered return type of async fn is not OpaqueDef: {:?}",

compiler/rustc_hir/src/hir.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,6 @@ impl<'hir> Ty<'hir> {
26102610
}
26112611
TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
26122612
TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),
2613-
TyKind::OpaqueDef(_, generic_args) => are_suggestable_generic_args(generic_args),
26142613
TyKind::Path(QPath::TypeRelative(ty, segment)) => {
26152614
ty.is_suggestable_infer_ty() || are_suggestable_generic_args(segment.args().args)
26162615
}
@@ -2729,19 +2728,8 @@ pub struct BareFnTy<'hir> {
27292728
pub struct OpaqueTy<'hir> {
27302729
pub hir_id: HirId,
27312730
pub def_id: LocalDefId,
2732-
pub generics: &'hir Generics<'hir>,
27332731
pub bounds: GenericBounds<'hir>,
27342732
pub origin: OpaqueTyOrigin,
2735-
/// Return-position impl traits (and async futures) must "reify" any late-bound
2736-
/// lifetimes that are captured from the function signature they originate from.
2737-
///
2738-
/// This is done by generating a new early-bound lifetime parameter local to the
2739-
/// opaque which is instantiated in the function signature with the late-bound
2740-
/// lifetime.
2741-
///
2742-
/// This mapping associated a captured lifetime (first parameter) with the new
2743-
/// early-bound lifetime that was generated for the opaque.
2744-
pub lifetime_mapping: &'hir [(&'hir Lifetime, LocalDefId)],
27452733
/// Whether the opaque is a return-position impl trait (or async future)
27462734
/// originating from a trait method. This makes it so that the opaque is
27472735
/// lowered as an associated type.
@@ -2837,7 +2825,7 @@ pub enum TyKind<'hir> {
28372825
/// possibly parameters) that are actually bound on the `impl Trait`.
28382826
///
28392827
/// The last parameter specifies whether this opaque appears in a trait definition.
2840-
OpaqueDef(&'hir OpaqueTy<'hir>, &'hir [GenericArg<'hir>]),
2828+
OpaqueDef(&'hir OpaqueTy<'hir>),
28412829
/// A trait object type `Bound1 + Bound2 + Bound3`
28422830
/// where `Bound` is a trait or a lifetime.
28432831
TraitObject(
@@ -3959,7 +3947,6 @@ impl<'hir> Node<'hir> {
39593947
| Node::TraitItem(TraitItem { generics, .. })
39603948
| Node::ImplItem(ImplItem { generics, .. }) => Some(generics),
39613949
Node::Item(item) => item.kind.generics(),
3962-
Node::OpaqueTy(opaque) => Some(opaque.generics),
39633950
_ => None,
39643951
}
39653952
}

compiler/rustc_hir/src/intravisit.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,8 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) -> V::Resul
896896
TyKind::Path(ref qpath) => {
897897
try_visit!(visitor.visit_qpath(qpath, typ.hir_id, typ.span));
898898
}
899-
TyKind::OpaqueDef(opaque, lifetimes) => {
899+
TyKind::OpaqueDef(opaque) => {
900900
try_visit!(visitor.visit_opaque_ty(opaque));
901-
walk_list!(visitor, visit_generic_arg, lifetimes);
902901
}
903902
TyKind::Array(ref ty, ref length) => {
904903
try_visit!(visitor.visit_ty(ty));
@@ -1188,18 +1187,8 @@ pub fn walk_poly_trait_ref<'v, V: Visitor<'v>>(
11881187
}
11891188

11901189
pub fn walk_opaque_ty<'v, V: Visitor<'v>>(visitor: &mut V, opaque: &'v OpaqueTy<'v>) -> V::Result {
1191-
let &OpaqueTy {
1192-
hir_id,
1193-
def_id: _,
1194-
generics,
1195-
bounds,
1196-
origin: _,
1197-
lifetime_mapping: _,
1198-
in_trait: _,
1199-
span: _,
1200-
} = opaque;
1190+
let &OpaqueTy { hir_id, def_id: _, bounds, origin: _, in_trait: _, span: _ } = opaque;
12011191
try_visit!(visitor.visit_id(hir_id));
1202-
try_visit!(walk_generics(visitor, generics));
12031192
walk_list!(visitor, visit_param_bound, bounds);
12041193
V::Result::output()
12051194
}

compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
13951395
}
13961396
}
13971397

1398-
#[instrument(level = "debug", skip(tcx))]
1398+
#[instrument(level = "debug", skip(tcx), ret)]
13991399
fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, ty::PolyFnSig<'_>> {
14001400
use rustc_hir::Node::*;
14011401
use rustc_hir::*;

compiler/rustc_hir_analysis/src/collect/generics_of.rs

+15
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,21 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
455455
});
456456
}
457457

458+
if let Node::OpaqueTy(&hir::OpaqueTy { .. }) = node {
459+
assert!(own_params.is_empty());
460+
461+
let lifetimes = tcx.opaque_captured_lifetimes(def_id);
462+
debug!(?lifetimes);
463+
464+
own_params.extend(lifetimes.iter().map(|&(_, param)| ty::GenericParamDef {
465+
name: tcx.item_name(param.to_def_id()),
466+
index: next_index(),
467+
def_id: param.to_def_id(),
468+
pure_wrt_drop: false,
469+
kind: ty::GenericParamDefKind::Lifetime,
470+
}))
471+
}
472+
458473
let param_def_id_to_index =
459474
own_params.iter().map(|param| (param.def_id, param.index)).collect();
460475

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

-7
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
316316
// We create bi-directional Outlives predicates between the original
317317
// and the duplicated parameter, to ensure that they do not get out of sync.
318318
if let Node::OpaqueTy(..) = node {
319-
let opaque_ty_node = tcx.parent_hir_node(hir_id);
320-
let Node::Ty(&hir::Ty { kind: TyKind::OpaqueDef(_, lifetimes), .. }) = opaque_ty_node
321-
else {
322-
bug!("unexpected {opaque_ty_node:?}")
323-
};
324-
debug!(?lifetimes);
325-
326319
compute_bidirectional_outlives_predicates(tcx, &generics.own_params, &mut predicates);
327320
debug!(?predicates);
328321
}

0 commit comments

Comments
 (0)