about summary refs log tree commit diff
path: root/compiler/rustc_infer/src/traits/util.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-07 11:18:22 +0000
committerbors <bors@rust-lang.org>2023-05-07 11:18:22 +0000
commit0dddad0dc5d614f799d7e04de4895e7a7418eccb (patch)
treec9d6db616e9b3a2d0259767a10a52f011564b9df /compiler/rustc_infer/src/traits/util.rs
parent8660707bb22b2fa0ef6e2d37c60da20d9cf3d7b9 (diff)
parent76802e31a131d2ac5933b8283a292735b6ab8366 (diff)
downloadrust-0dddad0dc5d614f799d7e04de4895e7a7418eccb.tar.gz
rust-0dddad0dc5d614f799d7e04de4895e7a7418eccb.zip
Auto merge of #111161 - compiler-errors:rtn-super, r=cjgillot
Support return-type bounds on associated methods from supertraits

Support `T: Trait<method(): Bound>` when `method` comes from a supertrait, aligning it with the behavior of associated type bounds (both equality and trait bounds).

The only wrinkle is that I have to extend `super_predicates_that_define_assoc_type` to look for *all* items, not just `AssocKind::Ty`. This will also be needed to support `feature(associated_const_equality)` as well, which is subtly broken when it comes to supertraits, though this PR does not fix those yet. There's a slight chance there's a perf regression here, in which case I guess I could split it out into a separate query.
Diffstat (limited to 'compiler/rustc_infer/src/traits/util.rs')
-rw-r--r--compiler/rustc_infer/src/traits/util.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs
index f54e5e5e56f..74a78f38024 100644
--- a/compiler/rustc_infer/src/traits/util.rs
+++ b/compiler/rustc_infer/src/traits/util.rs
@@ -380,11 +380,11 @@ pub fn transitive_bounds<'tcx>(
 }
 
 /// A specialized variant of `elaborate` that only elaborates trait references that may
-/// define the given associated type `assoc_name`. It uses the
-/// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that
+/// define the given associated item with the name `assoc_name`. It uses the
+/// `super_predicates_that_define_assoc_item` query to avoid enumerating super-predicates that
 /// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or
 /// `T::Item` and helps to avoid cycle errors (see e.g. #35237).
-pub fn transitive_bounds_that_define_assoc_type<'tcx>(
+pub fn transitive_bounds_that_define_assoc_item<'tcx>(
     tcx: TyCtxt<'tcx>,
     bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
     assoc_name: Ident,
@@ -397,7 +397,7 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
             let anon_trait_ref = tcx.anonymize_bound_vars(trait_ref);
             if visited.insert(anon_trait_ref) {
                 let super_predicates =
-                    tcx.super_predicates_that_define_assoc_type((trait_ref.def_id(), assoc_name));
+                    tcx.super_predicates_that_define_assoc_item((trait_ref.def_id(), assoc_name));
                 for (super_predicate, _) in super_predicates.predicates {
                     let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
                     if let Some(binder) = subst_predicate.to_opt_poly_trait_pred() {