forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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, GATs
- Loading branch information
1 parent
b511753
commit 2dacf7a
Showing
4 changed files
with
286 additions
and
10 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() {} |
19 changes: 19 additions & 0 deletions
19
tests/ui/associated-types/imply-relevant-nested-item-bounds-for-gat.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,19 @@ | ||
//@ check-pass | ||
|
||
// Test that `for<'a> Self::Gat<'a>: Debug` is implied in the definition of `Foo`, | ||
// just as it would be if it weren't a GAT but just a regular associated type. | ||
|
||
use std::fmt::Debug; | ||
|
||
trait Foo | ||
where | ||
for<'a> Self::Gat<'a>: Debug, | ||
{ | ||
type Gat<'a>; | ||
} | ||
|
||
fn test<T: Foo>(x: T::Gat<'static>) { | ||
println!("{:?}", x); | ||
} | ||
|
||
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() {} |