Skip to content

diagnostically note source of overruling outer forbid #34251

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

Merged
merged 1 commit into from
Jul 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use dep_graph::DepNode;
use middle::privacy::AccessLevels;
use ty::TyCtxt;
use session::{config, early_error, Session};
use lint::{Level, LevelSource, Lint, LintId, LintPass};
use lint::{Level, LevelSource, Lint, LintId, LintPass, LintSource};
use lint::{EarlyLintPassObject, LateLintPassObject};
use lint::{Default, CommandLine, Node, Allow, Warn, Deny, Forbid};
use lint::builtin;
Expand Down Expand Up @@ -599,13 +599,23 @@ pub trait LintContext: Sized {
};

for (lint_id, level, span) in v {
let now = self.lints().get_level_source(lint_id).0;
let (now, now_source) = self.lints().get_level_source(lint_id);
if now == Forbid && level != Forbid {
let lint_name = lint_id.as_str();
span_err!(self.sess(), span, E0453,
"{}({}) overruled by outer forbid({})",
level.as_str(), lint_name,
lint_name);
let mut diag_builder = struct_span_err!(self.sess(), span, E0453,
"{}({}) overruled by outer forbid({})",
level.as_str(), lint_name,
lint_name);
match now_source {
LintSource::Default => &mut diag_builder,
LintSource::Node(forbid_source_span) => {
diag_builder.span_note(forbid_source_span,
"`forbid` lint level set here")
},
LintSource::CommandLine => {
diag_builder.note("`forbid` lint level was set on command line")
}
}.emit()
} else if now != level {
let src = self.lints().get_level_source(lint_id).1;
self.level_stack().push((lint_id, (now, src)));
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail-fulldeps/lint-plugin-forbid-attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#![feature(plugin)]
#![plugin(lint_plugin_test)]
#![forbid(test_lint)]
//~^ NOTE lint level defined here
//~| NOTE `forbid` lint level set here

fn lintme() { } //~ ERROR item is named 'lintme'

Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/lint-forbid-attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#![forbid(deprecated)]
//~^ NOTE `forbid` lint level set here

#[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated)
fn main() {
Expand Down