forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
35 changed files
with
897 additions
and
37 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.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,12 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
trait X { | ||
type Y<'x>; | ||
} | ||
|
||
fn main() { | ||
fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {} | ||
//~^ ERROR: use of undeclared lifetime name `'x` | ||
//~| ERROR: binding for associated type `Y` references lifetime | ||
} |
29 changes: 29 additions & 0 deletions
29
src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.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,29 @@ | ||
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:1:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
error[E0261]: use of undeclared lifetime name `'x` | ||
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:35 | ||
| | ||
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {} | ||
| - ^^ undeclared lifetime | ||
| | | ||
| help: consider introducing lifetime `'x` here: `<'x>` | ||
| | ||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes | ||
|
||
error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types | ||
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:33 | ||
| | ||
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {} | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
||
Some errors have detailed explanations: E0261, E0582. | ||
For more information about an error, try `rustc --explain E0261`. |
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,30 @@ | ||
// check-pass | ||
|
||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
#![feature(associated_type_defaults)] | ||
|
||
trait Foo { | ||
type A<'a> where Self: 'a; | ||
} | ||
|
||
struct Fooy; | ||
|
||
impl Foo for Fooy { | ||
type A<'a> = &'a (); | ||
} | ||
|
||
#[derive(Clone)] | ||
struct Fooer<T>(T); | ||
|
||
impl<T> Foo for Fooer<T> { | ||
type A<'x> where T: 'x = &'x (); | ||
} | ||
|
||
fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {} | ||
|
||
|
||
fn main() { | ||
let foo = Fooer(5); | ||
f(Box::new(foo)); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/generic-associated-types/gat-in-trait-path.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 `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/gat-in-trait-path.rs:3:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
warning: 1 warning emitted | ||
|
16 changes: 16 additions & 0 deletions
16
src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.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,16 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
trait Foo { | ||
type F<'a>; | ||
|
||
fn identity<'a>(t: &'a Self::F<'a>) -> &'a Self::F<'a> { t } | ||
} | ||
|
||
impl <T, T1> Foo for T { | ||
type F<T1> = &[u8]; | ||
//~^ ERROR: the name `T1` is already used for | ||
//~| ERROR: missing lifetime specifier | ||
} | ||
|
||
fn main() {} |
32 changes: 32 additions & 0 deletions
32
src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.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,32 @@ | ||
error[E0403]: the name `T1` is already used for a generic parameter in this item's generic parameters | ||
--> $DIR/gat-trait-path-generic-type-arg.rs:11:12 | ||
| | ||
LL | impl <T, T1> Foo for T { | ||
| -- first use of `T1` | ||
LL | type F<T1> = &[u8]; | ||
| ^^ already used | ||
|
||
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/gat-trait-path-generic-type-arg.rs:1:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
error[E0106]: missing lifetime specifier | ||
--> $DIR/gat-trait-path-generic-type-arg.rs:11:18 | ||
| | ||
LL | type F<T1> = &[u8]; | ||
| ^ expected named lifetime parameter | ||
| | ||
help: consider introducing a named lifetime parameter | ||
| | ||
LL | type F<'a, T1> = &'a [u8]; | ||
| ^^^ ^^^ | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
||
Some errors have detailed explanations: E0106, E0403. | ||
For more information about an error, try `rustc --explain E0106`. |
18 changes: 18 additions & 0 deletions
18
src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.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,18 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
trait X { | ||
type Y<'a>; | ||
//~^ ERROR missing generics for | ||
//~| ERROR missing generics for | ||
|
||
fn foo<'a>(t : Self::Y<'a>) -> Self::Y<'a> { t } | ||
} | ||
|
||
impl<T> X for T { | ||
fn foo<'a, T1: X<Y = T1>>(t : T1) -> T1::Y<'a> { | ||
t | ||
} | ||
} | ||
|
||
fn main() {} |
44 changes: 44 additions & 0 deletions
44
src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.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,44 @@ | ||
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/gat-trait-path-missing-lifetime.rs:1:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
error[E0107]: missing generics for associated type `X::Y` | ||
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8 | ||
| | ||
LL | type Y<'a>; | ||
| ^ expected 1 lifetime argument | ||
| | ||
note: associated type defined here, with 1 lifetime parameter: `'a` | ||
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8 | ||
| | ||
LL | type Y<'a>; | ||
| ^ -- | ||
help: use angle brackets to add missing lifetime argument | ||
| | ||
LL | type Y<'a><'a>; | ||
| ^^^^ | ||
|
||
error[E0107]: missing generics for associated type `X::Y` | ||
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8 | ||
| | ||
LL | type Y<'a>; | ||
| ^ expected 1 lifetime argument | ||
| | ||
note: associated type defined here, with 1 lifetime parameter: `'a` | ||
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8 | ||
| | ||
LL | type Y<'a>; | ||
| ^ -- | ||
help: use angle brackets to add missing lifetime argument | ||
| | ||
LL | type Y<'a><'a>; | ||
| ^^^^ | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0107`. |
15 changes: 15 additions & 0 deletions
15
src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.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,15 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
trait X { | ||
type Y<'a>; | ||
//~^ ERROR this associated type | ||
//~| ERROR this associated type | ||
} | ||
|
||
fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {} | ||
//~^ ERROR: lifetime in trait object type must be followed by `+` | ||
//~| ERROR: parenthesized generic arguments cannot be used | ||
//~| WARNING: trait objects without an explicit `dyn` are deprecated | ||
|
||
fn main() {} |
68 changes: 68 additions & 0 deletions
68
src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.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,68 @@ | ||
error: lifetime in trait object type must be followed by `+` | ||
--> $DIR/gat-trait-path-parenthesised-args.rs:10:29 | ||
| | ||
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {} | ||
| ^^ | ||
|
||
error: parenthesized generic arguments cannot be used in associated type constraints | ||
--> $DIR/gat-trait-path-parenthesised-args.rs:10:27 | ||
| | ||
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {} | ||
| ^^^^^ | ||
|
||
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/gat-trait-path-parenthesised-args.rs:1:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/gat-trait-path-parenthesised-args.rs:10:29 | ||
| | ||
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {} | ||
| ^^ help: use `dyn`: `dyn 'a` | ||
| | ||
= note: `#[warn(bare_trait_objects)]` on by default | ||
|
||
error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied | ||
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8 | ||
| | ||
LL | type Y<'a>; | ||
| ^ expected 1 lifetime argument | ||
| | ||
note: associated type defined here, with 1 lifetime parameter: `'a` | ||
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8 | ||
| | ||
LL | type Y<'a>; | ||
| ^ -- | ||
help: add missing lifetime argument | ||
| | ||
LL | fn foo<'a>(arg: Box<dyn X<Y('a'a) = &'a ()>>) {} | ||
| ^^ | ||
|
||
error[E0107]: this associated type takes 0 type arguments but 1 type argument was supplied | ||
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8 | ||
| | ||
LL | type Y<'a>; | ||
| ________^- | ||
| | | | ||
| | expected 0 type arguments | ||
LL | | | ||
LL | | | ||
LL | | } | ||
LL | | | ||
LL | | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {} | ||
| |_________________________________________- help: remove these generics | ||
| | ||
note: associated type defined here, with 0 type parameters | ||
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8 | ||
| | ||
LL | type Y<'a>; | ||
| ^ | ||
|
||
error: aborting due to 4 previous errors; 2 warnings emitted | ||
|
||
For more information about this error, try `rustc --explain E0107`. |
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,12 @@ | ||
// check-pass | ||
|
||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/generic-associated-types/issue-67510-pass.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 `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/issue-67510-pass.rs:3:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {} | ||
//~^ ERROR: use of undeclared lifetime name `'a` | ||
//~| ERROR: use of undeclared lifetime name `'a` | ||
|
||
|
||
fn main() {} |
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,32 @@ | ||
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/issue-67510.rs:1:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
error[E0261]: use of undeclared lifetime name `'a` | ||
--> $DIR/issue-67510.rs:8:21 | ||
| | ||
LL | fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {} | ||
| - ^^ undeclared lifetime | ||
| | | ||
| help: consider introducing lifetime `'a` here: `<'a>` | ||
| | ||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes | ||
|
||
error[E0261]: use of undeclared lifetime name `'a` | ||
--> $DIR/issue-67510.rs:8:26 | ||
| | ||
LL | fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {} | ||
| - ^^ undeclared lifetime | ||
| | | ||
| help: consider introducing lifetime `'a` here: `<'a>` | ||
| | ||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0261`. |
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,26 @@ | ||
// check-pass | ||
|
||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
|
||
trait Fun { | ||
type F<'a>; | ||
|
||
fn identity<'a>(t: Self::F<'a>) -> Self::F<'a> { t } | ||
} | ||
|
||
impl <T> Fun for T { | ||
type F<'a> = Self; | ||
} | ||
|
||
fn bug<'a, T: for<'b> Fun<F<'b> = T>>(t: T) -> T::F<'a> { | ||
T::identity(t) | ||
} | ||
|
||
|
||
fn main() { | ||
let x = 10; | ||
|
||
bug(x); | ||
} |
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 `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/issue-68648-1.rs:3:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
warning: 1 warning emitted | ||
|
Oops, something went wrong.