File: force_warn_expected_lints_unfulfilled.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (47 lines) | stat: -rw-r--r-- 1,636 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//@ compile-flags: --force-warn while_true
//@ compile-flags: --force-warn unused_variables
//@ compile-flags: --force-warn unused_mut
//@ check-pass

fn expect_early_pass_lint(terminate: bool) {
    #[expect(while_true)]
    //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
    //~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default
    while !terminate {
        println!("Do you know what a spin lock is?")
    }
}

#[expect(unused_variables, reason="<this should fail and display this reason>")]
//~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
//~| NOTE <this should fail and display this reason>
fn check_specific_lint() {
    let _x = 2;
}

#[expect(unused)]
//~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
fn check_multiple_lints_with_lint_group() {
    let fox_name = "Sir Nibbles";

    let what_does_the_fox_say = "*ding* *deng* *dung*";

    println!("The fox says: {what_does_the_fox_say}");
    println!("~ {fox_name}")
}


#[expect(unused)]
//~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
fn check_overridden_expectation_lint_level() {
    #[allow(unused_variables)]
    let this_should_not_fulfill_the_expectation = "maybe";
    //~^ WARNING unused variable: `this_should_not_fulfill_the_expectation` [unused_variables]
    //~| NOTE requested on the command line with `--force-warn unused-variables`
    //~| HELP if this is intentional, prefix it with an underscore
}

fn main() {
    check_multiple_lints_with_lint_group();
    check_overridden_expectation_lint_level();
}