-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collect relevant item bounds from trait clauses for nested rigid proj…
…ections
- Loading branch information
1 parent
0af2783
commit fa551a1
Showing
3 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/ui/associated-types/imply-relevant-nested-item-bounds-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// check-pass | ||
// revisions: current next | ||
//[next] compile-flags: -Znext-solver | ||
|
||
trait Trait | ||
where | ||
Self::Assoc: Clone, | ||
{ | ||
type Assoc; | ||
} | ||
|
||
fn foo<T: Trait>(x: &T::Assoc) -> T::Assoc { | ||
x.clone() | ||
} | ||
|
||
trait Trait2 | ||
where | ||
Self::Assoc: Iterator, | ||
<Self::Assoc as Iterator>::Item: Clone, | ||
{ | ||
type Assoc; | ||
} | ||
|
||
fn foo2<T: Trait2>(x: &<T::Assoc as Iterator>::Item) -> <T::Assoc as Iterator>::Item { | ||
x.clone() | ||
} | ||
|
||
fn main() {} |
23 changes: 23 additions & 0 deletions
23
tests/ui/associated-types/imply-relevant-nested-item-bounds.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// check-pass | ||
// revisions: current next | ||
//[next] compile-flags: -Znext-solver | ||
|
||
trait Foo | ||
where | ||
Self::Iterator: Iterator, | ||
<Self::Iterator as Iterator>::Item: Bar, | ||
{ | ||
type Iterator; | ||
|
||
fn iter() -> Self::Iterator; | ||
} | ||
|
||
trait Bar { | ||
fn bar(&self); | ||
} | ||
|
||
fn x<T: Foo>() { | ||
T::iter().next().unwrap().bar(); | ||
} | ||
|
||
fn main() {} |