Skip to content

compiletest does not signal when a ui (or compile-fail) test with //~ WARN gets unexpected warnings #55693

Description

@pnkfelix

In compiletest, a test that has a //~ WARN ... comment will not tell you if other undocumented warnings were also emitted.

If I recall correctly, we have a policy that if a test has annotations of the form //~ KIND (where KIND is one of ERROR/WARN/HELP/INFO`, then we will check that the set of annotations of that form properly matches what the compiler is emitting.

But it looks like we only actually follow the above policy completely for KIND == ERROR, not the others.

Activity

  1. changed the title [-]compiletest does not signal when a ui test with `//~ WARN` gets unexpected warnings[/-] [+]compiletest does not signal when a ui (or compile-fail) test with `//~ WARN` gets unexpected warnings[/+] on Nov 5, 2018
  2. memoryruins commented on Nov 5, 2018

    @memoryruins
    Contributor
  3. added
    A-testsuiteArea: The testsuite used to check the correctness of rustc
    P-highHigh priority
    on Nov 8, 2018
  4. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 23, 2020
  5. pnkfelix commented on May 6, 2020

    @pnkfelix
    ContributorAuthor

    Is this actually still a problem, given that #55596 has been resolved by PR #66213?

  6. pnkfelix commented on May 6, 2020

    @pnkfelix
    ContributorAuthor

    assigning to self to follow-up and determine if this is even a problem at this point.

  7. self-assigned this
    on May 6, 2020
  8. osa1 commented on Feb 1, 2021

    @osa1
    Contributor

    I think this is fixed now. To check, I created this file in src/test/ui/issue-55693.rs:

    // check-pass
    
    #[warn(unused_variables)]
    #[warn(non_snake_case)]
    
    fn main() {
        let unused: usize = 123;
        let WEIRD: usize = 456;
    }
    

    I first run this with --bless which created an .stderr file, with expected contents.

    Then added //~WARN in the first let. It failed with

    unexpected errors (from JSON output): [
        Error {
            line_num: 8,
            kind: Some(
                Warning,
            ),
            msg: "8:9: 8:14: unused variable: `WEIRD` [unused_variables]",
        },
        Error {
            line_num: 8,
            kind: Some(
                Warning,
            ),
            msg: "8:9: 8:14: variable `WEIRD` should have a snake case name [non_snake_case]",
        },
    ]
    

    So it seems like we now expect the //~WARN lines to match the compiler generated warnings.

  9. pnkfelix commented on Jan 28, 2022

    @pnkfelix
    ContributorAuthor

    closing as fixed! Thanks @osa1 for looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-testsuiteArea: The testsuite used to check the correctness of rustcP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions