|
1 | 1 | use rustc_errors::StashKey;
|
2 | 2 | use rustc_hir::def_id::LocalDefId;
|
3 | 3 | use rustc_hir::intravisit::{self, Visitor};
|
4 |
| -use rustc_hir::{self as hir, Expr, ImplItem, Item, Node, TraitItem}; |
| 4 | +use rustc_hir::{self as hir, def, Expr, ImplItem, Item, Node, TraitItem}; |
5 | 5 | use rustc_middle::hir::nested_filter;
|
6 | 6 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
|
7 | 7 | use rustc_span::DUMMY_SP;
|
@@ -74,9 +74,14 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
|
74 | 74 |
|
75 | 75 | hidden.ty
|
76 | 76 | } else {
|
| 77 | + let mut parent_def_id = def_id; |
| 78 | + while tcx.def_kind(parent_def_id) == def::DefKind::OpaqueTy { |
| 79 | + // Account for `type Alias = impl Trait<Foo = impl Trait>;` (#116031) |
| 80 | + parent_def_id = tcx.local_parent(parent_def_id); |
| 81 | + } |
77 | 82 | let reported = tcx.sess.emit_err(UnconstrainedOpaqueType {
|
78 | 83 | span: tcx.def_span(def_id),
|
79 |
| - name: tcx.item_name(tcx.local_parent(def_id).to_def_id()), |
| 84 | + name: tcx.item_name(parent_def_id.to_def_id()), |
80 | 85 | what: match tcx.hir().get(scope) {
|
81 | 86 | _ if scope == hir::CRATE_HIR_ID => "module",
|
82 | 87 | Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",
|
|
0 commit comments