From 70775304cd83bf01bf91d5cf206923064fca68ef Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 2 Sep 2022 16:55:24 +0000 Subject: [PATCH] Address nits --- compiler/rustc_ast_lowering/src/lib.rs | 1 - compiler/rustc_hir/src/def.rs | 4 ++-- compiler/rustc_hir/src/hir.rs | 5 ++++- compiler/rustc_trait_selection/src/traits/project.rs | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 8814d184c558..8fa2c593193e 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1357,7 +1357,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ) } ImplTraitContext::InTrait => { - // FIXME(RPITIT): Should we use def_node_id here? self.lower_impl_trait_in_trait(span, def_node_id, |lctx| { lctx.lower_param_bounds( bounds, diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 8563b588585b..e7c26bd726fb 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -193,7 +193,6 @@ impl DefKind { | DefKind::Variant | DefKind::Trait | DefKind::OpaqueTy - | DefKind::ImplTraitPlaceholder | DefKind::TyAlias | DefKind::ForeignTy | DefKind::TraitAlias @@ -221,7 +220,8 @@ impl DefKind { | DefKind::Use | DefKind::ForeignMod | DefKind::GlobalAsm - | DefKind::Impl => None, + | DefKind::Impl + | DefKind::ImplTraitPlaceholder => None, } } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 334d4fd0b042..8b1ebe34cb00 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -2551,7 +2551,10 @@ pub enum TyKind<'hir> { /// The generic argument list contains the lifetimes (and in the future /// possibly parameters) that are actually bound on the `impl Trait`. OpaqueDef(ItemId, &'hir [GenericArg<'hir>]), - /// The placeholder + /// A type that represents an `impl Trait` in a trait function. This is + /// not an opaque type, since it acts more like an associated type than + /// an opaque, and since it needs no generics since it inherits those + /// from the item's parent. ImplTraitInTrait(ItemId), /// A trait object type `Bound1 + Bound2 + Bound3` /// where `Bound` is a trait or a lifetime. diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 6ccb91c8cab6..6c9efea8ca87 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1308,9 +1308,9 @@ fn project<'cx, 'tcx>( } } -/// The first thing we have to do is scan through the parameter -/// environment to see whether there are any projection predicates -/// there that can answer this question. +/// If the predicate's item is an `ImplTraitPlaceholder`, we do a select on the +/// corresponding trait ref. If this yields an `impl`, then we're able to project +/// to a concrete type, since we have an `impl`'s method to provide the RPITIT. fn assemble_candidate_for_impl_trait_in_trait<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>,