Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Trait inheritance with cycles on associated types #79209

Merged
merged 28 commits into from
Nov 29, 2020
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
24dcf6f
Allow to use super trait bounds in where clauses
spastorino Nov 3, 2020
2ca4964
Allow to self reference associated types in where clauses
spastorino Nov 13, 2020
4406805
Update tests
spastorino Nov 17, 2020
4a97c52
Add test to check that we do not get a cycle due to resolving `Self::…
nikomatsakis Nov 14, 2020
5b6f206
Fix super_traits_of to consider where bounds
spastorino Nov 19, 2020
3c8cf6d
Avoid ICEing when associated type bound trait is missing
spastorino Nov 19, 2020
a6d2235
Add test for a still ambiguous scenario
spastorino Nov 20, 2020
f76d6e0
Add description on test
spastorino Nov 20, 2020
aa1cafd
Add `` to variable name in docs
spastorino Nov 20, 2020
30e933c
Extract trait_may_define_assoc_type helper function
spastorino Nov 20, 2020
6631215
Remove unneeded logic
spastorino Nov 20, 2020
b60a214
super_traits_of is now a query
spastorino Nov 21, 2020
c0007a2
Extract function trait_may_define_assoc_type
spastorino Nov 21, 2020
dd267fe
compute_bounds takes &[GenericBound]
spastorino Nov 21, 2020
6ab8fe2
Bless tests
spastorino Nov 21, 2020
b916ac6
adjust super_predicates_that_define_assoc_type query description
spastorino Nov 22, 2020
af38d71
Add super_traits_of docs
spastorino Nov 22, 2020
a175f36
Document compute_bounds_that_match_assoc_type
spastorino Nov 24, 2020
9e0538b
Document elaborate_trait_refs_that_define_assoc_type
spastorino Nov 24, 2020
28446ef
Inline elaborate_trait_refs_that_define_assoc_type into transitive_bo…
spastorino Nov 24, 2020
ac1845a
Fix super_predicates_that_define_assoc_type API doc
spastorino Nov 24, 2020
1895e52
Fix super_traits_of API doc
spastorino Nov 24, 2020
67ea9b2
Make super_traits_of return Lrc for cheaper clone
spastorino Nov 24, 2020
b02a905
Add test to check that we handle predicates that can define assoc typ…
spastorino Nov 25, 2020
a6136d8
Simplify super_traits_of
spastorino Nov 25, 2020
35bf466
Remove super_traits_of query, just leave a helper function
spastorino Nov 25, 2020
504d27c
Make super_traits_of return an iterator
spastorino Nov 25, 2020
ada7c1f
Return FxIndexSet instead of FxHashSet to avoid order errors on diffe…
spastorino Nov 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/rustc_infer/src/traits/util.rs
Original file line number Diff line number Diff line change
@@ -90,6 +90,11 @@ pub fn elaborate_trait_refs<'tcx>(
elaborate_predicates(tcx, predicates)
}

/// A specialized variant of `elaborate_trait_refs` 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
/// 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 elaborate_trait_refs_that_define_assoc_type<'tcx>(
tcx: TyCtxt<'tcx>,
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,