diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-09-22 12:15:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-22 12:15:27 +0200 |
| commit | fc4cfe01f6b0f0117e285b1349be17ff393bbcd4 (patch) | |
| tree | fef7693eee4d7d58ea121178bf12117f92d59a20 /compiler | |
| parent | faf13dd112bf0f455e5311cb1acc9db514defe78 (diff) | |
| parent | f2ede49c2f9da8c64782abbec3b4a1710d52a4c5 (diff) | |
| download | rust-fc4cfe01f6b0f0117e285b1349be17ff393bbcd4.tar.gz rust-fc4cfe01f6b0f0117e285b1349be17ff393bbcd4.zip | |
Rollup merge of #116039 - estebank:nested-tait, r=compiler-errors
Account for nested `impl Trait` in TAIT Fix #116031. r? `@compiler-errors`
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs index 957a6bb3481..0544c5ca866 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs @@ -1,7 +1,7 @@ use rustc_errors::StashKey; use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{self as hir, Expr, ImplItem, Item, Node, TraitItem}; +use rustc_hir::{self as hir, def, Expr, ImplItem, Item, Node, TraitItem}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::DUMMY_SP; @@ -74,9 +74,14 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local hidden.ty } else { + let mut parent_def_id = def_id; + while tcx.def_kind(parent_def_id) == def::DefKind::OpaqueTy { + // Account for `type Alias = impl Trait<Foo = impl Trait>;` (#116031) + parent_def_id = tcx.local_parent(parent_def_id); + } let reported = tcx.sess.emit_err(UnconstrainedOpaqueType { span: tcx.def_span(def_id), - name: tcx.item_name(tcx.local_parent(def_id).to_def_id()), + name: tcx.item_name(parent_def_id.to_def_id()), what: match tcx.hir().get(scope) { _ if scope == hir::CRATE_HIR_ID => "module", Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module", |
