Skip to content

Commit ee0d3c7

Browse files
committed
Rename TyKind::Def to OpaqueDef
1 parent 6c04d86 commit ee0d3c7

File tree

14 files changed

+22
-21
lines changed

14 files changed

+22
-21
lines changed

src/librustc_ast_lowering/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14001400
lctx.generate_opaque_type(opaque_ty_node_id, opaque_ty_item, span, opaque_ty_span);
14011401

14021402
// `impl Trait` now just becomes `Foo<'a, 'b, ..>`.
1403-
hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, lifetimes)
1403+
hir::TyKind::OpaqueDef(hir::ItemId { id: opaque_ty_id }, lifetimes)
14041404
})
14051405
}
14061406

src/librustc_hir/hir.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2046,12 +2046,12 @@ pub enum TyKind<'hir> {
20462046
///
20472047
/// Type parameters may be stored in each `PathSegment`.
20482048
Path(QPath<'hir>),
2049-
/// A type definition itself. This is currently only used for the `type Foo = impl Trait`
2050-
/// item that `impl Trait` in return position desugars to.
2049+
/// A opaque type definition itself. This is currently only used for the
2050+
/// `opaque type Foo: Trait` item that `impl Trait` in desugars to.
20512051
///
2052-
/// The generic argument list contains the lifetimes (and in the future possibly parameters)
2053-
/// that are actually bound on the `impl Trait`.
2054-
Def(ItemId, &'hir [GenericArg<'hir>]),
2052+
/// The generic argument list contains the lifetimes (and in the future
2053+
/// possibly parameters) that are actually bound on the `impl Trait`.
2054+
OpaqueDef(ItemId, &'hir [GenericArg<'hir>]),
20552055
/// A trait object type `Bound1 + Bound2 + Bound3`
20562056
/// where `Bound` is a trait or a lifetime.
20572057
TraitObject(&'hir [PolyTraitRef<'hir>], Lifetime),

src/librustc_hir/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
690690
TyKind::Path(ref qpath) => {
691691
visitor.visit_qpath(qpath, typ.hir_id, typ.span);
692692
}
693-
TyKind::Def(item_id, lifetimes) => {
693+
TyKind::OpaqueDef(item_id, lifetimes) => {
694694
visitor.visit_nested_item(item_id);
695695
walk_list!(visitor, visit_generic_arg, lifetimes);
696696
}

src/librustc_hir_pretty/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl<'a> State<'a> {
407407
&f.param_names[..],
408408
);
409409
}
410-
hir::TyKind::Def(..) => self.s.word("/*impl Trait*/"),
410+
hir::TyKind::OpaqueDef(..) => self.s.word("/*impl Trait*/"),
411411
hir::TyKind::Path(ref qpath) => self.print_qpath(qpath, false),
412412
hir::TyKind::TraitObject(bounds, ref lifetime) => {
413413
let mut first = true;

src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
8484
rustc_hir::intravisit::walk_ty(&mut v, ty);
8585

8686
debug!("try_report_named_anon_conflict: ret ty {:?}", ty);
87-
if sub == &ty::ReStatic && (matches!(ty.kind, TyKind::Def(_, _)) || v.0.len() == 1)
87+
if sub == &ty::ReStatic
88+
&& (matches!(ty.kind, TyKind::OpaqueDef(_, _)) || v.0.len() == 1)
8889
{
8990
debug!("try_report_named_anon_conflict: impl Trait + 'static");
9091
// This is an `impl Trait` or `dyn Trait` return that evaluates de need of

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
11021102
hir::ItemKind::TyAlias(ref ty, ref generics) => (&*ty, generics),
11031103
_ => return,
11041104
};
1105-
if let hir::TyKind::Def(..) = ty.kind {
1105+
if let hir::TyKind::OpaqueDef(..) = ty.kind {
11061106
// Bounds are respected for `type X = impl Trait`
11071107
return;
11081108
}

src/librustc_passes/dead.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
304304
}
305305

306306
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
307-
if let TyKind::Def(item_id, _) = ty.kind {
307+
if let TyKind::OpaqueDef(item_id, _) = ty.kind {
308308
let item = self.tcx.hir().expect_item(item_id.id);
309309
intravisit::walk_item(self, item);
310310
}

src/librustc_resolve/late/lifetimes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
400400
self.with(scope, |_, this| intravisit::walk_item(this, item));
401401
}
402402
hir::ItemKind::OpaqueTy(hir::OpaqueTy { .. }) => {
403-
// Opaque types are visited when we visit the `TyKind::Def`, so
404-
// that they have the lifetimes from their parent opaque_ty in
405-
// scope.
403+
// Opaque types are visited when we visit the
404+
// `TyKind::OpaqueDef`, so that they have the lifetimes from
405+
// their parent opaque_ty in scope.
406406
}
407407
hir::ItemKind::TyAlias(_, ref generics)
408408
| hir::ItemKind::Enum(_, ref generics)
@@ -557,7 +557,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
557557
};
558558
self.with(scope, |_, this| this.visit_ty(&mt.ty));
559559
}
560-
hir::TyKind::Def(item_id, lifetimes) => {
560+
hir::TyKind::OpaqueDef(item_id, lifetimes) => {
561561
// Resolve the lifetimes in the bounds to the lifetime defs in the generics.
562562
// `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
563563
// `type MyAnonTy<'b> = impl MyTrait<'b>;`

src/librustc_save_analysis/dump_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
13791379
v.visit_expr(&map.body(anon_const.body).value)
13801380
});
13811381
}
1382-
hir::TyKind::Def(item_id, _) => {
1382+
hir::TyKind::OpaqueDef(item_id, _) => {
13831383
let item = self.tcx.hir().item(item_id.id);
13841384
self.nest_tables(self.tcx.hir().local_def_id(item_id.id), |v| v.visit_item(item));
13851385
}

src/librustc_save_analysis/sig.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
324324
let text = format!("[{}; {}]", nested_ty.text, expr);
325325
Ok(replace_text(nested_ty, text))
326326
}
327-
hir::TyKind::Def(item_id, _) => {
327+
hir::TyKind::OpaqueDef(item_id, _) => {
328328
let item = scx.tcx.hir().item(item_id.id);
329329
item.make(offset, Some(item_id.id), scx)
330330
}

src/librustc_typeck/astconv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2838,7 +2838,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28382838
let opt_self_ty = maybe_qself.as_ref().map(|qself| self.ast_ty_to_ty(qself));
28392839
self.res_to_ty(opt_self_ty, path, false)
28402840
}
2841-
hir::TyKind::Def(item_id, ref lifetimes) => {
2841+
hir::TyKind::OpaqueDef(item_id, ref lifetimes) => {
28422842
let opaque_ty = tcx.hir().expect_item(item_id.id);
28432843
let def_id = tcx.hir().local_def_id(item_id.id).to_def_id();
28442844

src/librustc_typeck/check/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14941494
let mut is_object_safe = false;
14951495
if let hir::FnRetTy::Return(ty) = fn_output {
14961496
// Get the return type.
1497-
if let hir::TyKind::Def(..) = ty.kind {
1497+
if let hir::TyKind::OpaqueDef(..) = ty.kind {
14981498
let ty = AstConv::ast_ty_to_ty(fcx, ty);
14991499
// Get the `impl Trait`'s `DefId`.
15001500
if let ty::Opaque(def_id, _) = ty.kind {

src/librustc_typeck/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ fn is_suggestable_infer_ty(ty: &hir::Ty<'_>) -> bool {
14171417
Slice(ty) | Array(ty, _) => is_suggestable_infer_ty(ty),
14181418
Tup(tys) => tys.iter().any(is_suggestable_infer_ty),
14191419
Ptr(mut_ty) | Rptr(_, mut_ty) => is_suggestable_infer_ty(mut_ty.ty),
1420-
Def(_, generic_args) => are_suggestable_generic_args(generic_args),
1420+
OpaqueDef(_, generic_args) => are_suggestable_generic_args(generic_args),
14211421
Path(hir::QPath::TypeRelative(ty, segment)) => {
14221422
is_suggestable_infer_ty(ty) || are_suggestable_generic_args(segment.generic_args().args)
14231423
}

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ impl Clean<Type> for hir::Ty<'_> {
13511351
Array(box ty.clean(cx), length)
13521352
}
13531353
TyKind::Tup(ref tys) => Tuple(tys.clean(cx)),
1354-
TyKind::Def(item_id, _) => {
1354+
TyKind::OpaqueDef(item_id, _) => {
13551355
let item = cx.tcx.hir().expect_item(item_id.id);
13561356
if let hir::ItemKind::OpaqueTy(ref ty) = item.kind {
13571357
ImplTrait(ty.bounds.clean(cx))

0 commit comments

Comments
 (0)