2017-07-23 22:06:16 +07:00
|
|
|
// Test successful and unsuccessful parsing of the `default` contextual keyword
|
2015-12-18 14:38:28 -08:00
|
|
|
|
2019-01-06 18:33:05 +03:00
|
|
|
#![feature(specialization)]
|
2020-06-16 10:06:35 +02:00
|
|
|
//~^ WARN the feature `specialization` is incomplete
|
2019-01-06 18:33:05 +03:00
|
|
|
|
2015-12-18 14:38:28 -08:00
|
|
|
trait Foo {
|
|
|
|
fn foo<T: Default>() -> T;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for u8 {
|
|
|
|
default fn foo<T: Default>() -> T {
|
|
|
|
T::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for u16 {
|
2023-04-03 22:28:55 -05:00
|
|
|
pub default fn foo<T: Default>() -> T { //~ ERROR visibility qualifiers are not permitted here
|
2015-12-18 14:38:28 -08:00
|
|
|
T::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-06 18:33:05 +03:00
|
|
|
impl Foo for u32 { //~ ERROR not all trait items implemented, missing: `foo`
|
2020-02-01 06:18:10 +01:00
|
|
|
default pub fn foo<T: Default>() -> T { T::default() }
|
2020-02-23 12:54:00 +01:00
|
|
|
//~^ ERROR `default` is not followed by an item
|
2020-02-22 08:16:39 +01:00
|
|
|
//~| ERROR non-item in item list
|
2015-12-18 14:38:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|