File tree Expand file tree Collapse file tree 5 files changed +38
-12
lines changed Expand file tree Collapse file tree 5 files changed +38
-12
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ impl<'a> LintLevelsBuilder<'a> {
222222 continue
223223 }
224224 } ;
225- if word. is_scoped ( ) {
225+ if let Some ( lint_tool ) = word. is_scoped ( ) {
226226 if !self . sess . features_untracked ( ) . tool_lints {
227227 feature_gate:: emit_feature_err ( & sess. parse_sess ,
228228 "tool_lints" ,
@@ -232,12 +232,12 @@ impl<'a> LintLevelsBuilder<'a> {
232232 word. ident) ) ;
233233 }
234234
235- if !attr:: is_known_lint_tool ( word ) {
235+ if !attr:: is_known_lint_tool ( lint_tool ) {
236236 span_err ! (
237237 sess,
238- word . span,
238+ lint_tool . span,
239239 E0710 ,
240- "an unknown tool name found in scoped lint: `{}`. " ,
240+ "an unknown tool name found in scoped lint: `{}`" ,
241241 word. ident
242242 ) ;
243243 }
Original file line number Diff line number Diff line change @@ -98,10 +98,8 @@ pub fn is_known_tool(attr: &Attribute) -> bool {
9898 RUST_KNOWN_TOOL . contains ( & tool_name. as_str ( ) . as_ref ( ) )
9999}
100100
101- pub fn is_known_lint_tool ( m_item : & MetaItem ) -> bool {
102- let tool_name =
103- m_item. ident . segments . iter ( ) . next ( ) . expect ( "empty path in meta item" ) . ident . name ;
104- RUST_KNOWN_LINT_TOOL . contains ( & tool_name. as_str ( ) . as_ref ( ) )
101+ pub fn is_known_lint_tool ( m_item : Ident ) -> bool {
102+ RUST_KNOWN_LINT_TOOL . contains ( & m_item. as_str ( ) . as_ref ( ) )
105103}
106104
107105impl NestedMetaItem {
@@ -298,8 +296,12 @@ impl MetaItem {
298296 self . meta_item_list ( ) . is_some ( )
299297 }
300298
301- pub fn is_scoped ( & self ) -> bool {
302- self . ident . segments . len ( ) > 1
299+ pub fn is_scoped ( & self ) -> Option < Ident > {
300+ if self . ident . segments . len ( ) > 1 {
301+ Some ( self . ident . segments [ 0 ] . ident )
302+ } else {
303+ None
304+ }
303305 }
304306}
305307
Original file line number Diff line number Diff line change 1010
1111#![ feature( tool_lints) ]
1212
13- #![ deny( foo:: bar) ] //~ ERROR an unknown tool name found in scoped lint: `foo::bar`.
13+ #![ deny( foo:: bar) ] //~ ERROR an unknown tool name found in scoped lint: `foo::bar`
1414
15- #[ allow( foo:: bar) ] //~ ERROR an unknown tool name found in scoped lint: `foo::bar`.
15+ #[ allow( foo:: bar) ] //~ ERROR an unknown tool name found in scoped lint: `foo::bar`
1616fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ feature( tool_lints) ]
12+
13+ #[ warn( foo:: bar) ]
14+ //~^ ERROR an unknown tool name found in scoped lint: `foo::bar`
15+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0710]: an unknown tool name found in scoped lint: `foo::bar`
2+ --> $DIR/tool_lints.rs:13:8
3+ |
4+ LL | #[warn(foo::bar)]
5+ | ^^^
6+
7+ error: aborting due to previous error
8+
9+ For more information about this error, try `rustc --explain E0710`.
You can’t perform that action at this time.
0 commit comments