-
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.
- Loading branch information
1 parent
af24d0b
commit e2fc2a1
Showing
9 changed files
with
207 additions
and
11 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
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
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
52 changes: 52 additions & 0 deletions
52
tests/ui/associated-type-bounds/return-type-notation/higher-ranked-bound-works.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,52 @@ | ||
//@ check-pass | ||
|
||
#![feature(return_type_notation)] | ||
//~^ WARN the feature `return_type_notation` is incomplete | ||
|
||
trait Trait<'a> { | ||
fn late<'b>(&'b self, _: &'a ()) -> impl Sized; | ||
fn early<'b: 'b>(&'b self, _: &'a ()) -> impl Sized; | ||
} | ||
|
||
#[allow(refining_impl_trait_internal)] | ||
impl<'a> Trait<'a> for () { | ||
fn late<'b>(&'b self, _: &'a ()) -> i32 { 1 } | ||
fn early<'b: 'b>(&'b self, _: &'a ()) -> i32 { 1 } | ||
} | ||
|
||
trait Other<'c> {} | ||
impl Other<'_> for i32 {} | ||
|
||
fn test<T>(t: &T) | ||
where | ||
T: for<'a, 'c> Trait<'a, late(..): Other<'c>>, | ||
// which is basically: | ||
// for<'a, 'c> Trait<'a, for<'b> method<'b>: Other<'c>>, | ||
T: for<'a, 'c> Trait<'a, early(..): Other<'c>>, | ||
// which is basically: | ||
// for<'a, 'c> Trait<'a, for<'b> method<'b>: Other<'c>>, | ||
{ | ||
is_other_impl(t.late(&())); | ||
is_other_impl(t.early(&())); | ||
} | ||
|
||
fn test_path<T>(t: &T) | ||
where | ||
T: for<'a> Trait<'a>, | ||
for<'a, 'c> <T as Trait<'a>>::late(..): Other<'c>, | ||
// which is basically: | ||
// for<'a, 'b, 'c> <T as Trait<'a>>::method::<'b>: Other<'c> | ||
for<'a, 'c> <T as Trait<'a>>::early(..): Other<'c>, | ||
// which is basically: | ||
// for<'a, 'b, 'c> <T as Trait<'a>>::method::<'b>: Other<'c> | ||
{ | ||
is_other_impl(t.late(&())); | ||
is_other_impl(t.early(&())); | ||
} | ||
|
||
fn is_other_impl(_: impl for<'c> Other<'c>) {} | ||
|
||
fn main() { | ||
test(&()); | ||
test(&()); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui/associated-type-bounds/return-type-notation/higher-ranked-bound-works.stderr
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,11 @@ | ||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/higher-ranked-bound-works.rs:3:12 | ||
| | ||
LL | #![feature(return_type_notation)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #109417 </~https://github.com/rust-lang/rust/issues/109417> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
42 changes: 42 additions & 0 deletions
42
tests/ui/associated-type-bounds/return-type-notation/namespace-conflict.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,42 @@ | ||
//@ check-pass | ||
|
||
#![allow(non_camel_case_types)] | ||
#![feature(return_type_notation)] | ||
//~^ WARN the feature `return_type_notation` is incomplete | ||
|
||
trait Foo { | ||
type test; | ||
|
||
fn test() -> impl Bar; | ||
} | ||
|
||
fn call_path<T: Foo>() | ||
where | ||
T::test(..): Bar, | ||
{ | ||
} | ||
|
||
fn call_bound<T: Foo<test(..): Bar>>() {} | ||
|
||
trait Bar {} | ||
struct NotBar; | ||
struct YesBar; | ||
impl Bar for YesBar {} | ||
|
||
impl Foo for () { | ||
type test = NotBar; | ||
|
||
// Use refinement here so we can observe `YesBar: Bar`. | ||
#[allow(refining_impl_trait_internal)] | ||
fn test() -> YesBar { | ||
YesBar | ||
} | ||
} | ||
|
||
fn main() { | ||
// If `T::test(..)` resolved to the GAT (erroneously), then this would be | ||
// an error since `<() as Foo>::bar` -- the associated type -- does not | ||
// implement `Bar`, but the return type of the method does. | ||
call_path::<()>(); | ||
call_bound::<()>(); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui/associated-type-bounds/return-type-notation/namespace-conflict.stderr
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,11 @@ | ||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/namespace-conflict.rs:4:12 | ||
| | ||
LL | #![feature(return_type_notation)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #109417 </~https://github.com/rust-lang/rust/issues/109417> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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
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