2020-02-21 21:53:02 -06:00
|
|
|
// Test parsing for `default` where it doesn't belong.
|
|
|
|
// Specifically, we are interested in kinds of items or items in certain contexts.
|
2020-02-21 23:57:31 -06:00
|
|
|
// Also test item kinds in `extern` blocks and associated contexts which are not allowed there.
|
2020-02-21 21:53:02 -06:00
|
|
|
|
|
|
|
fn main() {}
|
|
|
|
|
|
|
|
#[cfg(FALSE)]
|
|
|
|
mod free_items {
|
2020-02-23 03:24:30 -06:00
|
|
|
default extern crate foo; //~ ERROR an extern crate cannot be `default`
|
|
|
|
default use foo; //~ ERROR a `use` import cannot be `default`
|
|
|
|
default static foo: u8; //~ ERROR a static item cannot be `default`
|
|
|
|
default const foo: u8;
|
|
|
|
default fn foo();
|
|
|
|
default mod foo {} //~ ERROR a module cannot be `default`
|
|
|
|
default extern "C" {} //~ ERROR an extern block cannot be `default`
|
|
|
|
default type foo = u8;
|
|
|
|
default enum foo {} //~ ERROR an enum cannot be `default`
|
|
|
|
default struct foo {} //~ ERROR a struct cannot be `default`
|
|
|
|
default union foo {} //~ ERROR a union cannot be `default`
|
|
|
|
default trait foo {} //~ ERROR a trait cannot be `default`
|
|
|
|
default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
|
2020-02-21 21:53:02 -06:00
|
|
|
default impl foo {}
|
|
|
|
default!();
|
|
|
|
default::foo::bar!();
|
2020-02-23 03:24:30 -06:00
|
|
|
default default!(); //~ ERROR an item macro invocation cannot be `default`
|
|
|
|
default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
|
|
|
|
default macro foo {} //~ ERROR a macro definition cannot be `default`
|
|
|
|
default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
|
2020-02-21 21:53:02 -06:00
|
|
|
}
|
2020-02-21 23:57:31 -06:00
|
|
|
|
|
|
|
#[cfg(FALSE)]
|
|
|
|
extern "C" {
|
2020-02-23 03:24:30 -06:00
|
|
|
default extern crate foo; //~ ERROR an extern crate cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR extern crate not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default use foo; //~ ERROR a `use` import cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR `use` import not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default static foo: u8; //~ ERROR a static item cannot be `default`
|
|
|
|
default const foo: u8;
|
2020-02-21 23:57:31 -06:00
|
|
|
//~^ ERROR extern items cannot be `const`
|
2020-02-23 03:24:30 -06:00
|
|
|
default fn foo();
|
|
|
|
default mod foo {} //~ ERROR a module cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR module not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default extern "C" {} //~ ERROR an extern block cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR extern block not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default type foo = u8;
|
|
|
|
default enum foo {} //~ ERROR an enum cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR enum not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default struct foo {} //~ ERROR a struct cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR struct not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default union foo {} //~ ERROR a union cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR union not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default trait foo {} //~ ERROR a trait cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR trait not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR trait alias not supported in `extern` block
|
2020-02-21 23:57:31 -06:00
|
|
|
default impl foo {}
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR implementation not supported in `extern` block
|
2020-02-21 23:57:31 -06:00
|
|
|
default!();
|
|
|
|
default::foo::bar!();
|
2020-02-23 03:24:30 -06:00
|
|
|
default default!(); //~ ERROR an item macro invocation cannot be `default`
|
|
|
|
default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
|
|
|
|
default macro foo {} //~ ERROR a macro definition cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR macro definition not supported in `extern` block
|
2020-02-23 03:24:30 -06:00
|
|
|
default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR macro definition not supported in `extern` block
|
2020-02-21 23:57:31 -06:00
|
|
|
}
|
2020-02-22 01:16:39 -06:00
|
|
|
|
|
|
|
#[cfg(FALSE)]
|
|
|
|
impl S {
|
2020-02-23 03:24:30 -06:00
|
|
|
default extern crate foo; //~ ERROR an extern crate cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR extern crate not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default use foo; //~ ERROR a `use` import cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR `use` import not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default static foo: u8; //~ ERROR a static item cannot be `default`
|
2020-02-22 01:16:39 -06:00
|
|
|
//~^ ERROR associated `static` items are not allowed
|
|
|
|
default const foo: u8;
|
|
|
|
default fn foo();
|
2020-02-23 03:24:30 -06:00
|
|
|
default mod foo {}//~ ERROR a module cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR module not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default extern "C" {} //~ ERROR an extern block cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR extern block not supported in `trait` or `impl`
|
2020-02-22 01:16:39 -06:00
|
|
|
default type foo = u8;
|
2020-02-23 03:24:30 -06:00
|
|
|
default enum foo {} //~ ERROR an enum cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR enum not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default struct foo {} //~ ERROR a struct cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR struct not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default union foo {} //~ ERROR a union cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR union not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default trait foo {} //~ ERROR a trait cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR trait not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR trait alias not supported in `trait` or `impl`
|
2020-02-22 01:16:39 -06:00
|
|
|
default impl foo {}
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR implementation not supported in `trait` or `impl`
|
2020-02-22 01:16:39 -06:00
|
|
|
default!();
|
|
|
|
default::foo::bar!();
|
2020-02-23 03:24:30 -06:00
|
|
|
default default!(); //~ ERROR an item macro invocation cannot be `default`
|
|
|
|
default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
|
|
|
|
default macro foo {} //~ ERROR a macro definition cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR macro definition not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR macro definition not supported in `trait` or `impl`
|
2020-02-22 01:16:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(FALSE)]
|
|
|
|
trait T {
|
2020-02-23 03:24:30 -06:00
|
|
|
default extern crate foo; //~ ERROR an extern crate cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR extern crate not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default use foo; //~ ERROR a `use` import cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR `use` import not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default static foo: u8; //~ ERROR a static item cannot be `default`
|
2020-02-22 01:16:39 -06:00
|
|
|
//~^ ERROR associated `static` items are not allowed
|
|
|
|
default const foo: u8;
|
|
|
|
default fn foo();
|
2020-02-23 03:24:30 -06:00
|
|
|
default mod foo {}//~ ERROR a module cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR module not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default extern "C" {} //~ ERROR an extern block cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR extern block not supported in `trait` or `impl`
|
2020-02-22 01:16:39 -06:00
|
|
|
default type foo = u8;
|
2020-02-23 03:24:30 -06:00
|
|
|
default enum foo {} //~ ERROR an enum cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR enum not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default struct foo {} //~ ERROR a struct cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR struct not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default union foo {} //~ ERROR a union cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR union not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default trait foo {} //~ ERROR a trait cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR trait not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR trait alias not supported in `trait` or `impl`
|
2020-02-22 01:16:39 -06:00
|
|
|
default impl foo {}
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR implementation not supported in `trait` or `impl`
|
2020-02-22 01:16:39 -06:00
|
|
|
default!();
|
|
|
|
default::foo::bar!();
|
2020-02-23 03:24:30 -06:00
|
|
|
default default!(); //~ ERROR an item macro invocation cannot be `default`
|
|
|
|
default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
|
|
|
|
default macro foo {} //~ ERROR a macro definition cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR macro definition not supported in `trait` or `impl`
|
2020-02-23 03:24:30 -06:00
|
|
|
default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
|
2020-02-22 23:04:37 -06:00
|
|
|
//~^ ERROR macro definition not supported in `trait` or `impl`
|
2020-02-22 01:16:39 -06:00
|
|
|
}
|