Skip to content

Update to nightly 2018-05-28 #2817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clippy_lints/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ fn check_unformatted(expr: &Expr) -> bool {
if let ExprArray(ref exprs) = expr.node;
if exprs.len() == 1;
if let ExprStruct(_, ref fields, _) = exprs[0].node;
if let Some(format_field) = fields.iter().find(|f| f.name.node == "format");
if let Some(format_field) = fields.iter().find(|f| f.ident.name == "format");
if let ExprStruct(_, ref fields, _) = format_field.expr.node;
if let Some(align_field) = fields.iter().find(|f| f.name.node == "width");
if let Some(align_field) = fields.iter().find(|f| f.ident.name == "width");
if let ExprPath(ref qpath) = align_field.expr.node;
if last_path_segment(qpath).name == "Implied";
then {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#![recursion_limit = "256"]
#![allow(stable_features)]
#![feature(iterator_find_map)]

#![feature(macro_at_most_once_rep)]

extern crate cargo_metadata;
#[macro_use]
extern crate rustc;
extern crate rustc_typeck;
extern crate rustc_target;
extern crate rustc_typeck;
extern crate syntax;
extern crate syntax_pos;

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
None
}
},
ExprField(_, spanned) => {
let name = spanned.node.as_str();
ExprField(_, ident) => {
let name = ident.as_str();
if name.starts_with('_') && !name.starts_with("__") {
Some(name)
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/redundant_field_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames {

if let ExprStruct(_, ref fields, _) = expr.node {
for field in fields {
let name = field.name.node;
let name = field.ident.name;

if match_var(&field.expr, name) && !field.is_shorthand {
span_lint_and_sugg (
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ fn check_pat<'a, 'tcx>(
PatKind::Struct(_, ref pfields, _) => if let Some(init_struct) = init {
if let ExprStruct(_, ref efields, _) = init_struct.node {
for field in pfields {
let name = field.node.name;
let name = field.node.ident.name;
let efield = efields
.iter()
.find(|f| f.name.node == name)
.find(|f| f.ident.name == name)
.map(|f| &*f.expr);
check_pat(cx, &field.node.pat, efield, span, bindings);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
self.current = value_pat;
self.visit_expr(value);
},
Expr_::ExprField(ref object, ref field_name) => {
Expr_::ExprField(ref object, ref field_ident) => {
let obj_pat = self.next("object");
let field_name_pat = self.next("field_name");
println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current);
println!(" if {}.node.as_str() == {:?}", field_name_pat, field_name.node.as_str());
println!(" if {}.node.as_str() == {:?}", field_name_pat, field_ident.name.as_str());
self.current = obj_pat;
self.visit_expr(object);
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/higher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O
/// Find the field named `name` in the field. Always return `Some` for
/// convenience.
fn get_field<'a>(name: &str, fields: &'a [hir::Field]) -> Option<&'a hir::Expr> {
let expr = &fields.iter().find(|field| field.name.node == name)?.expr;
let expr = &fields.iter().find(|field| field.ident.name == name)?.expr;

Some(expr)
}
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/utils/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
(&ExprCast(ref lx, ref lt), &ExprCast(ref rx, ref rt)) |
(&ExprType(ref lx, ref lt), &ExprType(ref rx, ref rt)) => self.eq_expr(lx, rx) && self.eq_ty(lt, rt),
(&ExprField(ref l_f_exp, ref l_f_ident), &ExprField(ref r_f_exp, ref r_f_ident)) => {
l_f_ident.node == r_f_ident.node && self.eq_expr(l_f_exp, r_f_exp)
l_f_ident.name == r_f_ident.name && self.eq_expr(l_f_exp, r_f_exp)
},
(&ExprIndex(ref la, ref li), &ExprIndex(ref ra, ref ri)) => self.eq_expr(la, ra) && self.eq_expr(li, ri),
(&ExprIf(ref lc, ref lt, ref le), &ExprIf(ref rc, ref rt, ref re)) => {
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
}

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

fn eq_lifetime(&mut self, left: &Lifetime, right: &Lifetime) -> bool {
Expand Down Expand Up @@ -419,7 +419,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
let c: fn(_, _) -> _ = ExprField;
c.hash(&mut self.s);
self.hash_expr(e);
self.hash_name(&f.node);
self.hash_name(&f.name);
},
ExprIndex(ref a, ref i) => {
let c: fn(_, _) -> _ = ExprIndex;
Expand Down Expand Up @@ -502,7 +502,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_qpath(path);

for f in fields {
self.hash_name(&f.name.node);
self.hash_name(&f.ident.name);
self.hash_expr(&f.expr);
}

Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/utils/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
println!("{}rhs:", ind);
print_expr(cx, rhs, indent + 1);
},
hir::ExprField(ref e, ref name) => {
hir::ExprField(ref e, ref ident) => {
println!("{}Field", ind);
println!("{}field name: {}", ind, name.node);
println!("{}field name: {}", ind, ident.name);
println!("{}struct expr:", ind);
print_expr(cx, e, indent + 1);
},
Expand Down Expand Up @@ -322,7 +322,7 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
println!("{}Struct", ind);
println!("{}path: {:?}", ind, path);
for field in fields {
println!("{}field \"{}\":", ind, field.name.node);
println!("{}field \"{}\":", ind, field.ident.name);
print_expr(cx, &field.expr, indent + 1);
}
if let Some(ref base) = *base {
Expand Down Expand Up @@ -433,7 +433,7 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) {
println!("{}ignore leftover fields: {}", ind, ignore);
println!("{}fields:", ind);
for field in fields {
println!("{} field name: {}", ind, field.node.name);
println!("{} field name: {}", ind, field.node.ident.name);
if field.node.is_shorthand {
println!("{} in shorthand notation", ind);
}
Expand Down
4 changes: 3 additions & 1 deletion clippy_lints/src/utils/sugg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl<'a> Sugg<'a> {
ast::ExprKind::Closure(..) |
ast::ExprKind::If(..) |
ast::ExprKind::IfLet(..) |
ast::ExprKind::ObsoleteInPlace(..) |
ast::ExprKind::Unary(..) |
ast::ExprKind::Match(..) => Sugg::MaybeParen(snippet),
ast::ExprKind::Block(..) |
Expand Down Expand Up @@ -320,6 +321,7 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg, rhs: &Sugg) -> Sugg<'static> {
AssocOp::ShiftRight |
AssocOp::Subtract => format!("{} {} {}", lhs, op.to_ast_binop().expect("Those are AST ops").to_string(), rhs),
AssocOp::Assign => format!("{} = {}", lhs, rhs),
AssocOp::ObsoleteInPlace => format!("in ({}) {}", lhs, rhs),
AssocOp::AssignOp(op) => format!("{} {}= {}", lhs, token_to_string(&token::BinOp(op)), rhs),
AssocOp::As => format!("{} as {}", lhs, rhs),
AssocOp::DotDot => format!("{}..{}", lhs, rhs),
Expand Down Expand Up @@ -360,7 +362,7 @@ fn associativity(op: &AssocOp) -> Associativity {
use syntax::util::parser::AssocOp::*;

match *op {
Assign | AssignOp(_) => Associativity::Right,
ObsoleteInPlace | Assign | AssignOp(_) => Associativity::Right,
Add | BitAnd | BitOr | BitXor | LAnd | LOr | Multiply | As | Colon => Associativity::Both,
Divide |
Equal |
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ where
if let ExprArray(ref format_exprs) = format_expr.node;
if format_exprs.len() >= 1;
if let ExprStruct(_, ref fields, _) = format_exprs[idx].node;
if let Some(format_field) = fields.iter().find(|f| f.name.node == "format");
if let Some(format_field) = fields.iter().find(|f| f.ident.name == "format");
if check_unformatted(&format_field.expr);
then {
lint_fn(tup_val.span);
Expand Down Expand Up @@ -469,13 +469,13 @@ fn is_in_debug_impl(cx: &LateContext, expr: &Expr) -> bool {
pub fn check_unformatted(format_field: &Expr) -> bool {
if_chain! {
if let ExprStruct(_, ref fields, _) = format_field.node;
if let Some(width_field) = fields.iter().find(|f| f.name.node == "width");
if let Some(width_field) = fields.iter().find(|f| f.ident.name == "width");
if let ExprPath(ref qpath) = width_field.expr.node;
if last_path_segment(qpath).name == "Implied";
if let Some(align_field) = fields.iter().find(|f| f.name.node == "align");
if let Some(align_field) = fields.iter().find(|f| f.ident.name == "align");
if let ExprPath(ref qpath) = align_field.expr.node;
if last_path_segment(qpath).name == "Unknown";
if let Some(precision_field) = fields.iter().find(|f| f.name.node == "precision");
if let Some(precision_field) = fields.iter().find(|f| f.ident.name == "precision");
if let ExprPath(ref qpath_precision) = precision_field.expr.node;
if last_path_segment(qpath_precision).name == "Implied";
then {
Expand Down
36 changes: 18 additions & 18 deletions tests/ui/for_loop.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ error: the loop variable `i` is only used to index `vec`.
help: consider using an iterator
|
86 | for <item> in &vec {
|
| ^^^^^^ ^^^^

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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