2024-06-19 02:09:56 +00:00
|
|
|
#![feature(coverage_attribute)]
|
|
|
|
//@ edition: 2021
|
|
|
|
|
|
|
|
// Demonstrates the diagnostics produced when using the syntax `#[coverage]`,
|
|
|
|
// which should not be allowed.
|
|
|
|
//
|
|
|
|
// The syntax is tested both in places that can have a coverage attribute,
|
|
|
|
// and in places that cannot have a coverage attribute, to demonstrate the
|
|
|
|
// interaction between multiple errors.
|
|
|
|
|
|
|
|
#[coverage]
|
2024-06-20 08:13:48 +00:00
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
2024-06-19 02:09:56 +00:00
|
|
|
mod my_mod {}
|
|
|
|
|
|
|
|
mod my_mod_inner {
|
|
|
|
#![coverage]
|
2024-06-20 08:13:48 +00:00
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
2024-06-19 02:09:56 +00:00
|
|
|
}
|
|
|
|
|
2024-06-20 08:13:48 +00:00
|
|
|
#[coverage]
|
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
|
|
|
//~| ERROR attribute should be applied to a function definition or closure
|
2024-06-19 02:09:56 +00:00
|
|
|
struct MyStruct;
|
|
|
|
|
|
|
|
#[coverage]
|
2024-06-20 08:13:48 +00:00
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
2024-06-19 02:09:56 +00:00
|
|
|
impl MyStruct {
|
2024-06-20 08:13:48 +00:00
|
|
|
#[coverage]
|
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
|
|
|
//~| ERROR attribute should be applied to a function definition or closure
|
2024-06-19 02:09:56 +00:00
|
|
|
const X: u32 = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[coverage]
|
2024-06-20 08:13:48 +00:00
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
|
|
|
//~| ERROR attribute should be applied to a function definition or closure
|
2024-06-19 02:09:56 +00:00
|
|
|
trait MyTrait {
|
2024-06-20 08:13:48 +00:00
|
|
|
#[coverage]
|
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
|
|
|
//~| ERROR attribute should be applied to a function definition or closure
|
2024-06-19 02:09:56 +00:00
|
|
|
const X: u32;
|
|
|
|
|
2024-06-20 08:13:48 +00:00
|
|
|
#[coverage]
|
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
|
|
|
//~| ERROR attribute should be applied to a function definition or closure
|
2024-06-19 02:09:56 +00:00
|
|
|
type T;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[coverage]
|
2024-06-20 08:13:48 +00:00
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
2024-06-19 02:09:56 +00:00
|
|
|
impl MyTrait for MyStruct {
|
2024-06-20 08:13:48 +00:00
|
|
|
#[coverage]
|
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
|
|
|
//~| ERROR attribute should be applied to a function definition or closure
|
2024-06-19 02:09:56 +00:00
|
|
|
const X: u32 = 8;
|
|
|
|
|
2024-06-20 08:13:48 +00:00
|
|
|
#[coverage]
|
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
|
|
|
//~| ERROR attribute should be applied to a function definition or closure
|
2024-06-19 02:09:56 +00:00
|
|
|
type T = ();
|
|
|
|
}
|
|
|
|
|
2024-06-20 08:13:48 +00:00
|
|
|
#[coverage]
|
|
|
|
//~^ ERROR malformed `coverage` attribute input
|
2024-06-19 02:09:56 +00:00
|
|
|
fn main() {}
|