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