-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 1de894f
Showing
11 changed files
with
298 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
42 changes: 42 additions & 0 deletions
42
tests/ui/associated-type-bounds/return-type-notation/not-a-method.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 @@ | ||
#![feature(return_type_notation)] | ||
//~^ WARN the feature `return_type_notation` is incomplete | ||
|
||
fn function() {} | ||
|
||
fn not_a_method() | ||
where | ||
function(..): Send, | ||
//~^ ERROR expected function, found function `function` | ||
//~| ERROR return type notation not allowed in this position yet | ||
{ | ||
} | ||
|
||
fn not_a_method_and_typoed() | ||
where | ||
function(): Send, | ||
//~^ ERROR expected type, found function `function` | ||
{ | ||
} | ||
|
||
trait Tr { | ||
fn method(); | ||
} | ||
|
||
// Forgot the `T::` | ||
fn maybe_method_overlaps<T: Tr>() | ||
where | ||
method(..): Send, | ||
//~^ ERROR cannot find function `method` in this scope | ||
//~| ERROR return type notation not allowed in this position yet | ||
{ | ||
} | ||
|
||
// Forgot the `T::`, AND typoed `(..)` to `()` | ||
fn maybe_method_overlaps_and_typoed<T: Tr>() | ||
where | ||
method(): Send, | ||
//~^ ERROR cannot find type `method` in this scope | ||
{ | ||
} | ||
|
||
fn main() {} |
49 changes: 49 additions & 0 deletions
49
tests/ui/associated-type-bounds/return-type-notation/not-a-method.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,49 @@ | ||
error[E0575]: expected function, found function `function` | ||
--> $DIR/not-a-method.rs:8:5 | ||
| | ||
LL | function(..): Send, | ||
| ^^^^^^^^^^^^ not a function | ||
|
||
error[E0573]: expected type, found function `function` | ||
--> $DIR/not-a-method.rs:16:5 | ||
| | ||
LL | function(): Send, | ||
| ^^^^^^^^^^ not a type | ||
|
||
error[E0576]: cannot find function `method` in this scope | ||
--> $DIR/not-a-method.rs:28:5 | ||
| | ||
LL | method(..): Send, | ||
| ^^^^^^ not found in this scope | ||
|
||
error[E0412]: cannot find type `method` in this scope | ||
--> $DIR/not-a-method.rs:37:5 | ||
| | ||
LL | method(): Send, | ||
| ^^^^^^ not found in this scope | ||
|
||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/not-a-method.rs:1: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 | ||
|
||
error: return type notation not allowed in this position yet | ||
--> $DIR/not-a-method.rs:8:5 | ||
| | ||
LL | function(..): Send, | ||
| ^^^^^^^^^^^^ | ||
|
||
error: return type notation not allowed in this position yet | ||
--> $DIR/not-a-method.rs:28:5 | ||
| | ||
LL | method(..): Send, | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to 6 previous errors; 1 warning emitted | ||
|
||
Some errors have detailed explanations: E0412, E0573, E0575, E0576. | ||
For more information about an error, try `rustc --explain E0412`. |