Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pnkfelix opened this issue Nov 5, 2018 · 5 comments
Assignees
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Nov 5, 2018

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.

@pnkfelix pnkfelix 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 Nov 5, 2018
@memoryruins
Copy link
Contributor

cc #55596

@pnkfelix pnkfelix added A-testsuite Area: The testsuite used to check the correctness of rustc P-high High priority labels Nov 8, 2018
@Centril Centril added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 23, 2020
@pnkfelix
Copy link
Member Author

pnkfelix commented May 6, 2020

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

@pnkfelix
Copy link
Member Author

pnkfelix commented May 6, 2020

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

@pnkfelix pnkfelix self-assigned this May 6, 2020
@osa1
Copy link
Contributor

osa1 commented Feb 1, 2021

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.

@pnkfelix
Copy link
Member Author

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

@tmiasko tmiasko closed this as completed Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants