2024-06-18 08:18:15 +00:00
|
|
|
#![feature(coverage_attribute)]
|
|
|
|
|
|
|
|
// Tests the error messages produced (or not produced) by various unusual
|
|
|
|
// uses of the `#[coverage(..)]` attribute.
|
|
|
|
|
2024-06-19 02:09:56 +00:00
|
|
|
// FIXME(#126658): Multiple coverage attributes with the same value are useless,
|
2024-06-18 08:18:15 +00:00
|
|
|
// and should probably produce a diagnostic.
|
|
|
|
#[coverage(off)]
|
|
|
|
#[coverage(off)]
|
|
|
|
fn multiple_consistent() {}
|
|
|
|
|
2024-06-19 02:09:56 +00:00
|
|
|
// FIXME(#126658): When there are multiple inconsistent coverage attributes,
|
2024-06-18 08:18:15 +00:00
|
|
|
// it's unclear which one will prevail.
|
|
|
|
#[coverage(off)]
|
|
|
|
#[coverage(on)]
|
|
|
|
fn multiple_inconsistent() {}
|
|
|
|
|
|
|
|
#[coverage] //~ ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
fn bare_word() {}
|
|
|
|
|
2024-06-19 02:09:56 +00:00
|
|
|
// FIXME(#126658): This shows as multiple different errors, one of which suggests
|
2024-06-18 08:18:15 +00:00
|
|
|
// writing bare `#[coverage]`, which is not allowed.
|
|
|
|
#[coverage = true]
|
|
|
|
//~^ ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
//~| ERROR malformed `coverage` attribute input
|
|
|
|
//~| HELP the following are the possible correct uses
|
|
|
|
//~| SUGGESTION #[coverage(on|off)]
|
|
|
|
fn key_value() {}
|
|
|
|
|
|
|
|
#[coverage()] //~ ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
fn list_empty() {}
|
|
|
|
|
|
|
|
#[coverage(off, off)] //~ ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
fn list_consistent() {}
|
|
|
|
|
|
|
|
#[coverage(off, on)] //~ ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
fn list_inconsistent() {}
|
|
|
|
|
|
|
|
#[coverage(bogus)] //~ ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
fn bogus_word() {}
|
|
|
|
|
|
|
|
#[coverage(bogus, off)] //~ ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
fn bogus_word_before() {}
|
|
|
|
|
|
|
|
#[coverage(off, bogus)] //~ ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
fn bogus_word_after() {}
|
|
|
|
|
|
|
|
#[coverage(off,)]
|
|
|
|
fn comma_after() {}
|
|
|
|
|
2024-06-19 02:09:56 +00:00
|
|
|
// FIXME(#126658): This shows as multiple different errors.
|
2024-06-18 08:18:15 +00:00
|
|
|
#[coverage(,off)]
|
|
|
|
//~^ ERROR expected identifier, found `,`
|
|
|
|
//~| HELP remove this comma
|
|
|
|
//~| ERROR expected `coverage(off)` or `coverage(on)`
|
|
|
|
fn comma_before() {}
|
|
|
|
|
|
|
|
fn main() {}
|