@@ -125,14 +125,14 @@ impl LintPass for AttrPass {
125125impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for AttrPass {
126126 fn check_attribute ( & mut self , cx : & LateContext < ' a , ' tcx > , attr : & ' tcx Attribute ) {
127127 if let Some ( ref items) = attr. meta_item_list ( ) {
128- if items. is_empty ( ) || attr. name ( ) . map_or ( true , |n| n != "deprecated" ) {
128+ if items. is_empty ( ) || attr. name ( ) != "deprecated" {
129129 return ;
130130 }
131131 for item in items {
132132 if_chain ! {
133133 if let NestedMetaItemKind :: MetaItem ( ref mi) = item. node;
134134 if let MetaItemKind :: NameValue ( ref lit) = mi. node;
135- if mi. ident . name == "since" ;
135+ if mi. name( ) == "since" ;
136136 then {
137137 check_semver( cx, item. span, lit) ;
138138 }
@@ -149,40 +149,38 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
149149 ItemExternCrate ( _) | ItemUse ( _, _) => {
150150 for attr in & item. attrs {
151151 if let Some ( ref lint_list) = attr. meta_item_list ( ) {
152- if let Some ( name) = attr. name ( ) {
153- match & * name. as_str ( ) {
154- "allow" | "warn" | "deny" | "forbid" => {
155- // whitelist `unused_imports` and `deprecated`
156- for lint in lint_list {
157- if is_word ( lint, "unused_imports" ) || is_word ( lint, "deprecated" ) {
158- if let ItemUse ( _, _) = item. node {
159- return ;
160- }
152+ match & * attr. name ( ) . as_str ( ) {
153+ "allow" | "warn" | "deny" | "forbid" => {
154+ // whitelist `unused_imports` and `deprecated`
155+ for lint in lint_list {
156+ if is_word ( lint, "unused_imports" ) || is_word ( lint, "deprecated" ) {
157+ if let ItemUse ( _, _) = item. node {
158+ return ;
161159 }
162160 }
163- let line_span = last_line_of_span ( cx, attr. span ) ;
161+ }
162+ let line_span = last_line_of_span ( cx, attr. span ) ;
164163
165- if let Some ( mut sugg) = snippet_opt ( cx, line_span) {
166- if sugg. contains ( "#[" ) {
167- span_lint_and_then (
168- cx,
169- USELESS_ATTRIBUTE ,
170- line_span,
171- "useless lint attribute" ,
172- |db| {
173- sugg = sugg. replacen ( "#[" , "#![" , 1 ) ;
174- db. span_suggestion (
175- line_span,
176- "if you just forgot a `!`, use" ,
177- sugg,
178- ) ;
179- } ,
180- ) ;
181- }
164+ if let Some ( mut sugg) = snippet_opt ( cx, line_span) {
165+ if sugg. contains ( "#[" ) {
166+ span_lint_and_then (
167+ cx,
168+ USELESS_ATTRIBUTE ,
169+ line_span,
170+ "useless lint attribute" ,
171+ |db| {
172+ sugg = sugg. replacen ( "#[" , "#![" , 1 ) ;
173+ db. span_suggestion (
174+ line_span,
175+ "if you just forgot a `!`, use" ,
176+ sugg,
177+ ) ;
178+ } ,
179+ ) ;
182180 }
183- } ,
184- _ => { } ,
185- }
181+ }
182+ } ,
183+ _ => { } ,
186184 }
187185 }
188186 }
@@ -294,7 +292,7 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
294292 }
295293
296294 if let Some ( ref values) = attr. meta_item_list ( ) {
297- if values. len ( ) != 1 || attr. name ( ) . map_or ( true , |n| n != "inline" ) {
295+ if values. len ( ) != 1 || attr. name ( ) != "inline" {
298296 continue ;
299297 }
300298 if is_word ( & values[ 0 ] , "always" ) {
@@ -328,7 +326,7 @@ fn check_semver(cx: &LateContext, span: Span, lit: &Lit) {
328326
329327fn is_word ( nmi : & NestedMetaItem , expected : & str ) -> bool {
330328 if let NestedMetaItemKind :: MetaItem ( ref mi) = nmi. node {
331- mi. is_word ( ) && mi. ident . name == expected
329+ mi. is_word ( ) && mi. name ( ) == expected
332330 } else {
333331 false
334332 }
0 commit comments