Skip to content

Commit

Permalink
Rename TyKind::Def to OpaqueDef
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Jun 11, 2020
1 parent 6c04d86 commit ee0d3c7
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/lib.rs
Expand Up @@ -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)
})
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustc_hir/hir.rs
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_hir/intravisit.rs
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_hir_pretty/lib.rs
Expand Up @@ -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;
Expand Down
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/dead.rs
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_resolve/late/lifetimes.rs
Expand Up @@ -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)
Expand Down Expand Up @@ -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>;`
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/dump_visitor.rs
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/sig.rs
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/astconv.rs
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/coercion.rs
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/collect.rs
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Expand Up @@ -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))
Expand Down

0 comments on commit ee0d3c7

Please sign in to comment.