-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
548929d
commit 7a63d3f
Showing
2 changed files
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// check-pass | ||
|
||
#![feature(associated_type_bounds)] | ||
|
||
trait A<'a> { | ||
type Assoc: ?Sized; | ||
} | ||
|
||
impl<'a> A<'a> for () { | ||
type Assoc = &'a (); | ||
} | ||
|
||
fn hello() -> impl for<'a> A<'a, Assoc: Sized> { | ||
() | ||
} | ||
|
||
fn main() {} |
37 changes: 37 additions & 0 deletions
37
tests/ui/associated-type-bounds/nested-bounds-dont-eliminate-alias-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,37 @@ | ||
// check-pass | ||
|
||
#![feature(associated_type_bounds)] | ||
|
||
trait Trait1 { | ||
type Assoc1: Bar; | ||
|
||
fn assoc(self) -> Self::Assoc1; | ||
} | ||
|
||
impl Trait1 for () { | ||
type Assoc1 = (); | ||
fn assoc(self) {} | ||
} | ||
|
||
trait Foo {} | ||
impl Foo for () {} | ||
trait Bar {} | ||
impl Bar for () {} | ||
|
||
fn hello() -> impl Trait1<Assoc1: Foo> { | ||
() | ||
} | ||
|
||
fn world() { | ||
// Tests that `Assoc1: Foo` bound in the RPIT doesn't disqualify | ||
// the `Assoc1: Bar` bound in the item, as a nested RPIT desugaring | ||
// would do. | ||
|
||
fn is_foo(_: impl Foo) {} | ||
is_foo(hello().assoc()); | ||
|
||
fn is_bar(_: impl Bar) {} | ||
is_bar(hello().assoc()); | ||
} | ||
|
||
fn main() {} |