Rename TyKind::Def
to OpaqueDef
This commit is contained in:
parent
6c04d8672d
commit
ee0d3c7f90
@ -1400,7 +1400,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
lctx.generate_opaque_type(opaque_ty_node_id, opaque_ty_item, span, opaque_ty_span);
|
||||
|
||||
// `impl Trait` now just becomes `Foo<'a, 'b, ..>`.
|
||||
hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, lifetimes)
|
||||
hir::TyKind::OpaqueDef(hir::ItemId { id: opaque_ty_id }, lifetimes)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2046,12 +2046,12 @@ pub enum TyKind<'hir> {
|
||||
///
|
||||
/// Type parameters may be stored in each `PathSegment`.
|
||||
Path(QPath<'hir>),
|
||||
/// A type definition itself. This is currently only used for the `type Foo = impl Trait`
|
||||
/// item that `impl Trait` in return position desugars to.
|
||||
/// A opaque type definition itself. This is currently only used for the
|
||||
/// `opaque type Foo: Trait` item that `impl Trait` in desugars to.
|
||||
///
|
||||
/// The generic argument list contains the lifetimes (and in the future possibly parameters)
|
||||
/// that are actually bound on the `impl Trait`.
|
||||
Def(ItemId, &'hir [GenericArg<'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>]),
|
||||
/// A trait object type `Bound1 + Bound2 + Bound3`
|
||||
/// where `Bound` is a trait or a lifetime.
|
||||
TraitObject(&'hir [PolyTraitRef<'hir>], Lifetime),
|
||||
|
@ -690,7 +690,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
|
||||
TyKind::Path(ref qpath) => {
|
||||
visitor.visit_qpath(qpath, typ.hir_id, typ.span);
|
||||
}
|
||||
TyKind::Def(item_id, lifetimes) => {
|
||||
TyKind::OpaqueDef(item_id, lifetimes) => {
|
||||
visitor.visit_nested_item(item_id);
|
||||
walk_list!(visitor, visit_generic_arg, lifetimes);
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ impl<'a> State<'a> {
|
||||
&f.param_names[..],
|
||||
);
|
||||
}
|
||||
hir::TyKind::Def(..) => self.s.word("/*impl Trait*/"),
|
||||
hir::TyKind::OpaqueDef(..) => self.s.word("/*impl Trait*/"),
|
||||
hir::TyKind::Path(ref qpath) => self.print_qpath(qpath, false),
|
||||
hir::TyKind::TraitObject(bounds, ref lifetime) => {
|
||||
let mut first = true;
|
||||
|
@ -84,7 +84,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
rustc_hir::intravisit::walk_ty(&mut v, ty);
|
||||
|
||||
debug!("try_report_named_anon_conflict: ret ty {:?}", ty);
|
||||
if sub == &ty::ReStatic && (matches!(ty.kind, TyKind::Def(_, _)) || v.0.len() == 1)
|
||||
if sub == &ty::ReStatic
|
||||
&& (matches!(ty.kind, TyKind::OpaqueDef(_, _)) || v.0.len() == 1)
|
||||
{
|
||||
debug!("try_report_named_anon_conflict: impl Trait + 'static");
|
||||
// This is an `impl Trait` or `dyn Trait` return that evaluates de need of
|
||||
|
@ -1102,7 +1102,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
|
||||
hir::ItemKind::TyAlias(ref ty, ref generics) => (&*ty, generics),
|
||||
_ => return,
|
||||
};
|
||||
if let hir::TyKind::Def(..) = ty.kind {
|
||||
if let hir::TyKind::OpaqueDef(..) = ty.kind {
|
||||
// Bounds are respected for `type X = impl Trait`
|
||||
return;
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
|
||||
if let TyKind::Def(item_id, _) = ty.kind {
|
||||
if let TyKind::OpaqueDef(item_id, _) = ty.kind {
|
||||
let item = self.tcx.hir().expect_item(item_id.id);
|
||||
intravisit::walk_item(self, item);
|
||||
}
|
||||
|
@ -400,9 +400,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
self.with(scope, |_, this| intravisit::walk_item(this, item));
|
||||
}
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy { .. }) => {
|
||||
// Opaque types are visited when we visit the `TyKind::Def`, so
|
||||
// that they have the lifetimes from their parent opaque_ty in
|
||||
// scope.
|
||||
// Opaque types are visited when we visit the
|
||||
// `TyKind::OpaqueDef`, so that they have the lifetimes from
|
||||
// their parent opaque_ty in scope.
|
||||
}
|
||||
hir::ItemKind::TyAlias(_, ref generics)
|
||||
| hir::ItemKind::Enum(_, ref generics)
|
||||
@ -557,7 +557,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
};
|
||||
self.with(scope, |_, this| this.visit_ty(&mt.ty));
|
||||
}
|
||||
hir::TyKind::Def(item_id, lifetimes) => {
|
||||
hir::TyKind::OpaqueDef(item_id, lifetimes) => {
|
||||
// Resolve the lifetimes in the bounds to the lifetime defs in the generics.
|
||||
// `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
|
||||
// `type MyAnonTy<'b> = impl MyTrait<'b>;`
|
||||
|
@ -1379,7 +1379,7 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
|
||||
v.visit_expr(&map.body(anon_const.body).value)
|
||||
});
|
||||
}
|
||||
hir::TyKind::Def(item_id, _) => {
|
||||
hir::TyKind::OpaqueDef(item_id, _) => {
|
||||
let item = self.tcx.hir().item(item_id.id);
|
||||
self.nest_tables(self.tcx.hir().local_def_id(item_id.id), |v| v.visit_item(item));
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
|
||||
let text = format!("[{}; {}]", nested_ty.text, expr);
|
||||
Ok(replace_text(nested_ty, text))
|
||||
}
|
||||
hir::TyKind::Def(item_id, _) => {
|
||||
hir::TyKind::OpaqueDef(item_id, _) => {
|
||||
let item = scx.tcx.hir().item(item_id.id);
|
||||
item.make(offset, Some(item_id.id), scx)
|
||||
}
|
||||
|
@ -2838,7 +2838,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let opt_self_ty = maybe_qself.as_ref().map(|qself| self.ast_ty_to_ty(qself));
|
||||
self.res_to_ty(opt_self_ty, path, false)
|
||||
}
|
||||
hir::TyKind::Def(item_id, ref lifetimes) => {
|
||||
hir::TyKind::OpaqueDef(item_id, ref lifetimes) => {
|
||||
let opaque_ty = tcx.hir().expect_item(item_id.id);
|
||||
let def_id = tcx.hir().local_def_id(item_id.id).to_def_id();
|
||||
|
||||
|
@ -1494,7 +1494,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||
let mut is_object_safe = false;
|
||||
if let hir::FnRetTy::Return(ty) = fn_output {
|
||||
// Get the return type.
|
||||
if let hir::TyKind::Def(..) = ty.kind {
|
||||
if let hir::TyKind::OpaqueDef(..) = ty.kind {
|
||||
let ty = AstConv::ast_ty_to_ty(fcx, ty);
|
||||
// Get the `impl Trait`'s `DefId`.
|
||||
if let ty::Opaque(def_id, _) = ty.kind {
|
||||
|
@ -1417,7 +1417,7 @@ fn is_suggestable_infer_ty(ty: &hir::Ty<'_>) -> bool {
|
||||
Slice(ty) | Array(ty, _) => is_suggestable_infer_ty(ty),
|
||||
Tup(tys) => tys.iter().any(is_suggestable_infer_ty),
|
||||
Ptr(mut_ty) | Rptr(_, mut_ty) => is_suggestable_infer_ty(mut_ty.ty),
|
||||
Def(_, generic_args) => are_suggestable_generic_args(generic_args),
|
||||
OpaqueDef(_, generic_args) => are_suggestable_generic_args(generic_args),
|
||||
Path(hir::QPath::TypeRelative(ty, segment)) => {
|
||||
is_suggestable_infer_ty(ty) || are_suggestable_generic_args(segment.generic_args().args)
|
||||
}
|
||||
|
@ -1351,7 +1351,7 @@ impl Clean<Type> for hir::Ty<'_> {
|
||||
Array(box ty.clean(cx), length)
|
||||
}
|
||||
TyKind::Tup(ref tys) => Tuple(tys.clean(cx)),
|
||||
TyKind::Def(item_id, _) => {
|
||||
TyKind::OpaqueDef(item_id, _) => {
|
||||
let item = cx.tcx.hir().expect_item(item_id.id);
|
||||
if let hir::ItemKind::OpaqueTy(ref ty) = item.kind {
|
||||
ImplTrait(ty.bounds.clean(cx))
|
||||
|
Loading…
x
Reference in New Issue
Block a user