Rustup to *1.10.0-nightly (7bddce693 2016-05-27)*

This commit is contained in:
mcarton 2016-05-27 14:24:28 +02:00
parent 71b41b6e01
commit a892a96eeb
No known key found for this signature in database
GPG key ID: 5E427C794CBA45E8
9 changed files with 57 additions and 18 deletions

View file

@ -187,7 +187,7 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<Interned
match pat.node {
PatKind::Box(ref pat) |
PatKind::Ref(ref pat, _) => bindings_impl(cx, pat, map),
PatKind::TupleStruct(_, Some(ref pats)) => {
PatKind::TupleStruct(_, ref pats, _) => {
for pat in pats {
bindings_impl(cx, pat, map);
}
@ -205,7 +205,7 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<Interned
bindings_impl(cx, &pat.node.pat, map);
}
}
PatKind::Tup(ref fields) => {
PatKind::Tuple(ref fields, _) => {
for pat in fields {
bindings_impl(cx, pat, map);
}
@ -221,7 +221,6 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<Interned
bindings_impl(cx, pat, map);
}
}
PatKind::TupleStruct(..) |
PatKind::Lit(..) |
PatKind::QPath(..) |
PatKind::Range(..) |

View file

@ -101,7 +101,7 @@ fn check_arg_is_display(cx: &LateContext, expr: &Expr) -> bool {
let ExprMatch(_, ref arms, _) = expr.node,
arms.len() == 1,
arms[0].pats.len() == 1,
let PatKind::Tup(ref pat) = arms[0].pats[0].node,
let PatKind::Tuple(ref pat, None) = arms[0].pats[0].node,
pat.len() == 1,
let ExprVec(ref exprs) = arms[0].body.node,
exprs.len() == 1,

View file

@ -280,7 +280,7 @@ impl LateLintPass for LoopsPass {
}
if let ExprMatch(ref match_expr, ref arms, MatchSource::WhileLetDesugar) = expr.node {
let pat = &arms[0].pats[0].node;
if let (&PatKind::TupleStruct(ref path, Some(ref pat_args)),
if let (&PatKind::TupleStruct(ref path, ref pat_args, _),
&ExprMethodCall(method_name, _, ref method_args)) = (pat, &match_expr.node) {
let iter_expr = &method_args[0];
if let Some(lhs_constructor) = path.segments.last() {
@ -575,7 +575,7 @@ fn check_for_loop_explicit_counter(cx: &LateContext, arg: &Expr, body: &Expr, ex
/// Check for the `FOR_KV_MAP` lint.
fn check_for_loop_over_map_kv(cx: &LateContext, pat: &Pat, arg: &Expr, body: &Expr, expr: &Expr) {
if let PatKind::Tup(ref pat) = pat.node {
if let PatKind::Tuple(ref pat, _) = pat.node {
if pat.len() == 2 {
let (pat_span, kind) = match (&pat[0].node, &pat[1].node) {
(key, _) if pat_is_wild(key, body) => (&pat[1].span, "values"),

View file

@ -193,14 +193,13 @@ fn check_single_match_opt_like(cx: &LateContext, ex: &Expr, arms: &[Arm], expr:
(&paths::RESULT, "Ok")];
let path = match arms[1].pats[0].node {
PatKind::TupleStruct(ref path, Some(ref inner)) => {
PatKind::TupleStruct(ref path, ref inner, _) => {
// contains any non wildcard patterns? e.g. Err(err)
if inner.iter().any(|pat| pat.node != PatKind::Wild) {
return;
}
path.to_string()
}
PatKind::TupleStruct(ref path, None) => path.to_string(),
PatKind::Ident(BindByValue(MutImmutable), ident, None) => ident.node.to_string(),
_ => return,
};

View file

@ -161,7 +161,7 @@ fn check_pat(cx: &LateContext, pat: &Pat, init: &Option<&Expr>, span: Span, bind
}
}
}
PatKind::Tup(ref inner) => {
PatKind::Tuple(ref inner, _) => {
if let Some(ref init_tup) = *init {
if let ExprTup(ref tup) = init_tup.node {
for (i, p) in inner.iter().enumerate() {

View file

@ -68,7 +68,7 @@ impl<'v> Visitor<'v> for UnusedLabelVisitor {
self.labels.remove(&label.node.as_str());
}
hir::ExprLoop(_, Some(label)) | hir::ExprWhile(_, _, Some(label)) => {
self.labels.insert(label.as_str(), expr.span);
self.labels.insert(label.node.as_str(), expr.span);
}
_ => (),
}

View file

@ -95,7 +95,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
}
(&ExprLit(ref l), &ExprLit(ref r)) => l.node == r.node,
(&ExprLoop(ref lb, ref ll), &ExprLoop(ref rb, ref rl)) => {
self.eq_block(lb, rb) && both(ll, rl, |l, r| l.as_str() == r.as_str())
self.eq_block(lb, rb) && both(ll, rl, |l, r| l.node.as_str() == r.node.as_str())
}
(&ExprMatch(ref le, ref la, ref ls), &ExprMatch(ref re, ref ra, ref rs)) => {
ls == rs && self.eq_expr(le, re) &&
@ -124,7 +124,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
(&ExprUnary(l_op, ref le), &ExprUnary(r_op, ref re)) => l_op == r_op && self.eq_expr(le, re),
(&ExprVec(ref l), &ExprVec(ref r)) => self.eq_exprs(l, r),
(&ExprWhile(ref lc, ref lb, ref ll), &ExprWhile(ref rc, ref rb, ref rl)) => {
self.eq_expr(lc, rc) && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.as_str() == r.as_str())
self.eq_expr(lc, rc) && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.node.as_str() == r.node.as_str())
}
_ => false,
}
@ -142,8 +142,8 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
pub fn eq_pat(&self, left: &Pat, right: &Pat) -> bool {
match (&left.node, &right.node) {
(&PatKind::Box(ref l), &PatKind::Box(ref r)) => self.eq_pat(l, r),
(&PatKind::TupleStruct(ref lp, ref la), &PatKind::TupleStruct(ref rp, ref ra)) => {
self.eq_path(lp, rp) && both(la, ra, |l, r| over(l, r, |l, r| self.eq_pat(l, r)))
(&PatKind::TupleStruct(ref lp, ref la, ls), &PatKind::TupleStruct(ref rp, ref ra, rs)) => {
self.eq_path(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs
}
(&PatKind::Ident(ref lb, ref li, ref lp), &PatKind::Ident(ref rb, ref ri, ref rp)) => {
lb == rb && li.node.as_str() == ri.node.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
@ -152,7 +152,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
(&PatKind::QPath(ref ls, ref lp), &PatKind::QPath(ref rs, ref rp)) => {
self.eq_qself(ls, rs) && self.eq_path(lp, rp)
}
(&PatKind::Tup(ref l), &PatKind::Tup(ref r)) => over(l, r, |l, r| self.eq_pat(l, r)),
(&PatKind::Tuple(ref l, ls), &PatKind::Tuple(ref r, rs)) => ls == rs && over(l, r, |l, r| self.eq_pat(l, r)),
(&PatKind::Range(ref ls, ref le), &PatKind::Range(ref rs, ref re)) => {
self.eq_expr(ls, rs) && self.eq_expr(le, re)
}
@ -374,7 +374,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
c.hash(&mut self.s);
self.hash_block(b);
if let Some(i) = *i {
self.hash_name(&i);
self.hash_name(&i.node);
}
}
ExprMatch(ref e, ref arms, ref s) => {
@ -468,7 +468,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_expr(cond);
self.hash_block(b);
if let Some(l) = l {
self.hash_name(&l);
self.hash_name(&l.node);
}
}
}

View file

@ -828,7 +828,7 @@ pub fn recover_for_loop(expr: &Expr) -> Option<(&Pat, &Expr, &Expr)> {
let Some(ref loopexpr) = block.expr,
let ExprMatch(_, ref innerarms, MatchSource::ForLoopDesugar) = loopexpr.node,
innerarms.len() == 2 && innerarms[0].pats.len() == 1,
let PatKind::TupleStruct(_, Some(ref somepats)) = innerarms[0].pats[0].node,
let PatKind::TupleStruct(_, ref somepats, _) = innerarms[0].pats[0].node,
somepats.len() == 1
], {
return Some((&somepats[0],

View file

@ -1,4 +1,5 @@
#![feature(plugin, inclusive_range_syntax)]
#![feature(dotdot_in_tuple_patterns)]
#![plugin(clippy)]
#![allow(dead_code, no_effect, unnecessary_operation)]
@ -129,6 +130,34 @@ fn if_same_then_else() -> Result<&'static str, ()> {
if let Some(a) = Some(42) {}
}
if true {
if let (1, .., 3) = (1, 2, 3) {}
}
else { //~ERROR this `if` has identical blocks
if let (1, .., 3) = (1, 2, 3) {}
}
if true {
if let (1, .., 3) = (1, 2, 3) {}
}
else {
if let (.., 3) = (1, 2, 3) {}
}
if true {
if let (1, .., 3) = (1, 2, 3) {}
}
else {
if let (.., 4) = (1, 2, 3) {}
}
if true {
if let (1, .., 3) = (1, 2, 3) {}
}
else {
if let (.., 1, 3) = (1, 2, 3) {}
}
if true {
if let Some(a) = Some(42) {}
}
@ -165,6 +194,18 @@ fn if_same_then_else() -> Result<&'static str, ()> {
_ => (),
}
match (Some(42), Some(42)) {
(Some(a), ..) => bar(a),
(.., Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
_ => (),
}
match (1, 2, 3) {
(1, .., 3) => 42,
(.., 3) => 42, //~ERROR this `match` has identical arm bodies
_ => 0,
};
match (Some(42), Some("")) {
(Some(a), None) => bar(a),
(None, Some(a)) => bar(a), // bindings have different types