add tests

This commit is contained in:
b-naber 2020-11-21 15:44:06 +01:00 committed by b-naber
parent 37d103f3cf
commit 5c4568d08b
35 changed files with 346 additions and 32 deletions

View File

@ -0,0 +1,11 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete
trait X {
type Y<'a>;
}
fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {}
//~^ ERROR: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
fn main() {}

View File

@ -0,0 +1,17 @@
error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
--> $DIR/trait-path-expected-token.rs:8:33
|
LL | fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {}
| ^ expected one of 7 possible tokens
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/trait-path-expected-token.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: aborting due to previous error; 1 warning emitted

View File

@ -0,0 +1,23 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete
mod error1 {
trait X {
type Y<'a>;
}
fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {}
//~^ ERROR: expected expression, found `)`
}
mod error2 {
trait X {
type Y<'a>;
}
fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {}
//~^ ERROR: only types can be used in associated type constraints
}
fn main() {}

View File

@ -0,0 +1,25 @@
error: expected expression, found `)`
--> $DIR/trait-path-expressions.rs:9:39
|
LL | fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {}
| - ^ expected expression
| |
| while parsing a const generic argument starting here
error: only types can be used in associated type constraints
--> $DIR/trait-path-expressions.rs:19:30
|
LL | fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {}
| ^^^^^
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/trait-path-expressions.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: aborting due to 2 previous errors; 1 warning emitted

View File

@ -0,0 +1,21 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete
trait X {
type Y<'a>;
}
const _: () = {
fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
//~^ ERROR: expected one of `>`, const, lifetime, or type, found `:`
//~| ERROR: expected parameter name, found `>`
//~| ERROR: expected one of `!`, `)`, `+`, `,`, or `::`, found `>`
//~| ERROR: constant provided when a type was expected
};
const _: () = {
fn f1<'a>(arg : Box<dyn X< = 32 >>) {}
//~^ ERROR: expected one of `>`, const, lifetime, or type, found `=`
};
fn main() {}

View File

@ -0,0 +1,50 @@
error: expected one of `>`, const, lifetime, or type, found `:`
--> $DIR/trait-path-missing-gen_arg.rs:9:30
|
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
| ^ expected one of `>`, const, lifetime, or type
|
help: expressions must be enclosed in braces to be used as const generic arguments
|
LL | fn f1<'a>(arg : Box<{ dyn X< : 32 } >>) {}
| ^ ^
error: expected parameter name, found `>`
--> $DIR/trait-path-missing-gen_arg.rs:9:36
|
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
| ^ expected parameter name
error: expected one of `!`, `)`, `+`, `,`, or `::`, found `>`
--> $DIR/trait-path-missing-gen_arg.rs:9:36
|
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
| ^
| |
| expected one of `!`, `)`, `+`, `,`, or `::`
| help: missing `,`
error: expected one of `>`, const, lifetime, or type, found `=`
--> $DIR/trait-path-missing-gen_arg.rs:17:30
|
LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {}
| ^ expected one of `>`, const, lifetime, or type
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/trait-path-missing-gen_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[E0747]: constant provided when a type was expected
--> $DIR/trait-path-missing-gen_arg.rs:9:23
|
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
| ^^^^^^^^^^^
error: aborting due to 5 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0747`.

View File

@ -0,0 +1,35 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete
const _: () = {
trait X {
type Y<'a>;
}
fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {}
//~^ ERROR: paths with multiple segments cannot be used in associated type constraints
};
const _: () = {
trait X {
type Y<'a>;
}
trait Z {}
impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {}
//~^ ERROR: qualified paths cannot be used in associated type constraints
};
const _: () = {
trait X {
type Y<'a>;
}
trait Z {}
impl<T : X<X::Y<'a> = &'a u32>> Z for T {}
//~^ ERROR: paths with multiple segments cannot be used in associated type constraints
};
fn main() {}

View File

@ -0,0 +1,31 @@
error: paths with multiple segments cannot be used in associated type constraints
--> $DIR/trait-path-segments.rs:9:31
|
LL | fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {}
| ^^^^
error: qualified paths cannot be used in associated type constraints
--> $DIR/trait-path-segments.rs:20:16
|
LL | impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {}
| ^^^^^^^^^-^^^^^^^^
| |
| not allowed in associated type constraints
error: paths with multiple segments cannot be used in associated type constraints
--> $DIR/trait-path-segments.rs:31:16
|
LL | impl<T : X<X::Y<'a> = &'a u32>> Z for T {}
| ^^^^^^^^
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/trait-path-segments.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: aborting due to 3 previous errors; 1 warning emitted

View File

@ -0,0 +1,10 @@
#![feature(generic_associated_types)]
trait X {
type Y<'a>;
}
const _: () = {
fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
//~^ ERROR: generic associated types in trait paths are currently not implemented
};

View File

@ -0,0 +1,8 @@
error: generic associated types in trait paths are currently not implemented
--> $DIR/trait-path-type-error-once-implemented.rs:8:30
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^
error: aborting due to previous error

View File

@ -0,0 +1,23 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete
trait X {
type Y<'a>;
}
const _: () = {
fn f<'a>(arg : Box<dyn X< [u8; 1] = u32>>) {}
//~^ ERROR: only path types can be used in associated type constraints
};
const _: () = {
fn f1<'a>(arg : Box<dyn X<(Y<'a>) = &'a ()>>) {}
//~^ ERROR: only path types can be used in associated type constraints
};
const _: () = {
fn f1<'a>(arg : Box<dyn X< 'a = u32 >>) {}
//~^ ERROR: only types can be used in associated type constraints
};
fn main() {}

View File

@ -0,0 +1,29 @@
error: only path types can be used in associated type constraints
--> $DIR/trait-path-types.rs:9:29
|
LL | fn f<'a>(arg : Box<dyn X< [u8; 1] = u32>>) {}
| ^^^^^^^
error: only path types can be used in associated type constraints
--> $DIR/trait-path-types.rs:14:29
|
LL | fn f1<'a>(arg : Box<dyn X<(Y<'a>) = &'a ()>>) {}
| ^^^^^^^
error: only types can be used in associated type constraints
--> $DIR/trait-path-types.rs:19:30
|
LL | fn f1<'a>(arg : Box<dyn X< 'a = u32 >>) {}
| ^^
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/trait-path-types.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: aborting due to 3 previous errors; 1 warning emitted

View File

@ -0,0 +1,17 @@
#![feature(generic_associated_types)]
trait X {
type Y<'a>;
}
const _: () = {
fn f1<'a>(arg : Box<dyn X<Y<'a> = &'a ()>>) {}
//~^ ERROR: generic associated types in trait paths are currently not implemented
};
const _: () = {
fn f1<'a>(arg : Box<dyn X<Y('a) = &'a ()>>) {}
//~^ ERROR: lifetime in trait object type must be followed by `+`
};
fn main() {}

View File

@ -0,0 +1,14 @@
error: lifetime in trait object type must be followed by `+`
--> $DIR/trait-path-unimplemented.rs:13:31
|
LL | fn f1<'a>(arg : Box<dyn X<Y('a) = &'a ()>>) {}
| ^^
error: generic associated types in trait paths are currently not implemented
--> $DIR/trait-path-unimplemented.rs:8:30
|
LL | fn f1<'a>(arg : Box<dyn X<Y<'a> = &'a ()>>) {}
| ^^^^
error: aborting due to 2 previous errors

View File

@ -9,7 +9,7 @@ type Type_1_<'a, T> = &'a T;
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,` or `>`, found `(`
type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,`, `:`, `=`, or `>`, found `(`
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`

View File

@ -1,8 +1,8 @@
error: expected one of `,` or `>`, found `(`
error: expected one of `,`, `:`, `=`, or `>`, found `(`
--> $DIR/issue-20616-2.rs:12:31
|
LL | type Type_2 = Type_1_<'static ()>;
| ^ expected one of `,` or `>`
| ^ expected one of `,`, `:`, `=`, or `>`
error: aborting due to previous error

View File

@ -11,7 +11,7 @@ type Type_1_<'a, T> = &'a T;
type Type_3<T> = Box<T,,>;
//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
//~^ error: expected one of `>`, const, lifetime, or type, found `,`
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`

View File

@ -1,8 +1,8 @@
error: expected one of `>`, const, identifier, lifetime, or type, found `,`
error: expected one of `>`, const, lifetime, or type, found `,`
--> $DIR/issue-20616-3.rs:13:24
|
LL | type Type_3<T> = Box<T,,>;
| ^ expected one of `>`, const, identifier, lifetime, or type
| ^ expected one of `>`, const, lifetime, or type
error: aborting due to previous error

View File

@ -14,7 +14,7 @@ type Type_1_<'a, T> = &'a T;
type Type_4<T> = Type_1_<'static,, T>;
//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
//~^ error: expected one of `>`, const, lifetime, or type, found `,`
type Type_5_<'a> = Type_1_<'a, ()>;

View File

@ -1,8 +1,8 @@
error: expected one of `>`, const, identifier, lifetime, or type, found `,`
error: expected one of `>`, const, lifetime, or type, found `,`
--> $DIR/issue-20616-4.rs:16:34
|
LL | type Type_4<T> = Type_1_<'static,, T>;
| ^ expected one of `>`, const, identifier, lifetime, or type
| ^ expected one of `>`, const, lifetime, or type
error: aborting due to previous error

View File

@ -20,7 +20,7 @@ type Type_5_<'a> = Type_1_<'a, ()>;
type Type_5<'a> = Type_1_<'a, (),,>;
//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
//~^ error: expected one of `>`, const, lifetime, or type, found `,`
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`

View File

@ -1,8 +1,8 @@
error: expected one of `>`, const, identifier, lifetime, or type, found `,`
error: expected one of `>`, const, lifetime, or type, found `,`
--> $DIR/issue-20616-5.rs:22:34
|
LL | type Type_5<'a> = Type_1_<'a, (),,>;
| ^ expected one of `>`, const, identifier, lifetime, or type
| ^ expected one of `>`, const, lifetime, or type
error: aborting due to previous error

View File

@ -23,7 +23,7 @@ type Type_5_<'a> = Type_1_<'a, ()>;
type Type_6 = Type_5_<'a,,>;
//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
//~^ error: expected one of `>`, const, lifetime, or type, found `,`
//type Type_7 = Box<(),,>; // error: expected type, found `,`

View File

@ -1,8 +1,8 @@
error: expected one of `>`, const, identifier, lifetime, or type, found `,`
error: expected one of `>`, const, lifetime, or type, found `,`
--> $DIR/issue-20616-6.rs:25:26
|
LL | type Type_6 = Type_5_<'a,,>;
| ^ expected one of `>`, const, identifier, lifetime, or type
| ^ expected one of `>`, const, lifetime, or type
error: aborting due to previous error

View File

@ -26,7 +26,7 @@ type Type_5_<'a> = Type_1_<'a, ()>;
type Type_7 = Box<(),,>;
//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
//~^ error: expected one of `>`, const, lifetime, or type, found `,`
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`

View File

@ -1,8 +1,8 @@
error: expected one of `>`, const, identifier, lifetime, or type, found `,`
error: expected one of `>`, const, lifetime, or type, found `,`
--> $DIR/issue-20616-7.rs:28:22
|
LL | type Type_7 = Box<(),,>;
| ^ expected one of `>`, const, identifier, lifetime, or type
| ^ expected one of `>`, const, lifetime, or type
error: aborting due to previous error

View File

@ -1,6 +1,6 @@
fn main () {
let sr: Vec<(u32, _, _) = vec![];
//~^ ERROR expected one of `,` or `>`, found `=`
//~^ ERROR only path types can be used in associated type constraints
let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect();
//~^ ERROR a value of type `Vec<(u32, _, _)>` cannot be built
}

View File

@ -1,8 +1,8 @@
error: expected one of `,` or `>`, found `=`
--> $DIR/issue-34334.rs:2:29
error: only path types can be used in associated type constraints
--> $DIR/issue-34334.rs:2:17
|
LL | let sr: Vec<(u32, _, _) = vec![];
| -- ^ expected one of `,` or `>`
| -- ^^^^^^^^^^^
| |
| while parsing the type for `sr`

View File

@ -5,7 +5,7 @@ struct Foo;
impl Foo {
pub fn foo(_: i32, self: Box<Self) {}
//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)`
//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `)`
}
fn main() {}

View File

@ -1,8 +1,8 @@
error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)`
error: expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `)`
--> $DIR/issue-62660.rs:7:38
|
LL | pub fn foo(_: i32, self: Box<Self) {}
| ^ expected one of 7 possible tokens
| ^ expected one of 9 possible tokens
error: aborting due to previous error

View File

@ -12,7 +12,7 @@ error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `;`
LL | impl W <s(f;Y(;]
| ^ expected one of 7 possible tokens
error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `->`, `...`, `::`, `<`, `>`, `?`, `[`, `_`, `async`, `const`, `dyn`, `extern`, `fn`, `for`, `impl`, `unsafe`, lifetime, or path, found `;`
error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `->`, `...`, `::`, `:`, `<`, `=`, `>`, `?`, `[`, `_`, `async`, `const`, `dyn`, `extern`, `fn`, `for`, `impl`, `unsafe`, lifetime, or path, found `;`
--> $DIR/issue-63116.rs:3:15
|
LL | impl W <s(f;Y(;]

View File

@ -3,6 +3,6 @@ struct Foo<'a, 'b> {
}
fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {}
//~^ ERROR expected one of `,` or `>`, found `;`
//~^ ERROR expected one of `,`, `:`, `=`, or `>`, found `;`
fn main() {}

View File

@ -1,8 +1,8 @@
error: expected one of `,` or `>`, found `;`
error: expected one of `,`, `:`, `=`, or `>`, found `;`
--> $DIR/lifetime-semicolon.rs:5:30
|
LL | fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {}
| ^ expected one of `,` or `>`
| ^ expected one of `,`, `:`, `=`, or `>`
error: aborting due to previous error

View File

@ -1,2 +1,2 @@
type closure = Box<lt/fn()>;
//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/`
//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `/`

View File

@ -1,8 +1,8 @@
error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/`
error: expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `/`
--> $DIR/removed-syntax-closure-lifetime.rs:1:22
|
LL | type closure = Box<lt/fn()>;
| ^ expected one of 7 possible tokens
| ^ expected one of 9 possible tokens
error: aborting due to previous error