Skip to content

Commit d53ca63

Browse files
Make sure type_param_predicates resolves correctly for RPITIT
1 parent 298c746 commit d53ca63

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+10
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,16 @@ pub(super) fn type_param_predicates<'tcx>(
764764
tcx: TyCtxt<'tcx>,
765765
(item_def_id, def_id, assoc_name): (LocalDefId, LocalDefId, Ident),
766766
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
767+
match tcx.opt_rpitit_info(item_def_id.to_def_id()) {
768+
Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => {
769+
return tcx.type_param_predicates((opaque_def_id.expect_local(), def_id, assoc_name));
770+
}
771+
Some(ty::ImplTraitInTraitData::Impl { .. }) => {
772+
unreachable!("should not be lowering bounds on RPITIT in impl")
773+
}
774+
None => {}
775+
}
776+
767777
use rustc_hir::*;
768778
use rustc_middle::ty::Ty;
769779

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ check-pass
2+
3+
// Ensure that we can resolve a shorthand projection in an item bound in an RPITIT.
4+
5+
pub trait Bar {
6+
type Foo;
7+
}
8+
9+
pub trait Baz {
10+
fn boom<X: Bar>() -> impl Bar<Foo = X::Foo>;
11+
}
12+
13+
fn main() {}

0 commit comments

Comments
 (0)