2020-02-22 04:53:02 +01: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-22 06:57:31 +01:00
|
|
|
// Also test item kinds in `extern` blocks and associated contexts which are not allowed there.
|
2020-02-22 04:53:02 +01:00
|
|
|
|
|
|
|
fn main() {}
|
|
|
|
|
|
|
|
#[cfg(FALSE)]
|
|
|
|
mod free_items {
|
|
|
|
default extern crate foo; //~ ERROR item cannot be `default`
|
|
|
|
default use foo; //~ ERROR item cannot be `default`
|
|
|
|
default static foo: u8; //~ ERROR item cannot be `default`
|
|
|
|
default const foo: u8; //~ ERROR item cannot be `default`
|
|
|
|
default fn foo(); //~ ERROR item cannot be `default`
|
|
|
|
default mod foo {} //~ ERROR item cannot be `default`
|
|
|
|
default extern "C" {} //~ ERROR item cannot be `default`
|
|
|
|
default type foo = u8; //~ ERROR item cannot be `default`
|
|
|
|
default enum foo {} //~ ERROR item cannot be `default`
|
|
|
|
default struct foo {} //~ ERROR item cannot be `default`
|
|
|
|
default union foo {} //~ ERROR item cannot be `default`
|
|
|
|
default trait foo {} //~ ERROR item cannot be `default`
|
|
|
|
default trait foo = Ord; //~ ERROR item cannot be `default`
|
|
|
|
default impl foo {}
|
|
|
|
default!();
|
|
|
|
default::foo::bar!();
|
2020-02-22 08:55:01 +01:00
|
|
|
default default!(); //~ ERROR item cannot be `default`
|
|
|
|
default default::foo::bar!(); //~ ERROR item cannot be `default`
|
2020-02-22 04:53:02 +01:00
|
|
|
default macro foo {} //~ ERROR item cannot be `default`
|
|
|
|
default macro_rules! foo {} //~ ERROR item cannot be `default`
|
|
|
|
}
|
2020-02-22 06:57:31 +01:00
|
|
|
|
|
|
|
#[cfg(FALSE)]
|
|
|
|
extern "C" {
|
|
|
|
default extern crate foo; //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR extern crate not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default use foo; //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR `use` import not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default static foo: u8; //~ ERROR item cannot be `default`
|
|
|
|
default const foo: u8; //~ ERROR item cannot be `default`
|
|
|
|
//~^ ERROR extern items cannot be `const`
|
|
|
|
default fn foo(); //~ ERROR item cannot be `default`
|
|
|
|
default mod foo {} //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR module not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default extern "C" {} //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR extern block not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default type foo = u8; //~ ERROR item cannot be `default`
|
|
|
|
default enum foo {} //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR enum not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default struct foo {} //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR struct not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default union foo {} //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR union not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default trait foo {} //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR trait not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default trait foo = Ord; //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR trait alias not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default impl foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR implementation not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default!();
|
|
|
|
default::foo::bar!();
|
2020-02-22 08:55:01 +01:00
|
|
|
default default!(); //~ ERROR item cannot be `default`
|
|
|
|
default default::foo::bar!(); //~ ERROR item cannot be `default`
|
2020-02-22 06:57:31 +01:00
|
|
|
default macro foo {} //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR macro definition not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
default macro_rules! foo {} //~ ERROR item cannot be `default`
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR macro definition not supported in `extern` block
|
2020-02-22 06:57:31 +01:00
|
|
|
}
|
2020-02-22 08:16:39 +01:00
|
|
|
|
|
|
|
#[cfg(FALSE)]
|
|
|
|
impl S {
|
|
|
|
default extern crate foo;
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR extern crate not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default use foo;
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR `use` import not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default static foo: u8;
|
|
|
|
//~^ ERROR associated `static` items are not allowed
|
|
|
|
default const foo: u8;
|
|
|
|
default fn foo();
|
|
|
|
default mod foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR module not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default extern "C" {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR extern block not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default type foo = u8;
|
|
|
|
default enum foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR enum not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default struct foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR struct not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default union foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR union not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default trait foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR trait not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default trait foo = Ord;
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR trait alias not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default impl foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR implementation not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default!();
|
|
|
|
default::foo::bar!();
|
2020-02-22 08:55:01 +01:00
|
|
|
default default!();
|
|
|
|
default default::foo::bar!();
|
2020-02-22 08:16:39 +01:00
|
|
|
default macro foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR macro definition not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default macro_rules! foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR macro definition not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(FALSE)]
|
|
|
|
trait T {
|
|
|
|
default extern crate foo;
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR extern crate not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default use foo;
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR `use` import not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default static foo: u8;
|
|
|
|
//~^ ERROR associated `static` items are not allowed
|
|
|
|
default const foo: u8;
|
|
|
|
default fn foo();
|
|
|
|
default mod foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR module not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default extern "C" {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR extern block not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default type foo = u8;
|
|
|
|
default enum foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR enum not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default struct foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR struct not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default union foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR union not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default trait foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR trait not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default trait foo = Ord;
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR trait alias not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default impl foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR implementation not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default!();
|
|
|
|
default::foo::bar!();
|
2020-02-22 08:55:01 +01:00
|
|
|
default default!();
|
|
|
|
default default::foo::bar!();
|
2020-02-22 08:16:39 +01:00
|
|
|
default macro foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR macro definition not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
default macro_rules! foo {}
|
2020-02-23 06:04:37 +01:00
|
|
|
//~^ ERROR macro definition not supported in `trait` or `impl`
|
2020-02-22 08:16:39 +01:00
|
|
|
}
|