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