continue
}
};
- if word.is_scoped() {
+ if let Some(lint_tool) = word.is_scoped() {
if !self.sess.features_untracked().tool_lints {
feature_gate::emit_feature_err(&sess.parse_sess,
"tool_lints",
word.ident));
}
- if !attr::is_known_lint_tool(word) {
+ if !attr::is_known_lint_tool(lint_tool) {
span_err!(
sess,
- word.span,
+ lint_tool.span,
E0710,
- "an unknown tool name found in scoped lint: `{}`.",
+ "an unknown tool name found in scoped lint: `{}`",
word.ident
);
}
RUST_KNOWN_TOOL.contains(&tool_name.as_str().as_ref())
}
-pub fn is_known_lint_tool(m_item: &MetaItem) -> bool {
- let tool_name =
- m_item.ident.segments.iter().next().expect("empty path in meta item").ident.name;
- RUST_KNOWN_LINT_TOOL.contains(&tool_name.as_str().as_ref())
+pub fn is_known_lint_tool(m_item: Ident) -> bool {
+ RUST_KNOWN_LINT_TOOL.contains(&m_item.as_str().as_ref())
}
impl NestedMetaItem {
self.meta_item_list().is_some()
}
- pub fn is_scoped(&self) -> bool {
- self.ident.segments.len() > 1
+ pub fn is_scoped(&self) -> Option<Ident> {
+ if self.ident.segments.len() > 1 {
+ Some(self.ident.segments[0].ident)
+ } else {
+ None
+ }
}
}
#![feature(tool_lints)]
-#![deny(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar`.
+#![deny(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar`
-#[allow(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar`.
+#[allow(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar`
fn main() {}
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(tool_lints)]
+
+#[warn(foo::bar)]
+//~^ ERROR an unknown tool name found in scoped lint: `foo::bar`
+fn main() {}
--- /dev/null
+error[E0710]: an unknown tool name found in scoped lint: `foo::bar`
+ --> $DIR/tool_lints.rs:13:8
+ |
+LL | #[warn(foo::bar)]
+ | ^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0710`.