Skip to content

Commit 3aee654

Browse files
authored
Merge pull request #2880 from mati865/rustup_hir
Rustup
2 parents 656b26e + a24f77f commit 3aee654

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+196
-187
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ All notable changes to this project will be documented in this file.
617617
[`block_in_if_condition_expr`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#block_in_if_condition_expr
618618
[`block_in_if_condition_stmt`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#block_in_if_condition_stmt
619619
[`bool_comparison`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#bool_comparison
620+
[`borrow_interior_mutable_const`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#borrow_interior_mutable_const
620621
[`borrowed_box`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#borrowed_box
621622
[`box_vec`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#box_vec
622623
[`boxed_local`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#boxed_local
@@ -641,6 +642,7 @@ All notable changes to this project will be documented in this file.
641642
[`crosspointer_transmute`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#crosspointer_transmute
642643
[`cyclomatic_complexity`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#cyclomatic_complexity
643644
[`decimal_literal_representation`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#decimal_literal_representation
645+
[`declare_interior_mutable_const`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
644646
[`default_trait_access`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#default_trait_access
645647
[`deprecated_semver`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#deprecated_semver
646648
[`deref_addrof`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#deref_addrof

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We are currently in the process of discussing Clippy 1.0 via the RFC process in
99

1010
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
1111

12-
[There are 270 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)
12+
[There are 272 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)
1313

1414
We have a bunch of lint categories to allow you to choose how much clippy is supposed to ~~annoy~~ help you:
1515

clippy_lints/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
195195

196196
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
197197
if is_relevant_impl(cx.tcx, item) {
198-
check_attrs(cx, item.span, item.name, &item.attrs)
198+
check_attrs(cx, item.span, item.ident.name, &item.attrs)
199199
}
200200
}
201201

202202
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
203203
if is_relevant_trait(cx.tcx, item) {
204-
check_attrs(cx, item.span, item.name, &item.attrs)
204+
check_attrs(cx, item.span, item.ident.name, &item.attrs)
205205
}
206206
}
207207
}

clippy_lints/src/blacklisted_name.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ impl LintPass for BlackListedName {
4141

4242
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
4343
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
44-
if let PatKind::Binding(_, _, ref ident, _) = pat.node {
45-
if self.blacklist.iter().any(|s| ident.node == *s) {
44+
if let PatKind::Binding(_, _, ident, _) = pat.node {
45+
if self.blacklist.iter().any(|s| ident.name == *s) {
4646
span_lint(
4747
cx,
4848
BLACKLISTED_NAME,
4949
ident.span,
50-
&format!("use of a blacklisted/placeholder name `{}`", ident.node),
50+
&format!("use of a blacklisted/placeholder name `{}`", ident.name),
5151
);
5252
}
5353
}

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
203203
METHODS_WITH_NEGATION
204204
.iter().cloned()
205205
.flat_map(|(a, b)| vec![(a, b), (b, a)])
206-
.find(|&(a, _)| a == path.name.as_str())
206+
.find(|&(a, _)| a == path.ident.as_str())
207207
.and_then(|(_, neg_method)| Some(format!("{}.{}()", self.snip(&args[0])?, neg_method)))
208208
},
209209
_ => None,

clippy_lints/src/bytecount.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
3939
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
4040
if_chain! {
4141
if let ExprMethodCall(ref count, _, ref count_args) = expr.node;
42-
if count.name == "count";
42+
if count.ident.name == "count";
4343
if count_args.len() == 1;
4444
if let ExprMethodCall(ref filter, _, ref filter_args) = count_args[0].node;
45-
if filter.name == "filter";
45+
if filter.ident.name == "filter";
4646
if filter_args.len() == 2;
4747
if let ExprClosure(_, _, body_id, _, _) = filter_args[1].node;
4848
then {
@@ -68,7 +68,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
6868
}
6969
let haystack = if let ExprMethodCall(ref path, _, ref args) =
7070
filter_args[0].node {
71-
let p = path.name;
71+
let p = path.ident.name;
7272
if (p == "iter" || p == "iter_mut") && args.len() == 1 {
7373
&args[0]
7474
} else {
@@ -104,7 +104,7 @@ fn get_path_name(expr: &Expr) -> Option<Name> {
104104
} else {
105105
None
106106
},
107-
ExprPath(ref qpath) => single_segment_path(qpath).map(|ps| ps.name),
107+
ExprPath(ref qpath) => single_segment_path(qpath).map(|ps| ps.ident.name),
108108
_ => None,
109109
}
110110
}

clippy_lints/src/copies.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<LocalInt
269269
PatKind::TupleStruct(_, ref pats, _) => for pat in pats {
270270
bindings_impl(cx, pat, map);
271271
},
272-
PatKind::Binding(_, _, ref ident, ref as_pat) => {
273-
if let Entry::Vacant(v) = map.entry(ident.node.as_str()) {
272+
PatKind::Binding(_, _, ident, ref as_pat) => {
273+
if let Entry::Vacant(v) = map.entry(ident.as_str()) {
274274
v.insert(cx.tables.pat_ty(pat));
275275
}
276276
if let Some(ref as_pat) = *as_pat {

clippy_lints/src/duration_subsec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DurationSubsec {
4343
if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::DURATION);
4444
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables, right);
4545
then {
46-
let suggested_fn = match (method_path.name.as_str().as_ref(), divisor) {
46+
let suggested_fn = match (method_path.ident.as_str().as_ref(), divisor) {
4747
("subsec_micros", 1_000) => "subsec_millis",
4848
("subsec_nanos", 1_000) => "subsec_micros",
4949
("subsec_nanos", 1_000_000) => "subsec_millis",

clippy_lints/src/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn check_cond<'a, 'tcx, 'b>(
9090
if_chain! {
9191
if let ExprMethodCall(ref path, _, ref params) = check.node;
9292
if params.len() >= 2;
93-
if path.name == "contains_key";
93+
if path.ident.name == "contains_key";
9494
if let ExprAddrOf(_, ref key) = params[1].node;
9595
then {
9696
let map = &params[0];
@@ -125,7 +125,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
125125
if_chain! {
126126
if let ExprMethodCall(ref path, _, ref params) = expr.node;
127127
if params.len() == 3;
128-
if path.name == "insert";
128+
if path.ident.name == "insert";
129129
if get_item_name(self.cx, self.map) == get_item_name(self.cx, &params[0]);
130130
if SpanlessEq::new(self.cx).eq_expr(self.key, &params[1]);
131131
then {

clippy_lints/src/enum_variants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl LintPass for EnumVariantNames {
121121
}
122122

123123
fn var2str(var: &Variant) -> LocalInternedString {
124-
var.node.ident.name.as_str()
124+
var.node.ident.as_str()
125125
}
126126

127127
/// Returns the number of chars that match from the start
@@ -245,7 +245,7 @@ impl EarlyLintPass for EnumVariantNames {
245245
}
246246

247247
fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
248-
let item_name = item.ident.name.as_str();
248+
let item_name = item.ident.as_str();
249249
let item_name_chars = item_name.chars().count();
250250
let item_camel = to_camel_case(&item_name);
251251
if !in_macro(item.span) {

clippy_lints/src/eta_reduction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
7878
// If it's a proper path, it can't be a local variable
7979
return;
8080
}
81-
if p.segments[0].name != ident.node {
81+
if p.segments[0].ident.name != ident.name {
8282
// The two idents should be the same
8383
return;
8484
}

clippy_lints/src/explicit_write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
3636
if_chain! {
3737
// match call to unwrap
3838
if let ExprMethodCall(ref unwrap_fun, _, ref unwrap_args) = expr.node;
39-
if unwrap_fun.name == "unwrap";
39+
if unwrap_fun.ident.name == "unwrap";
4040
// match call to write_fmt
4141
if unwrap_args.len() > 0;
4242
if let ExprMethodCall(ref write_fun, _, ref write_args) =
4343
unwrap_args[0].node;
44-
if write_fun.name == "write_fmt";
44+
if write_fun.ident.name == "write_fmt";
4545
// match calls to std::io::stdout() / std::io::stderr ()
4646
if write_args.len() > 0;
4747
if let ExprCall(ref dest_fun, _) = write_args[0].node;

clippy_lints/src/fallible_impl_from.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
9393

9494
for impl_item in impl_items {
9595
if_chain! {
96-
if impl_item.name == "from";
96+
if impl_item.ident.name == "from";
9797
if let ImplItemKind::Method(_, body_id) =
9898
cx.tcx.hir.impl_item(impl_item.id).node;
9999
then {

clippy_lints/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn check_unformatted(expr: &Expr) -> bool {
151151
if let ExprStruct(_, ref fields, _) = format_field.expr.node;
152152
if let Some(align_field) = fields.iter().find(|f| f.ident.name == "width");
153153
if let ExprPath(ref qpath) = align_field.expr.node;
154-
if last_path_segment(qpath).name == "Implied";
154+
if last_path_segment(qpath).ident.name == "Implied";
155155
then {
156156
return true;
157157
}

clippy_lints/src/identity_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
5656
},
5757

5858
ExprMethodCall(ref name, .., ref args) => {
59-
if match_trait_method(cx, e, &paths::INTO[..]) && &*name.name.as_str() == "into" {
59+
if match_trait_method(cx, e, &paths::INTO[..]) && &*name.ident.as_str() == "into" {
6060
let a = cx.tables.expr_ty(e);
6161
let b = cx.tables.expr_ty(&args[0]);
6262
if same_tys(cx, a, b) {

clippy_lints/src/infinite_iter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
143143
match expr.node {
144144
ExprMethodCall(ref method, _, ref args) => {
145145
for &(name, len, heuristic, cap) in HEURISTICS.iter() {
146-
if method.name == name && args.len() == len {
146+
if method.ident.name == name && args.len() == len {
147147
return (match heuristic {
148148
Always => Infinite,
149149
First => is_infinite(cx, &args[0]),
@@ -152,7 +152,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
152152
}).and(cap);
153153
}
154154
}
155-
if method.name == "flat_map" && args.len() == 2 {
155+
if method.ident.name == "flat_map" && args.len() == 2 {
156156
if let ExprClosure(_, _, body_id, _, _) = args[1].node {
157157
let body = cx.tcx.hir.body(body_id);
158158
return is_infinite(cx, &body.value);
@@ -207,16 +207,16 @@ fn complete_infinite_iter(cx: &LateContext, expr: &Expr) -> Finiteness {
207207
match expr.node {
208208
ExprMethodCall(ref method, _, ref args) => {
209209
for &(name, len) in COMPLETING_METHODS.iter() {
210-
if method.name == name && args.len() == len {
210+
if method.ident.name == name && args.len() == len {
211211
return is_infinite(cx, &args[0]);
212212
}
213213
}
214214
for &(name, len) in POSSIBLY_COMPLETING_METHODS.iter() {
215-
if method.name == name && args.len() == len {
215+
if method.ident.name == name && args.len() == len {
216216
return MaybeInfinite.and(is_infinite(cx, &args[0]));
217217
}
218218
}
219-
if method.name == "last" && args.len() == 1 {
219+
if method.ident.name == "last" && args.len() == 1 {
220220
let not_double_ended = get_trait_def_id(cx, &paths::DOUBLE_ENDED_ITERATOR)
221221
.map_or(false, |id| !implements_trait(cx, cx.tables.expr_ty(&args[0]), id, &[]));
222222
if not_double_ended {

clippy_lints/src/inline_fn_without_body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl LintPass for Pass {
3838
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
3939
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
4040
if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.node {
41-
check_attrs(cx, item.name, &item.attrs);
41+
check_attrs(cx, item.ident.name, &item.attrs);
4242
}
4343
}
4444
}

clippy_lints/src/len_zero.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
107107

108108
fn check_trait_items(cx: &LateContext, visited_trait: &Item, trait_items: &[TraitItemRef]) {
109109
fn is_named_self(cx: &LateContext, item: &TraitItemRef, name: &str) -> bool {
110-
item.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
110+
item.ident.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
111111
has_self && {
112112
let did = cx.tcx.hir.local_def_id(item.id.node_id);
113113
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
@@ -135,7 +135,7 @@ fn check_trait_items(cx: &LateContext, visited_trait: &Item, trait_items: &[Trai
135135
.iter()
136136
.flat_map(|&i| cx.tcx.associated_items(i))
137137
.any(|i| {
138-
i.kind == ty::AssociatedKind::Method && i.method_has_self_argument && i.name == "is_empty"
138+
i.kind == ty::AssociatedKind::Method && i.method_has_self_argument && i.ident.name == "is_empty"
139139
&& cx.tcx.fn_sig(i.def_id).inputs().skip_binder().len() == 1
140140
});
141141

@@ -155,7 +155,7 @@ fn check_trait_items(cx: &LateContext, visited_trait: &Item, trait_items: &[Trai
155155

156156
fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
157157
fn is_named_self(cx: &LateContext, item: &ImplItemRef, name: &str) -> bool {
158-
item.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
158+
item.ident.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
159159
has_self && {
160160
let did = cx.tcx.hir.local_def_id(item.id.node_id);
161161
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
@@ -202,7 +202,7 @@ fn check_cmp(cx: &LateContext, span: Span, method: &Expr, lit: &Expr, op: &str,
202202
}
203203
}
204204

205-
check_len(cx, span, method_path.name, args, lit, op, compare_to)
205+
check_len(cx, span, method_path.ident.name, args, lit, op, compare_to)
206206
}
207207
}
208208

@@ -235,7 +235,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
235235
/// Get an `AssociatedItem` and return true if it matches `is_empty(self)`.
236236
fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool {
237237
if let ty::AssociatedKind::Method = item.kind {
238-
if item.name == "is_empty" {
238+
if item.ident.name == "is_empty" {
239239
let sig = cx.tcx.fn_sig(item.def_id);
240240
let ty = sig.skip_binder();
241241
ty.inputs().len() == 1

clippy_lints/src/let_if_seq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
6767
if let Some(expr) = it.peek();
6868
if let hir::StmtDecl(ref decl, _) = stmt.node;
6969
if let hir::DeclLocal(ref decl) = decl.node;
70-
if let hir::PatKind::Binding(mode, canonical_id, ref name, None) = decl.pat.node;
70+
if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node;
7171
if let hir::StmtExpr(ref if_, _) = expr.node;
7272
if let hir::ExprIf(ref cond, ref then, ref else_) = if_.node;
7373
if !used_in_expr(cx, canonical_id, cond);
@@ -106,7 +106,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
106106
let sug = format!(
107107
"let {mut}{name} = if {cond} {{{then} {value} }} else {{{else} {default} }};",
108108
mut=mutability,
109-
name=name.node,
109+
name=ident.name,
110110
cond=snippet(cx, cond.span, "_"),
111111
then=if then.stmts.len() > 1 { " ..;" } else { "" },
112112
else=if default_multi_stmts { " ..;" } else { "" },

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
434434
reg.register_lint_group("clippy_pedantic", vec![
435435
attrs::INLINE_ALWAYS,
436436
copies::MATCH_SAME_ARMS,
437+
default_trait_access::DEFAULT_TRAIT_ACCESS,
437438
derive::EXPL_IMPL_CLONE_ON_COPY,
438439
doc::DOC_MARKDOWN,
439440
empty_enum::EMPTY_ENUM,
@@ -492,7 +493,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
492493
copies::IF_SAME_THEN_ELSE,
493494
copies::IFS_SAME_COND,
494495
cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
495-
default_trait_access::DEFAULT_TRAIT_ACCESS,
496496
derive::DERIVE_HASH_XOR_EQ,
497497
double_comparison::DOUBLE_COMPARISONS,
498498
double_parens::DOUBLE_PARENS,
@@ -694,7 +694,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
694694
block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
695695
collapsible_if::COLLAPSIBLE_IF,
696696
const_static_lifetime::CONST_STATIC_LIFETIME,
697-
default_trait_access::DEFAULT_TRAIT_ACCESS,
698697
enum_variants::ENUM_VARIANT_NAMES,
699698
enum_variants::MODULE_INCEPTION,
700699
eq_op::OP_REF,

0 commit comments

Comments
 (0)