File tree 5 files changed +38
-12
lines changed
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> {
222
222
continue
223
223
}
224
224
} ;
225
- if word. is_scoped ( ) {
225
+ if let Some ( lint_tool ) = word. is_scoped ( ) {
226
226
if !self . sess . features_untracked ( ) . tool_lints {
227
227
feature_gate:: emit_feature_err ( & sess. parse_sess ,
228
228
"tool_lints" ,
@@ -232,12 +232,12 @@ impl<'a> LintLevelsBuilder<'a> {
232
232
word. ident) ) ;
233
233
}
234
234
235
- if !attr:: is_known_lint_tool ( word ) {
235
+ if !attr:: is_known_lint_tool ( lint_tool ) {
236
236
span_err ! (
237
237
sess,
238
- word . span,
238
+ lint_tool . span,
239
239
E0710 ,
240
- "an unknown tool name found in scoped lint: `{}`. " ,
240
+ "an unknown tool name found in scoped lint: `{}`" ,
241
241
word. ident
242
242
) ;
243
243
}
Original file line number Diff line number Diff line change @@ -98,10 +98,8 @@ pub fn is_known_tool(attr: &Attribute) -> bool {
98
98
RUST_KNOWN_TOOL . contains ( & tool_name. as_str ( ) . as_ref ( ) )
99
99
}
100
100
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 ( ) )
105
103
}
106
104
107
105
impl NestedMetaItem {
@@ -298,8 +296,12 @@ impl MetaItem {
298
296
self . meta_item_list ( ) . is_some ( )
299
297
}
300
298
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
+ }
303
305
}
304
306
}
305
307
Original file line number Diff line number Diff line change 10
10
11
11
#![ feature( tool_lints) ]
12
12
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`
14
14
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`
16
16
fn 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