rust/tests/ui/coverage-attr/allowed-positions.rs

63 lines
1.8 KiB
Rust
Raw Normal View History

//! Tests where the `#[coverage(..)]` attribute can and cannot be used.
//@ reference: attributes.coverage.allowed-positions
#![feature(coverage_attribute)]
#![feature(extern_types)]
#![feature(impl_trait_in_assoc_type)]
#![warn(unused_attributes)]
#![coverage(off)]
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
trait Trait {
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
const X: u32;
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
type T;
type U;
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
fn f(&self);
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
fn g();
}
#[coverage(off)]
impl Trait for () {
const X: u32 = 0;
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
type T = Self;
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
type U = impl Trait; //~ ERROR unconstrained opaque type
fn f(&self) {}
fn g() {}
}
extern "C" {
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
static X: u32;
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
type T;
}
2023-08-09 14:57:16 +00:00
#[coverage(off)]
fn main() {
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
let _ = ();
match () {
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
() => (),
}
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
return ();
}