Replace exist_ty and ExistTy with opaque_ty and OpaqueTy

This commit is contained in:
varkor 2019-08-02 00:08:05 +01:00
parent 2777386dc2
commit b4fe555796
11 changed files with 79 additions and 79 deletions

View File

@ -505,7 +505,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
visitor.visit_ty(ty); visitor.visit_ty(ty);
visitor.visit_generics(generics) visitor.visit_generics(generics)
} }
ItemKind::OpaqueTy(ExistTy { ItemKind::OpaqueTy(OpaqueTy {
ref generics, ref generics,
ref bounds, ref bounds,
.. ..

View File

@ -1721,7 +1721,7 @@ impl<'a> LoweringContext<'a> {
&mut self, &mut self,
span: Span, span: Span,
fn_def_id: Option<DefId>, fn_def_id: Option<DefId>,
exist_ty_node_id: NodeId, opaque_ty_node_id: NodeId,
lower_bounds: impl FnOnce(&mut LoweringContext<'_>) -> hir::GenericBounds, lower_bounds: impl FnOnce(&mut LoweringContext<'_>) -> hir::GenericBounds,
) -> hir::TyKind { ) -> hir::TyKind {
// Make sure we know that some funky desugaring has been going on here. // Make sure we know that some funky desugaring has been going on here.
@ -1729,30 +1729,30 @@ impl<'a> LoweringContext<'a> {
// desugaring that explicitly states that we don't want to track that. // desugaring that explicitly states that we don't want to track that.
// Not tracking it makes lints in rustc and clippy very fragile, as // Not tracking it makes lints in rustc and clippy very fragile, as
// frequently opened issues show. // frequently opened issues show.
let exist_ty_span = self.mark_span_with_reason( let opaque_ty_span = self.mark_span_with_reason(
DesugaringKind::OpaqueTy, DesugaringKind::OpaqueTy,
span, span,
None, None,
); );
let exist_ty_def_index = self let opaque_ty_def_index = self
.resolver .resolver
.definitions() .definitions()
.opt_def_index(exist_ty_node_id) .opt_def_index(opaque_ty_node_id)
.unwrap(); .unwrap();
self.allocate_hir_id_counter(exist_ty_node_id); self.allocate_hir_id_counter(opaque_ty_node_id);
let hir_bounds = self.with_hir_id_owner(exist_ty_node_id, lower_bounds); let hir_bounds = self.with_hir_id_owner(opaque_ty_node_id, lower_bounds);
let (lifetimes, lifetime_defs) = self.lifetimes_from_impl_trait_bounds( let (lifetimes, lifetime_defs) = self.lifetimes_from_impl_trait_bounds(
exist_ty_node_id, opaque_ty_node_id,
exist_ty_def_index, opaque_ty_def_index,
&hir_bounds, &hir_bounds,
); );
self.with_hir_id_owner(exist_ty_node_id, |lctx| { self.with_hir_id_owner(opaque_ty_node_id, |lctx| {
let exist_ty_item = hir::ExistTy { let opaque_ty_item = hir::OpaqueTy {
generics: hir::Generics { generics: hir::Generics {
params: lifetime_defs, params: lifetime_defs,
where_clause: hir::WhereClause { where_clause: hir::WhereClause {
@ -1766,16 +1766,16 @@ impl<'a> LoweringContext<'a> {
origin: hir::OpaqueTyOrigin::ReturnImplTrait, origin: hir::OpaqueTyOrigin::ReturnImplTrait,
}; };
trace!("exist ty from impl trait def-index: {:#?}", exist_ty_def_index); trace!("exist ty from impl trait def-index: {:#?}", opaque_ty_def_index);
let exist_ty_id = lctx.generate_opaque_type( let opaque_ty_id = lctx.generate_opaque_type(
exist_ty_node_id, opaque_ty_node_id,
exist_ty_item, opaque_ty_item,
span, span,
exist_ty_span, opaque_ty_span,
); );
// `impl Trait` now just becomes `Foo<'a, 'b, ..>`. // `impl Trait` now just becomes `Foo<'a, 'b, ..>`.
hir::TyKind::Def(hir::ItemId { id: exist_ty_id }, lifetimes) hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, lifetimes)
}) })
} }
@ -1783,34 +1783,34 @@ impl<'a> LoweringContext<'a> {
/// returns the lowered node-ID for the opaque type. /// returns the lowered node-ID for the opaque type.
fn generate_opaque_type( fn generate_opaque_type(
&mut self, &mut self,
exist_ty_node_id: NodeId, opaque_ty_node_id: NodeId,
exist_ty_item: hir::ExistTy, opaque_ty_item: hir::OpaqueTy,
span: Span, span: Span,
exist_ty_span: Span, opaque_ty_span: Span,
) -> hir::HirId { ) -> hir::HirId {
let exist_ty_item_kind = hir::ItemKind::OpaqueTy(exist_ty_item); let opaque_ty_item_kind = hir::ItemKind::OpaqueTy(opaque_ty_item);
let exist_ty_id = self.lower_node_id(exist_ty_node_id); let opaque_ty_id = self.lower_node_id(opaque_ty_node_id);
// Generate an `type Foo = impl Trait;` declaration. // Generate an `type Foo = impl Trait;` declaration.
trace!("registering opaque type with id {:#?}", exist_ty_id); trace!("registering opaque type with id {:#?}", opaque_ty_id);
let exist_ty_item = hir::Item { let opaque_ty_item = hir::Item {
hir_id: exist_ty_id, hir_id: opaque_ty_id,
ident: Ident::invalid(), ident: Ident::invalid(),
attrs: Default::default(), attrs: Default::default(),
node: exist_ty_item_kind, node: opaque_ty_item_kind,
vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited), vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),
span: exist_ty_span, span: opaque_ty_span,
}; };
// Insert the item into the global item list. This usually happens // Insert the item into the global item list. This usually happens
// automatically for all AST items. But this opaque type item // automatically for all AST items. But this opaque type item
// does not actually exist in the AST. // does not actually exist in the AST.
self.insert_item(exist_ty_item); self.insert_item(opaque_ty_item);
exist_ty_id opaque_ty_id
} }
fn lifetimes_from_impl_trait_bounds( fn lifetimes_from_impl_trait_bounds(
&mut self, &mut self,
exist_ty_id: NodeId, opaque_ty_id: NodeId,
parent_index: DefIndex, parent_index: DefIndex,
bounds: &hir::GenericBounds, bounds: &hir::GenericBounds,
) -> (HirVec<hir::GenericArg>, HirVec<hir::GenericParam>) { ) -> (HirVec<hir::GenericArg>, HirVec<hir::GenericParam>) {
@ -1820,7 +1820,7 @@ impl<'a> LoweringContext<'a> {
struct ImplTraitLifetimeCollector<'r, 'a> { struct ImplTraitLifetimeCollector<'r, 'a> {
context: &'r mut LoweringContext<'a>, context: &'r mut LoweringContext<'a>,
parent: DefIndex, parent: DefIndex,
exist_ty_id: NodeId, opaque_ty_id: NodeId,
collect_elided_lifetimes: bool, collect_elided_lifetimes: bool,
currently_bound_lifetimes: Vec<hir::LifetimeName>, currently_bound_lifetimes: Vec<hir::LifetimeName>,
already_defined_lifetimes: FxHashSet<hir::LifetimeName>, already_defined_lifetimes: FxHashSet<hir::LifetimeName>,
@ -1916,7 +1916,7 @@ impl<'a> LoweringContext<'a> {
let def_node_id = self.context.sess.next_node_id(); let def_node_id = self.context.sess.next_node_id();
let hir_id = let hir_id =
self.context.lower_node_id_with_owner(def_node_id, self.exist_ty_id); self.context.lower_node_id_with_owner(def_node_id, self.opaque_ty_id);
self.context.resolver.definitions().create_def_with_parent( self.context.resolver.definitions().create_def_with_parent(
self.parent, self.parent,
def_node_id, def_node_id,
@ -1952,7 +1952,7 @@ impl<'a> LoweringContext<'a> {
let mut lifetime_collector = ImplTraitLifetimeCollector { let mut lifetime_collector = ImplTraitLifetimeCollector {
context: self, context: self,
parent: parent_index, parent: parent_index,
exist_ty_id, opaque_ty_id,
collect_elided_lifetimes: true, collect_elided_lifetimes: true,
currently_bound_lifetimes: Vec::new(), currently_bound_lifetimes: Vec::new(),
already_defined_lifetimes: FxHashSet::default(), already_defined_lifetimes: FxHashSet::default(),
@ -2582,40 +2582,40 @@ impl<'a> LoweringContext<'a> {
}) })
} }
// Transforms `-> T` for `async fn` into `-> ExistTy { .. }` // Transforms `-> T` for `async fn` into `-> OpaqueTy { .. }`
// combined with the following definition of `ExistTy`: // combined with the following definition of `OpaqueTy`:
// //
// type ExistTy<generics_from_parent_fn> = impl Future<Output = T>; // type OpaqueTy<generics_from_parent_fn> = impl Future<Output = T>;
// //
// `inputs`: lowered types of arguments to the function (used to collect lifetimes) // `inputs`: lowered types of arguments to the function (used to collect lifetimes)
// `output`: unlowered output type (`T` in `-> T`) // `output`: unlowered output type (`T` in `-> T`)
// `fn_def_id`: `DefId` of the parent function (used to create child impl trait definition) // `fn_def_id`: `DefId` of the parent function (used to create child impl trait definition)
// `exist_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created // `opaque_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
// `elided_lt_replacement`: replacement for elided lifetimes in the return type // `elided_lt_replacement`: replacement for elided lifetimes in the return type
fn lower_async_fn_ret_ty( fn lower_async_fn_ret_ty(
&mut self, &mut self,
output: &FunctionRetTy, output: &FunctionRetTy,
fn_def_id: DefId, fn_def_id: DefId,
exist_ty_node_id: NodeId, opaque_ty_node_id: NodeId,
elided_lt_replacement: LtReplacement, elided_lt_replacement: LtReplacement,
) -> hir::FunctionRetTy { ) -> hir::FunctionRetTy {
let span = output.span(); let span = output.span();
let exist_ty_span = self.mark_span_with_reason( let opaque_ty_span = self.mark_span_with_reason(
DesugaringKind::Async, DesugaringKind::Async,
span, span,
None, None,
); );
let exist_ty_def_index = self let opaque_ty_def_index = self
.resolver .resolver
.definitions() .definitions()
.opt_def_index(exist_ty_node_id) .opt_def_index(opaque_ty_node_id)
.unwrap(); .unwrap();
self.allocate_hir_id_counter(exist_ty_node_id); self.allocate_hir_id_counter(opaque_ty_node_id);
let (exist_ty_id, lifetime_params) = self.with_hir_id_owner(exist_ty_node_id, |this| { let (opaque_ty_id, lifetime_params) = self.with_hir_id_owner(opaque_ty_node_id, |this| {
let future_bound = this.with_anonymous_lifetime_mode( let future_bound = this.with_anonymous_lifetime_mode(
AnonymousLifetimeMode::Replace(elided_lt_replacement), AnonymousLifetimeMode::Replace(elided_lt_replacement),
|this| this.lower_async_fn_output_type_to_future_bound( |this| this.lower_async_fn_output_type_to_future_bound(
@ -2642,11 +2642,11 @@ impl<'a> LoweringContext<'a> {
lifetime_params lifetime_params
.iter().cloned() .iter().cloned()
.map(|(span, hir_name)| { .map(|(span, hir_name)| {
this.lifetime_to_generic_param(span, hir_name, exist_ty_def_index) this.lifetime_to_generic_param(span, hir_name, opaque_ty_def_index)
}) })
.collect(); .collect();
let exist_ty_item = hir::ExistTy { let opaque_ty_item = hir::OpaqueTy {
generics: hir::Generics { generics: hir::Generics {
params: generic_params, params: generic_params,
where_clause: hir::WhereClause { where_clause: hir::WhereClause {
@ -2660,15 +2660,15 @@ impl<'a> LoweringContext<'a> {
origin: hir::OpaqueTyOrigin::AsyncFn, origin: hir::OpaqueTyOrigin::AsyncFn,
}; };
trace!("exist ty from async fn def index: {:#?}", exist_ty_def_index); trace!("exist ty from async fn def index: {:#?}", opaque_ty_def_index);
let exist_ty_id = this.generate_opaque_type( let opaque_ty_id = this.generate_opaque_type(
exist_ty_node_id, opaque_ty_node_id,
exist_ty_item, opaque_ty_item,
span, span,
exist_ty_span, opaque_ty_span,
); );
(exist_ty_id, lifetime_params) (opaque_ty_id, lifetime_params)
}); });
let generic_args = let generic_args =
@ -2683,10 +2683,10 @@ impl<'a> LoweringContext<'a> {
}) })
.collect(); .collect();
let exist_ty_ref = hir::TyKind::Def(hir::ItemId { id: exist_ty_id }, generic_args); let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args);
hir::FunctionRetTy::Return(P(hir::Ty { hir::FunctionRetTy::Return(P(hir::Ty {
node: exist_ty_ref, node: opaque_ty_ref,
span, span,
hir_id: self.next_id(), hir_id: self.next_id(),
})) }))
@ -3445,7 +3445,7 @@ impl<'a> LoweringContext<'a> {
self.lower_generics(generics, ImplTraitContext::disallowed()), self.lower_generics(generics, ImplTraitContext::disallowed()),
), ),
ItemKind::OpaqueTy(ref b, ref generics) => hir::ItemKind::OpaqueTy( ItemKind::OpaqueTy(ref b, ref generics) => hir::ItemKind::OpaqueTy(
hir::ExistTy { hir::OpaqueTy {
generics: self.lower_generics(generics, generics: self.lower_generics(generics,
ImplTraitContext::OpaqueTy(None)), ImplTraitContext::OpaqueTy(None)),
bounds: self.lower_param_bounds(b, bounds: self.lower_param_bounds(b,

View File

@ -827,7 +827,7 @@ impl<'hir> Map<'hir> {
match self.get(scope) { match self.get(scope) {
Node::Item(i) => { Node::Item(i) => {
match i.node { match i.node {
ItemKind::OpaqueTy(ExistTy { impl_trait_fn: None, .. }) => {} ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }) => {}
_ => break, _ => break,
} }
} }

View File

@ -1922,7 +1922,7 @@ pub struct BareFnTy {
} }
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct ExistTy { pub struct OpaqueTy {
pub generics: Generics, pub generics: Generics,
pub bounds: GenericBounds, pub bounds: GenericBounds,
pub impl_trait_fn: Option<DefId>, pub impl_trait_fn: Option<DefId>,
@ -2422,7 +2422,7 @@ pub enum ItemKind {
/// A type alias, e.g., `type Foo = Bar<u8>` /// A type alias, e.g., `type Foo = Bar<u8>`
Ty(P<Ty>, Generics), Ty(P<Ty>, Generics),
/// An opaque `impl Trait` type alias, e.g., `type Foo = impl Bar;` /// An opaque `impl Trait` type alias, e.g., `type Foo = impl Bar;`
OpaqueTy(ExistTy), OpaqueTy(OpaqueTy),
/// An enum definition, e.g., `enum Foo<A, B> {C<A>, D<B>}` /// An enum definition, e.g., `enum Foo<A, B> {C<A>, D<B>}`
Enum(EnumDef, Generics), Enum(EnumDef, Generics),
/// A struct definition, e.g., `struct Foo<A> {x: A}` /// A struct definition, e.g., `struct Foo<A> {x: A}`
@ -2479,7 +2479,7 @@ impl ItemKind {
Some(match *self { Some(match *self {
ItemKind::Fn(_, _, ref generics, _) | ItemKind::Fn(_, _, ref generics, _) |
ItemKind::Ty(_, ref generics) | ItemKind::Ty(_, ref generics) |
ItemKind::OpaqueTy(ExistTy { ref generics, impl_trait_fn: None, .. }) | ItemKind::OpaqueTy(OpaqueTy { ref generics, impl_trait_fn: None, .. }) |
ItemKind::Enum(_, ref generics) | ItemKind::Enum(_, ref generics) |
ItemKind::Struct(_, ref generics) | ItemKind::Struct(_, ref generics) |
ItemKind::Union(_, ref generics) | ItemKind::Union(_, ref generics) |

View File

@ -1033,13 +1033,13 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) { let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) {
Some(Node::Item(item)) => match item.node { Some(Node::Item(item)) => match item.node {
// Anonymous `impl Trait` // Anonymous `impl Trait`
hir::ItemKind::OpaqueTy(hir::ExistTy { hir::ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: Some(parent), impl_trait_fn: Some(parent),
origin, origin,
.. ..
}) => (parent == self.parent_def_id, origin), }) => (parent == self.parent_def_id, origin),
// Named `type Foo = impl Bar;` // Named `type Foo = impl Bar;`
hir::ItemKind::OpaqueTy(hir::ExistTy { hir::ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: None, impl_trait_fn: None,
origin, origin,
.. ..

View File

@ -480,7 +480,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
}; };
self.with(scope, |_, this| intravisit::walk_item(this, item)); self.with(scope, |_, this| intravisit::walk_item(this, item));
} }
hir::ItemKind::OpaqueTy(hir::ExistTy { hir::ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: Some(_), impl_trait_fn: Some(_),
.. ..
}) => { }) => {
@ -489,7 +489,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
// it. // it.
} }
hir::ItemKind::Ty(_, ref generics) hir::ItemKind::Ty(_, ref generics)
| hir::ItemKind::OpaqueTy(hir::ExistTy { | hir::ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: None, impl_trait_fn: None,
ref generics, ref generics,
.. ..
@ -629,7 +629,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
{ {
// Named opaque `impl Trait` types are reached via `TyKind::Path`. // Named opaque `impl Trait` types are reached via `TyKind::Path`.
// This arm is for `impl Trait` in the types of statics, constants and locals. // This arm is for `impl Trait` in the types of statics, constants and locals.
hir::ItemKind::OpaqueTy(hir::ExistTy { hir::ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: None, impl_trait_fn: None,
.. ..
}) => { }) => {
@ -637,7 +637,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
return; return;
} }
// RPIT (return position impl trait) // RPIT (return position impl trait)
hir::ItemKind::OpaqueTy(hir::ExistTy { hir::ItemKind::OpaqueTy(hir::OpaqueTy {
ref generics, ref generics,
ref bounds, ref bounds,
.. ..
@ -1254,7 +1254,7 @@ fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap<Vec<ObjectLifet
hir::ItemKind::Struct(_, ref generics) hir::ItemKind::Struct(_, ref generics)
| hir::ItemKind::Union(_, ref generics) | hir::ItemKind::Union(_, ref generics)
| hir::ItemKind::Enum(_, ref generics) | hir::ItemKind::Enum(_, ref generics)
| hir::ItemKind::OpaqueTy(hir::ExistTy { | hir::ItemKind::OpaqueTy(hir::OpaqueTy {
ref generics, ref generics,
impl_trait_fn: None, impl_trait_fn: None,
.. ..

View File

@ -3214,8 +3214,8 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> { pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) { if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
if let Node::Item(item) = tcx.hir().get(hir_id) { if let Node::Item(item) = tcx.hir().get(hir_id) {
if let hir::ItemKind::OpaqueTy(ref exist_ty) = item.node { if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.node {
return exist_ty.impl_trait_fn; return opaque_ty.impl_trait_fn;
} }
} }
} }

View File

@ -1403,7 +1403,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) {
hir::ItemKind::Union(..) => { hir::ItemKind::Union(..) => {
check_union(tcx, it.hir_id, it.span); check_union(tcx, it.hir_id, it.span);
} }
hir::ItemKind::OpaqueTy(hir::ExistTy{origin, ..}) => { hir::ItemKind::OpaqueTy(hir::OpaqueTy{origin, ..}) => {
let def_id = tcx.hir().local_def_id(it.hir_id); let def_id = tcx.hir().local_def_id(it.hir_id);
let substs = InternalSubsts::identity_for_item(tcx, def_id); let substs = InternalSubsts::identity_for_item(tcx, def_id);

View File

@ -294,7 +294,7 @@ fn type_param_predicates(
ItemKind::Fn(.., ref generics, _) ItemKind::Fn(.., ref generics, _)
| ItemKind::Impl(_, _, _, ref generics, ..) | ItemKind::Impl(_, _, _, ref generics, ..)
| ItemKind::Ty(_, ref generics) | ItemKind::Ty(_, ref generics)
| ItemKind::OpaqueTy(ExistTy { | ItemKind::OpaqueTy(OpaqueTy {
ref generics, ref generics,
impl_trait_fn: None, impl_trait_fn: None,
.. ..
@ -456,7 +456,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
} }
// Desugared from `impl Trait`, so visited by the function's return type. // Desugared from `impl Trait`, so visited by the function's return type.
hir::ItemKind::OpaqueTy(hir::ExistTy { hir::ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: Some(_), impl_trait_fn: Some(_),
.. ..
}) => {} }) => {}
@ -896,7 +896,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
.. ..
}) => Some(tcx.closure_base_def_id(def_id)), }) => Some(tcx.closure_base_def_id(def_id)),
Node::Item(item) => match item.node { Node::Item(item) => match item.node {
ItemKind::OpaqueTy(hir::ExistTy { impl_trait_fn, .. }) => impl_trait_fn, ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn, .. }) => impl_trait_fn,
_ => None, _ => None,
}, },
_ => None, _ => None,
@ -920,7 +920,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
ItemKind::Ty(_, ref generics) ItemKind::Ty(_, ref generics)
| ItemKind::Enum(_, ref generics) | ItemKind::Enum(_, ref generics)
| ItemKind::Struct(_, ref generics) | ItemKind::Struct(_, ref generics)
| ItemKind::OpaqueTy(hir::ExistTy { ref generics, .. }) | ItemKind::OpaqueTy(hir::OpaqueTy { ref generics, .. })
| ItemKind::Union(_, ref generics) => { | ItemKind::Union(_, ref generics) => {
allow_defaults = true; allow_defaults = true;
generics generics
@ -1253,12 +1253,12 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
let substs = InternalSubsts::identity_for_item(tcx, def_id); let substs = InternalSubsts::identity_for_item(tcx, def_id);
tcx.mk_adt(def, substs) tcx.mk_adt(def, substs)
} }
ItemKind::OpaqueTy(hir::ExistTy { ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: None, impl_trait_fn: None,
.. ..
}) => find_opaque_ty_constraints(tcx, def_id), }) => find_opaque_ty_constraints(tcx, def_id),
// Opaque types desugared from `impl Trait`. // Opaque types desugared from `impl Trait`.
ItemKind::OpaqueTy(hir::ExistTy { ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: Some(owner), impl_trait_fn: Some(owner),
.. ..
}) => { }) => {
@ -2051,7 +2051,7 @@ fn explicit_predicates_of(
is_trait = Some((ty::TraitRef::identity(tcx, def_id), &empty_trait_items)); is_trait = Some((ty::TraitRef::identity(tcx, def_id), &empty_trait_items));
generics generics
} }
ItemKind::OpaqueTy(ExistTy { ItemKind::OpaqueTy(OpaqueTy {
ref bounds, ref bounds,
impl_trait_fn, impl_trait_fn,
ref generics, ref generics,

View File

@ -3664,8 +3664,8 @@ impl Clean<Item> for doctree::OpaqueTy<'_> {
stability: self.stab.clean(cx), stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx), deprecation: self.depr.clean(cx),
inner: OpaqueTyItem(OpaqueTy { inner: OpaqueTyItem(OpaqueTy {
bounds: self.exist_ty.bounds.clean(cx), bounds: self.opaque_ty.bounds.clean(cx),
generics: self.exist_ty.generics.clean(cx), generics: self.opaque_ty.generics.clean(cx),
}, false), }, false),
} }
} }

View File

@ -472,9 +472,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
}; };
om.typedefs.push(t); om.typedefs.push(t);
}, },
hir::ItemKind::OpaqueTy(ref exist_ty) => { hir::ItemKind::OpaqueTy(ref opaque_ty) => {
let t = OpaqueTy { let t = OpaqueTy {
exist_ty, opaque_ty,
name: ident.name, name: ident.name,
id: item.hir_id, id: item.hir_id,
attrs: &item.attrs, attrs: &item.attrs,