Skip to content

Commit c1b39c4

Browse files
authored
Merge pull request #2713 from alexreg/nightly-fix
Fixed build for latest rust master
2 parents 77de100 + 9ce6fb3 commit c1b39c4

16 files changed

+82
-94
lines changed

clippy_lints/src/attrs.rs

Lines changed: 32 additions & 34 deletions
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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +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 if attr.name() == "doc" {
154154
// ignore mix of sugared and non-sugared doc
155-
if name == "doc" {
156-
return;
157-
}
155+
return;
158156
}
159157
}
160158

clippy_lints/src/inline_fn_without_body.rs

Lines changed: 1 addition & 1 deletion
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/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ extern crate regex_syntax;
4242

4343
extern crate quine_mc_cluskey;
4444

45-
extern crate rustc_const_math;
4645
extern crate rustc_errors;
4746
extern crate rustc_plugin;
4847

clippy_lints/src/map_unit_fn.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc::hir;
22
use rustc::lint::*;
33
use rustc::ty;
4+
use rustc_errors::{Applicability};
45
use syntax::codemap::Span;
56
use utils::{in_macro, iter_input_pats, match_type, method_chain_args, snippet, span_lint_and_then};
67
use utils::paths;
@@ -210,25 +211,31 @@ fn lint_map_unit_fn(cx: &LateContext, stmt: &hir::Stmt, expr: &hir::Expr, map_ar
210211
snippet(cx, fn_arg.span, "_"));
211212

212213
span_lint_and_then(cx, lint, expr.span, &msg, |db| {
213-
db.span_approximate_suggestion(stmt.span, "try this", suggestion);
214+
db.span_suggestion_with_applicability(stmt.span,
215+
"try this",
216+
suggestion,
217+
Applicability::Unspecified);
214218
});
215219
} else if let Some((binding, closure_expr)) = unit_closure(cx, fn_arg) {
216220
let msg = suggestion_msg("closure", map_type);
217221

218222
span_lint_and_then(cx, lint, expr.span, &msg, |db| {
219223
if let Some(reduced_expr_span) = reduce_unit_expression(cx, closure_expr) {
220224
let suggestion = format!("if let {0}({1}) = {2} {{ {3} }}",
221-
variant,
222-
snippet(cx, binding.pat.span, "_"),
223-
snippet(cx, var_arg.span, "_"),
224-
snippet(cx, reduced_expr_span, "_"));
225+
variant,
226+
snippet(cx, binding.pat.span, "_"),
227+
snippet(cx, var_arg.span, "_"),
228+
snippet(cx, reduced_expr_span, "_"));
225229
db.span_suggestion(stmt.span, "try this", suggestion);
226230
} else {
227231
let suggestion = format!("if let {0}({1}) = {2} {{ ... }}",
228-
variant,
229-
snippet(cx, binding.pat.span, "_"),
230-
snippet(cx, var_arg.span, "_"));
231-
db.span_approximate_suggestion(stmt.span, "try this", suggestion);
232+
variant,
233+
snippet(cx, binding.pat.span, "_"),
234+
snippet(cx, var_arg.span, "_"));
235+
db.span_suggestion_with_applicability(stmt.span,
236+
"try this",
237+
suggestion,
238+
Applicability::Unspecified);
232239
}
233240
});
234241
}

clippy_lints/src/missing_doc.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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))

0 commit comments

Comments
 (0)