Skip to content

Commit 8ed8ee8

Browse files
committed
Update to nightly 2018-05-28
1 parent 0d1e06d commit 8ed8ee8

18 files changed

+141
-144
lines changed

clippy_lints/src/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ fn check_unformatted(expr: &Expr) -> bool {
147147
if let ExprArray(ref exprs) = expr.node;
148148
if exprs.len() == 1;
149149
if let ExprStruct(_, ref fields, _) = exprs[0].node;
150-
if let Some(format_field) = fields.iter().find(|f| f.name.node == "format");
150+
if let Some(format_field) = fields.iter().find(|f| f.ident.name == "format");
151151
if let ExprStruct(_, ref fields, _) = format_field.expr.node;
152-
if let Some(align_field) = fields.iter().find(|f| f.name.node == "width");
152+
if let Some(align_field) = fields.iter().find(|f| f.ident.name == "width");
153153
if let ExprPath(ref qpath) = align_field.expr.node;
154154
if last_path_segment(qpath).name == "Implied";
155155
then {

clippy_lints/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
#![recursion_limit = "256"]
1111
#![allow(stable_features)]
1212
#![feature(iterator_find_map)]
13-
13+
#![feature(macro_at_most_once_rep)]
1414

1515
extern crate cargo_metadata;
1616
#[macro_use]
1717
extern crate rustc;
18-
extern crate rustc_typeck;
1918
extern crate rustc_target;
19+
extern crate rustc_typeck;
2020
extern crate syntax;
2121
extern crate syntax_pos;
2222

clippy_lints/src/misc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
392392
None
393393
}
394394
},
395-
ExprField(_, spanned) => {
396-
let name = spanned.node.as_str();
395+
ExprField(_, ident) => {
396+
let name = ident.as_str();
397397
if name.starts_with('_') && !name.starts_with("__") {
398398
Some(name)
399399
} else {

clippy_lints/src/redundant_field_names.rs

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

4646
if let ExprStruct(_, ref fields, _) = expr.node {
4747
for field in fields {
48-
let name = field.name.node;
48+
let name = field.ident.name;
4949

5050
if match_var(&field.expr, name) && !field.is_shorthand {
5151
span_lint_and_sugg (

clippy_lints/src/shadow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ fn check_pat<'a, 'tcx>(
187187
PatKind::Struct(_, ref pfields, _) => if let Some(init_struct) = init {
188188
if let ExprStruct(_, ref efields, _) = init_struct.node {
189189
for field in pfields {
190-
let name = field.node.name;
190+
let name = field.node.ident.name;
191191
let efield = efields
192192
.iter()
193-
.find(|f| f.name.node == name)
193+
.find(|f| f.ident.name == name)
194194
.map(|f| &*f.expr);
195195
check_pat(cx, &field.node.pat, efield, span, bindings);
196196
}

clippy_lints/src/utils/author.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,11 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
383383
self.current = value_pat;
384384
self.visit_expr(value);
385385
},
386-
Expr_::ExprField(ref object, ref field_name) => {
386+
Expr_::ExprField(ref object, ref field_ident) => {
387387
let obj_pat = self.next("object");
388388
let field_name_pat = self.next("field_name");
389389
println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current);
390-
println!(" if {}.node.as_str() == {:?}", field_name_pat, field_name.node.as_str());
390+
println!(" if {}.node.as_str() == {:?}", field_name_pat, field_ident.name.as_str());
391391
self.current = obj_pat;
392392
self.visit_expr(object);
393393
},

clippy_lints/src/utils/higher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O
7777
/// Find the field named `name` in the field. Always return `Some` for
7878
/// convenience.
7979
fn get_field<'a>(name: &str, fields: &'a [hir::Field]) -> Option<&'a hir::Expr> {
80-
let expr = &fields.iter().find(|field| field.name.node == name)?.expr;
80+
let expr = &fields.iter().find(|field| field.ident.name == name)?.expr;
8181

8282
Some(expr)
8383
}

clippy_lints/src/utils/hir_utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
101101
(&ExprCast(ref lx, ref lt), &ExprCast(ref rx, ref rt)) |
102102
(&ExprType(ref lx, ref lt), &ExprType(ref rx, ref rt)) => self.eq_expr(lx, rx) && self.eq_ty(lt, rt),
103103
(&ExprField(ref l_f_exp, ref l_f_ident), &ExprField(ref r_f_exp, ref r_f_ident)) => {
104-
l_f_ident.node == r_f_ident.node && self.eq_expr(l_f_exp, r_f_exp)
104+
l_f_ident.name == r_f_ident.name && self.eq_expr(l_f_exp, r_f_exp)
105105
},
106106
(&ExprIndex(ref la, ref li), &ExprIndex(ref ra, ref ri)) => self.eq_expr(la, ra) && self.eq_expr(li, ri),
107107
(&ExprIf(ref lc, ref lt, ref le), &ExprIf(ref rc, ref rt, ref re)) => {
@@ -149,7 +149,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
149149
}
150150

151151
fn eq_field(&mut self, left: &Field, right: &Field) -> bool {
152-
left.name.node == right.name.node && self.eq_expr(&left.expr, &right.expr)
152+
left.ident.name == right.ident.name && self.eq_expr(&left.expr, &right.expr)
153153
}
154154

155155
fn eq_lifetime(&mut self, left: &Lifetime, right: &Lifetime) -> bool {
@@ -419,7 +419,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
419419
let c: fn(_, _) -> _ = ExprField;
420420
c.hash(&mut self.s);
421421
self.hash_expr(e);
422-
self.hash_name(&f.node);
422+
self.hash_name(&f.name);
423423
},
424424
ExprIndex(ref a, ref i) => {
425425
let c: fn(_, _) -> _ = ExprIndex;
@@ -502,7 +502,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
502502
self.hash_qpath(path);
503503

504504
for f in fields {
505-
self.hash_name(&f.name.node);
505+
self.hash_name(&f.ident.name);
506506
self.hash_expr(&f.expr);
507507
}
508508

clippy_lints/src/utils/inspector.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
268268
println!("{}rhs:", ind);
269269
print_expr(cx, rhs, indent + 1);
270270
},
271-
hir::ExprField(ref e, ref name) => {
271+
hir::ExprField(ref e, ref ident) => {
272272
println!("{}Field", ind);
273-
println!("{}field name: {}", ind, name.node);
273+
println!("{}field name: {}", ind, ident.name);
274274
println!("{}struct expr:", ind);
275275
print_expr(cx, e, indent + 1);
276276
},
@@ -322,7 +322,7 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
322322
println!("{}Struct", ind);
323323
println!("{}path: {:?}", ind, path);
324324
for field in fields {
325-
println!("{}field \"{}\":", ind, field.name.node);
325+
println!("{}field \"{}\":", ind, field.ident.name);
326326
print_expr(cx, &field.expr, indent + 1);
327327
}
328328
if let Some(ref base) = *base {
@@ -433,7 +433,7 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) {
433433
println!("{}ignore leftover fields: {}", ind, ignore);
434434
println!("{}fields:", ind);
435435
for field in fields {
436-
println!("{} field name: {}", ind, field.node.name);
436+
println!("{} field name: {}", ind, field.node.ident.name);
437437
if field.node.is_shorthand {
438438
println!("{} in shorthand notation", ind);
439439
}

clippy_lints/src/utils/sugg.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ impl<'a> Sugg<'a> {
9797
ast::ExprKind::Closure(..) |
9898
ast::ExprKind::If(..) |
9999
ast::ExprKind::IfLet(..) |
100+
ast::ExprKind::ObsoleteInPlace(..) |
100101
ast::ExprKind::Unary(..) |
101102
ast::ExprKind::Match(..) => Sugg::MaybeParen(snippet),
102103
ast::ExprKind::Block(..) |
@@ -320,6 +321,7 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg, rhs: &Sugg) -> Sugg<'static> {
320321
AssocOp::ShiftRight |
321322
AssocOp::Subtract => format!("{} {} {}", lhs, op.to_ast_binop().expect("Those are AST ops").to_string(), rhs),
322323
AssocOp::Assign => format!("{} = {}", lhs, rhs),
324+
AssocOp::ObsoleteInPlace => format!("in ({}) {}", lhs, rhs),
323325
AssocOp::AssignOp(op) => format!("{} {}= {}", lhs, token_to_string(&token::BinOp(op)), rhs),
324326
AssocOp::As => format!("{} as {}", lhs, rhs),
325327
AssocOp::DotDot => format!("{}..{}", lhs, rhs),
@@ -360,7 +362,7 @@ fn associativity(op: &AssocOp) -> Associativity {
360362
use syntax::util::parser::AssocOp::*;
361363

362364
match *op {
363-
Assign | AssignOp(_) => Associativity::Right,
365+
ObsoleteInPlace | Assign | AssignOp(_) => Associativity::Right,
364366
Add | BitAnd | BitOr | BitXor | LAnd | LOr | Multiply | As | Colon => Associativity::Both,
365367
Divide |
366368
Equal |

clippy_lints/src/write.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ where
375375
if let ExprArray(ref format_exprs) = format_expr.node;
376376
if format_exprs.len() >= 1;
377377
if let ExprStruct(_, ref fields, _) = format_exprs[idx].node;
378-
if let Some(format_field) = fields.iter().find(|f| f.name.node == "format");
378+
if let Some(format_field) = fields.iter().find(|f| f.ident.name == "format");
379379
if check_unformatted(&format_field.expr);
380380
then {
381381
lint_fn(tup_val.span);
@@ -469,13 +469,13 @@ fn is_in_debug_impl(cx: &LateContext, expr: &Expr) -> bool {
469469
pub fn check_unformatted(format_field: &Expr) -> bool {
470470
if_chain! {
471471
if let ExprStruct(_, ref fields, _) = format_field.node;
472-
if let Some(width_field) = fields.iter().find(|f| f.name.node == "width");
472+
if let Some(width_field) = fields.iter().find(|f| f.ident.name == "width");
473473
if let ExprPath(ref qpath) = width_field.expr.node;
474474
if last_path_segment(qpath).name == "Implied";
475-
if let Some(align_field) = fields.iter().find(|f| f.name.node == "align");
475+
if let Some(align_field) = fields.iter().find(|f| f.ident.name == "align");
476476
if let ExprPath(ref qpath) = align_field.expr.node;
477477
if last_path_segment(qpath).name == "Unknown";
478-
if let Some(precision_field) = fields.iter().find(|f| f.name.node == "precision");
478+
if let Some(precision_field) = fields.iter().find(|f| f.ident.name == "precision");
479479
if let ExprPath(ref qpath_precision) = precision_field.expr.node;
480480
if last_path_segment(qpath_precision).name == "Implied";
481481
then {

tests/ui/for_loop.stderr

+18-18
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ error: the loop variable `i` is only used to index `vec`.
7878
help: consider using an iterator
7979
|
8080
86 | for <item> in &vec {
81-
|
81+
| ^^^^^^ ^^^^
8282

8383
error: the loop variable `i` is only used to index `vec`.
8484
--> $DIR/for_loop.rs:95:14
@@ -88,7 +88,7 @@ error: the loop variable `i` is only used to index `vec`.
8888
help: consider using an iterator
8989
|
9090
95 | for <item> in &vec {
91-
|
91+
| ^^^^^^ ^^^^
9292

9393
error: the loop variable `j` is only used to index `STATIC`.
9494
--> $DIR/for_loop.rs:100:14
@@ -98,7 +98,7 @@ error: the loop variable `j` is only used to index `STATIC`.
9898
help: consider using an iterator
9999
|
100100
100 | for <item> in STATIC.iter().take(4) {
101-
|
101+
| ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
102102

103103
error: the loop variable `j` is only used to index `CONST`.
104104
--> $DIR/for_loop.rs:104:14
@@ -108,7 +108,7 @@ error: the loop variable `j` is only used to index `CONST`.
108108
help: consider using an iterator
109109
|
110110
104 | for <item> in CONST.iter().take(4) {
111-
|
111+
| ^^^^^^ ^^^^^^^^^^^^^^^^^^^^
112112

113113
error: the loop variable `i` is used to index `vec`
114114
--> $DIR/for_loop.rs:108:14
@@ -118,7 +118,7 @@ error: the loop variable `i` is used to index `vec`
118118
help: consider using an iterator
119119
|
120120
108 | for (i, <item>) in vec.iter().enumerate() {
121-
|
121+
| ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
122122

123123
error: the loop variable `i` is only used to index `vec2`.
124124
--> $DIR/for_loop.rs:116:14
@@ -128,7 +128,7 @@ error: the loop variable `i` is only used to index `vec2`.
128128
help: consider using an iterator
129129
|
130130
116 | for <item> in vec2.iter().take(vec.len()) {
131-
|
131+
| ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
132132

133133
error: the loop variable `i` is only used to index `vec`.
134134
--> $DIR/for_loop.rs:120:14
@@ -138,7 +138,7 @@ error: the loop variable `i` is only used to index `vec`.
138138
help: consider using an iterator
139139
|
140140
120 | for <item> in vec.iter().skip(5) {
141-
|
141+
| ^^^^^^ ^^^^^^^^^^^^^^^^^^
142142

143143
error: the loop variable `i` is only used to index `vec`.
144144
--> $DIR/for_loop.rs:124:14
@@ -148,7 +148,7 @@ error: the loop variable `i` is only used to index `vec`.
148148
help: consider using an iterator
149149
|
150150
124 | for <item> in vec.iter().take(MAX_LEN) {
151-
|
151+
| ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
152152

153153
error: the loop variable `i` is only used to index `vec`.
154154
--> $DIR/for_loop.rs:128:14
@@ -158,7 +158,7 @@ error: the loop variable `i` is only used to index `vec`.
158158
help: consider using an iterator
159159
|
160160
128 | for <item> in vec.iter().take(MAX_LEN + 1) {
161-
|
161+
| ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
162162

163163
error: the loop variable `i` is only used to index `vec`.
164164
--> $DIR/for_loop.rs:132:14
@@ -168,7 +168,7 @@ error: the loop variable `i` is only used to index `vec`.
168168
help: consider using an iterator
169169
|
170170
132 | for <item> in vec.iter().take(10).skip(5) {
171-
|
171+
| ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
172172

173173
error: the loop variable `i` is only used to index `vec`.
174174
--> $DIR/for_loop.rs:136:14
@@ -178,7 +178,7 @@ error: the loop variable `i` is only used to index `vec`.
178178
help: consider using an iterator
179179
|
180180
136 | for <item> in vec.iter().take(10 + 1).skip(5) {
181-
|
181+
| ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
182182

183183
error: the loop variable `i` is used to index `vec`
184184
--> $DIR/for_loop.rs:140:14
@@ -188,7 +188,7 @@ error: the loop variable `i` is used to index `vec`
188188
help: consider using an iterator
189189
|
190190
140 | for (i, <item>) in vec.iter().enumerate().skip(5) {
191-
|
191+
| ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192192

193193
error: the loop variable `i` is used to index `vec`
194194
--> $DIR/for_loop.rs:144:14
@@ -198,7 +198,7 @@ error: the loop variable `i` is used to index `vec`
198198
help: consider using an iterator
199199
|
200200
144 | for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
201-
|
201+
| ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
202202

203203
error: this range is empty so this for loop will never run
204204
--> $DIR/for_loop.rs:148:14
@@ -384,7 +384,7 @@ error: you seem to want to iterate on a map's values
384384
help: use the corresponding method
385385
|
386386
385 | for v in m.values() {
387-
|
387+
| ^ ^^^^^^^^^^
388388

389389
error: you seem to want to iterate on a map's values
390390
--> $DIR/for_loop.rs:390:19
@@ -394,7 +394,7 @@ error: you seem to want to iterate on a map's values
394394
help: use the corresponding method
395395
|
396396
390 | for v in (*m).values() {
397-
|
397+
| ^ ^^^^^^^^^^^^^
398398

399399
error: you seem to want to iterate on a map's values
400400
--> $DIR/for_loop.rs:398:19
@@ -404,7 +404,7 @@ error: you seem to want to iterate on a map's values
404404
help: use the corresponding method
405405
|
406406
398 | for v in m.values_mut() {
407-
|
407+
| ^ ^^^^^^^^^^^^^^
408408

409409
error: you seem to want to iterate on a map's values
410410
--> $DIR/for_loop.rs:403:19
@@ -414,7 +414,7 @@ error: you seem to want to iterate on a map's values
414414
help: use the corresponding method
415415
|
416416
403 | for v in (*m).values_mut() {
417-
|
417+
| ^ ^^^^^^^^^^^^^^^^^
418418

419419
error: you seem to want to iterate on a map's keys
420420
--> $DIR/for_loop.rs:409:24
@@ -424,7 +424,7 @@ error: you seem to want to iterate on a map's keys
424424
help: use the corresponding method
425425
|
426426
409 | for k in rm.keys() {
427-
|
427+
| ^ ^^^^^^^^^
428428

429429
error: it looks like you're manually copying between slices
430430
--> $DIR/for_loop.rs:462:14

0 commit comments

Comments
 (0)