diff options
| author | Michael Goulet <michael@errs.io> | 2024-10-30 22:30:28 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-10-30 22:30:28 +0000 |
| commit | d53ca634532d548ad30cb75af3f93030f1b415f4 (patch) | |
| tree | 00e98286acc51942f204703597a64f6c0d89eb09 | |
| parent | 298c7462c3bf66d0afd39284cb65ec78a787a594 (diff) | |
| download | rust-d53ca634532d548ad30cb75af3f93030f1b415f4.tar.gz rust-d53ca634532d548ad30cb75af3f93030f1b415f4.zip | |
Make sure type_param_predicates resolves correctly for RPITIT
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect/predicates_of.rs | 10 | ||||
| -rw-r--r-- | tests/ui/impl-trait/in-trait/shorthand-projection-in-rpitit-bound.rs | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 644ff0c667c..4cdf0fc545c 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -764,6 +764,16 @@ pub(super) fn type_param_predicates<'tcx>( tcx: TyCtxt<'tcx>, (item_def_id, def_id, assoc_name): (LocalDefId, LocalDefId, Ident), ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { + match tcx.opt_rpitit_info(item_def_id.to_def_id()) { + Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => { + return tcx.type_param_predicates((opaque_def_id.expect_local(), def_id, assoc_name)); + } + Some(ty::ImplTraitInTraitData::Impl { .. }) => { + unreachable!("should not be lowering bounds on RPITIT in impl") + } + None => {} + } + use rustc_hir::*; use rustc_middle::ty::Ty; diff --git a/tests/ui/impl-trait/in-trait/shorthand-projection-in-rpitit-bound.rs b/tests/ui/impl-trait/in-trait/shorthand-projection-in-rpitit-bound.rs new file mode 100644 index 00000000000..102b53f4957 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/shorthand-projection-in-rpitit-bound.rs @@ -0,0 +1,13 @@ +//@ check-pass + +// Ensure that we can resolve a shorthand projection in an item bound in an RPITIT. + +pub trait Bar { + type Foo; +} + +pub trait Baz { + fn boom<X: Bar>() -> impl Bar<Foo = X::Foo>; +} + +fn main() {} |
