Skip to content

Commit 3b26baa

Browse files
author
Alexander Regueiro
committed
Fixed build for latest nightly
1 parent c7ce6c0 commit 3b26baa

File tree

9 files changed

+42
-49
lines changed

9 files changed

+42
-49
lines changed

clippy_lints/src/attrs.rs

+32-34
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ impl LintPass for AttrPass {
125125
impl<'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

329327
fn 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
}

clippy_lints/src/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ pub fn check_attrs<'a>(cx: &EarlyContext, valid_idents: &[String], attrs: &'a [a
150150
spans.extend_from_slice(&current_spans);
151151
doc.push_str(&current);
152152
}
153-
} else if let Some(name) = attr.name() {
153+
} else {
154154
// ignore mix of sugared and non-sugared doc
155-
if name == "doc" {
155+
if attr.name() == "doc" {
156156
return;
157157
}
158158
}

clippy_lints/src/inline_fn_without_body.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
4545

4646
fn check_attrs(cx: &LateContext, name: &Name, attrs: &[Attribute]) {
4747
for attr in attrs {
48-
if attr.name().map_or(true, |n| n != "inline") {
48+
if attr.name() == "inline" {
4949
continue;
5050
}
5151

clippy_lints/src/missing_doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl MissingDoc {
8484

8585
let has_doc = attrs
8686
.iter()
87-
.any(|a| a.is_value_str() && a.name().map_or(false, |n| n == "doc"));
87+
.any(|a| a.is_value_str() && a.name() == "doc");
8888
if !has_doc {
8989
cx.span_lint(
9090
MISSING_DOCS_IN_PRIVATE_ITEMS,

clippy_lints/src/needless_pass_by_value.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
7777
return;
7878
}
7979
for a in attrs {
80-
if_chain! {
81-
if a.meta_item_list().is_some();
82-
if let Some(name) = a.name();
83-
if name == "proc_macro_derive";
84-
then {
85-
return;
86-
}
80+
if a.meta_item_list().is_some() && a.name() == "proc_macro_derive" {
81+
return;
8782
}
8883
}
8984
},

clippy_lints/src/returns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,5 @@ impl EarlyLintPass for ReturnPass {
149149
}
150150

151151
fn attr_is_cfg(attr: &ast::Attribute) -> bool {
152-
attr.meta_item_list().is_some() && attr.name().map_or(false, |n| n == "cfg")
152+
attr.meta_item_list().is_some() && attr.name() == "cfg"
153153
}

clippy_lints/src/utils/author.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ fn has_attr(attrs: &[Attribute]) -> bool {
463463
attrs.iter().any(|attr| {
464464
attr.check_name("clippy") && attr.meta_item_list().map_or(false, |list| {
465465
list.len() == 1 && match list[0].node {
466-
ast::NestedMetaItemKind::MetaItem(ref it) => it.ident.name == "author",
466+
ast::NestedMetaItemKind::MetaItem(ref it) => it.name() == "author",
467467
ast::NestedMetaItemKind::Literal(_) => false,
468468
}
469469
})

clippy_lints/src/utils/conf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn file_from_args(
1313
args: &[codemap::Spanned<ast::NestedMetaItemKind>],
1414
) -> Result<Option<path::PathBuf>, (&'static str, codemap::Span)> {
1515
for arg in args.iter().filter_map(|a| a.meta_item()) {
16-
if arg.ident.name == "conf_file" {
16+
if arg.name() == "conf_file" {
1717
return match arg.node {
1818
ast::MetaItemKind::Word | ast::MetaItemKind::List(_) => {
1919
Err(("`conf_file` must be a named value", arg.span))

clippy_lints/src/utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'
743743
continue;
744744
}
745745
if let Some(ref value) = attr.value_str() {
746-
if attr.name().map_or(false, |n| n == name) {
746+
if attr.name() == name {
747747
if let Ok(value) = FromStr::from_str(&value.as_str()) {
748748
attr::mark_used(attr);
749749
f(value)

0 commit comments

Comments
 (0)