diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-09-24 07:38:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-24 07:38:56 +0200 |
| commit | a842357d37b0c043ccfeccc568cbf597d217d887 (patch) | |
| tree | cd92dea12863ab674aad2493f8f382576e9cbcfc /compiler | |
| parent | 9a4fe30fff6ab2009f3cfed639eac0da64368f73 (diff) | |
| parent | 79c665b2a321f7d7a8826139171092baa42b0b56 (diff) | |
| download | rust-a842357d37b0c043ccfeccc568cbf597d217d887.tar.gz rust-a842357d37b0c043ccfeccc568cbf597d217d887.zip | |
Rollup merge of #102152 - compiler-errors:issue-102140, r=fee1-dead
Calculate `ProjectionTy::trait_def_id` for return-position `impl Trait` in trait correctly Fixes #102140
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/ty/sty.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index e773b3032aa..258fb2e2f9f 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1133,9 +1133,13 @@ pub struct ProjectionTy<'tcx> { impl<'tcx> ProjectionTy<'tcx> { pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId { - let parent = tcx.parent(self.item_def_id); - assert_eq!(tcx.def_kind(parent), DefKind::Trait); - parent + match tcx.def_kind(self.item_def_id) { + DefKind::AssocTy | DefKind::AssocConst => tcx.parent(self.item_def_id), + DefKind::ImplTraitPlaceholder => { + tcx.parent(tcx.impl_trait_in_trait_parent(self.item_def_id)) + } + kind => bug!("unexpected DefKind in ProjectionTy: {kind:?}"), + } } /// Extracts the underlying trait reference and own substs from this projection. |
