Skip to content

#[deny(warnings)] does not change the lint source, produces confusing error #30730

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

Closed
brson opened this issue Jan 6, 2016 · 2 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@brson
Copy link
Contributor

brson commented Jan 6, 2016

Normally, an unused import:

use std::thread;
fn main() { }

Produces this compiler output:

linttest.rs:4:5: 4:16 warning: unused import, #[warn(unused_imports)] on by default
linttest.rs:4 use std::thread;

Saying the 'unused_imports' lint is 'on by default'.

If you explicitly set that lint to deny:

#![deny(unused_imports)]
use std::thread;
fn main() { }

Then the error indicates where the lint was set to 'deny':

linttest.rs:4:5: 4:16 error: unused import
linttest.rs:4 use std::thread;
                  ^~~~~~~~~~~
linttest.rs:1:9: 1:23 note: lint level defined here
linttest.rs:1 #![deny(unused_imports)]
                      ^~~~~~~~~~~~~~
error: aborting due to previous error

If you instead change warnings to errors:

#![deny(warnings)]
use std::thread;
fn main() { }

Then you get this error:

linttest.rs:4:5: 4:16 error: unused import, #[deny(unused_imports)] on by default
linttest.rs:4 use std::thread;
                  ^~~~~~~~~~~
error: aborting due to previous error

Which says 'deny(unused_imports)' is 'on by default'. That is not true. unused_imports is warn by default. This case should point to #[deny(warnings)] as the source of the error.

Discovered while interpreting all the lint regressions in a recent crater report.

cc @nikomatsakis

@brson brson added the A-diagnostics Area: Messages for errors, warnings, and lints label Jan 6, 2016
shssoichiro pushed a commit to shssoichiro/rust that referenced this issue Jan 9, 2016
@shssoichiro
Copy link
Contributor

I took a shot at this and made a PR. Now your example code for deny(warnings) shows the following:

test_deny.rs:2:5: 2:16 error: unused import
test_deny.rs:2 use std::thread;
                   ^~~~~~~~~~~
test_deny.rs:1:9: 1:17 note: lint level defined here
test_deny.rs:1 #![deny(warnings)]
                       ^~~~~~~~
error: aborting due to previous error

shssoichiro added a commit to shssoichiro/rust that referenced this issue Jan 12, 2016
bors added a commit that referenced this issue Mar 9, 2016
Show clearer error message when #![deny(warnings)] escalates a warning

Addresses #30730
@sanxiyn
Copy link
Member

sanxiyn commented Mar 23, 2016

This was fixed by #30804.

@sanxiyn sanxiyn closed this as completed Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants