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

profusion of redundant "overruled by outer forbid" messages #42873

Closed
zackmdavis opened this issue Jun 24, 2017 · 0 comments
Closed

profusion of redundant "overruled by outer forbid" messages #42873

zackmdavis opened this issue Jun 24, 2017 · 0 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@zackmdavis
Copy link
Member

Consider this (erroneous) program:

#![forbid(unused)]

#[allow(unused)]
fn main() {
    println!("hello forbidden world");
}

As we expect, this fails to compile, because the outer "forbid" attribute contradicts the "allow" attribute. ("Forbid" is like "deny" except that it prevents itself from being subsequently overridden.) However, the error messages leave something to be desired:

$ rustc --version
rustc 1.18.0 (03fc9d622 2017-06-06)
$ rustc scratch.rs 
error[E0453]: allow(unused_imports) overruled by outer forbid(unused_imports)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(unused_variables) overruled by outer forbid(unused_variables)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(unused_assignments) overruled by outer forbid(unused_assignments)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(dead_code) overruled by outer forbid(dead_code)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(unused_mut) overruled by outer forbid(unused_mut)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(unreachable_code) overruled by outer forbid(unreachable_code)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(unreachable_patterns) overruled by outer forbid(unreachable_patterns)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(unused_must_use) overruled by outer forbid(unused_must_use)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(unused_unsafe) overruled by outer forbid(unused_unsafe)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(path_statements) overruled by outer forbid(path_statements)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error[E0453]: allow(unused_attributes) overruled by outer forbid(unused_attributes)
 --> /home/ubuntu/rust/scratch.rs:3:9
  |
1 | #![forbid(unused)]
  |           ------ `forbid` level set here
2 | 
3 | #[allow(unused)]
  |         ^^^^^^ overruled by previous forbid

error: aborting due to 11 previous errors

We get a separate error for each lint in the "unused" lint group! This is kind of terrible! We would prefer to get a single error for the contradicting attributes, whose message names the offending attributes (it's weird to say "overruled by outer forbid(path_statements)", when the outer forbid is for unused, not path_statements).

A fix by the present author is forthcoming.

zackmdavis added a commit to zackmdavis/rust that referenced this issue Jun 24, 2017
Previously, conflicting forbid/allow attributes for a lint group would
result in a separate "allow(L) overruled by outer forbid(L)" error for
every lint L in the group. This was needlessly and annoyingly verbose;
we prefer to just have one error pointing out the conflicting
attributes.

Resolves rust-lang#42873.
@Mark-Simulacrum Mark-Simulacrum added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 24, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Jun 27, 2017
…bid, r=nikomatsakis

only set "overruled by outer forbid" once for lint groups, by group name

Previously, conflicting forbid/allow attributes for a lint group would
result in a separate "allow(L) overruled by outer forbid(L)" error for
every lint L in the group. This was needlessly and annoyingly verbose;
we prefer to just have one error pointing out the conflicting
attributes.

(Also, while we're touching context.rs, clean up some unused arguments.)

Resolves rust-lang#42873.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. 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

2 participants