Skip to content

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

@brson

Description

@brson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions