Skip to content
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

Fix breakage due to rust-lang/rust#58079 #3736

Merged
merged 1 commit into from Feb 3, 2019
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
2 changes: 1 addition & 1 deletion clippy_lints/src/blacklisted_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl LintPass for BlackListedName {

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
if let PatKind::Binding(_, _, ident, _) = pat.node {
if let PatKind::Binding(.., ident, _) = pat.node {
if self.blacklist.contains(&ident.name.to_string()) {
span_lint(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> FxHashMap<LocalI
bindings_impl(cx, pat, map);
}
},
PatKind::Binding(_, _, ident, ref as_pat) => {
PatKind::Binding(.., ident, ref as_pat) => {
if let Entry::Vacant(v) = map.entry(ident.as_str()) {
v.insert(cx.tables.pat_ty(pat));
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
_ => (),
}
for (a1, a2) in iter_input_pats(decl, body).zip(args) {
if let PatKind::Binding(_, _, ident, _) = a1.pat.node {
if let PatKind::Binding(.., ident, _) = a1.pat.node {
// XXXManishearth Should I be checking the binding mode here?
if let ExprKind::Path(QPath::Resolved(None, ref p)) = a2.node {
if p.segments.len() != 1 {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl<'a, 'tcx> Functions {
}

fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<ast::NodeId> {
if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.node, &ty.node) {
if let (&hir::PatKind::Binding(_, id, _, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.node, &ty.node) {
Some(id)
} else {
None
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/large_enum_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
|db| {
if variant.fields.len() == 1 {
let span = match def.variants[i].node.data {
VariantData::Struct(ref fields, _) | VariantData::Tuple(ref fields, _) => {
VariantData::Struct(ref fields, ..) | VariantData::Tuple(ref fields, ..) => {
fields[0].ty.span
},
VariantData::Unit(_) => unreachable!(),
VariantData::Unit(..) => unreachable!(),
};
if let Some(snip) = snippet_opt(cx, span) {
db.span_suggestion(
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
if_chain! {
if let Some(expr) = it.peek();
if let hir::StmtKind::Local(ref local) = stmt.node;
if let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.node;
if let hir::PatKind::Binding(mode, canonical_id, _, ident, None) = local.pat.node;
if let hir::StmtKind::Expr(ref if_) = expr.node;
if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node;
if !used_in_expr(cx, canonical_id, cond);
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ fn detect_manual_memcpy<'a, 'tcx>(
}) = higher::range(cx, arg)
{
// the var must be a single name
if let PatKind::Binding(_, canonical_id, _, _) = pat.node {
if let PatKind::Binding(_, canonical_id, _, _, _) = pat.node {
let print_sum = |arg1: &Offset, arg2: &Offset| -> String {
match (&arg1.value[..], arg1.negate, &arg2.value[..], arg2.negate) {
("0", _, "0", _) => "".into(),
Expand Down Expand Up @@ -1086,7 +1086,7 @@ fn check_for_loop_range<'a, 'tcx>(
}) = higher::range(cx, arg)
{
// the var must be a single name
if let PatKind::Binding(_, canonical_id, ident, _) = pat.node {
if let PatKind::Binding(_, canonical_id, _, ident, _) = pat.node {
let mut visitor = VarVisitor {
cx,
var: canonical_id,
Expand Down Expand Up @@ -1637,7 +1637,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<NodeId
let node_str = cx.tcx.hir().get(node_id);
if_chain! {
if let Node::Binding(pat) = node_str;
if let PatKind::Binding(bind_ann, _, _, _) = pat.node;
if let PatKind::Binding(bind_ann, ..) = pat.node;
if let BindingAnnotation::Mutable = bind_ann;
then {
return Some(node_id);
Expand Down Expand Up @@ -1670,7 +1670,7 @@ fn check_for_mutation(
fn pat_is_wild<'tcx>(pat: &'tcx PatKind, body: &'tcx Expr) -> bool {
match *pat {
PatKind::Wild => true,
PatKind::Binding(_, _, ident, None) if ident.as_str().starts_with('_') => {
PatKind::Binding(.., ident, None) if ident.as_str().starts_with('_') => {
let mut visitor = UsedVisitor {
var: ident.name,
used: false,
Expand Down Expand Up @@ -2095,7 +2095,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
// Look for declarations of the variable
if let StmtKind::Local(ref local) = stmt.node {
if local.pat.id == self.var_id {
if let PatKind::Binding(_, _, ident, _) = local.pat.node {
if let PatKind::Binding(.., ident, _) = local.pat.node {
self.name = Some(ident.name);

self.state = if let Some(ref init) = local.init {
Expand Down Expand Up @@ -2286,7 +2286,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor {
if self.nesting != Unknown {
return;
}
if let PatKind::Binding(_, _, span_name, _) = pat.node {
if let PatKind::Binding(.., span_name, _) = pat.node {
if self.iterator == span_name.name {
self.nesting = RuledOut;
return;
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
then {
match closure_body.arguments[0].pat.node {
hir::PatKind::Ref(ref inner, _) => if let hir::PatKind::Binding(
hir::BindingAnnotation::Unannotated, _, name, None
hir::BindingAnnotation::Unannotated, .., name, None
) = inner.node {
if ident_eq(name, closure_expr) {
lint(cx, e.span, args[0].span);
}
},
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => {
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, .., name, None) => {
match closure_expr.node {
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => {
if ident_eq(name, inner) && !cx.tables.expr_ty(inner).is_box() {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ fn check_single_match_opt_like(
}
print::to_string(print::NO_ANN, |s| s.print_qpath(path, false))
},
PatKind::Binding(BindingAnnotation::Unannotated, _, ident, None) => ident.to_string(),
PatKind::Binding(BindingAnnotation::Unannotated, .., ident, None) => ident.to_string(),
PatKind::Path(ref path) => print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)),
_ => return,
};
Expand Down Expand Up @@ -657,7 +657,7 @@ fn is_ref_some_arm(arm: &Arm) -> Option<BindingAnnotation> {
if_chain! {
if let PatKind::TupleStruct(ref path, ref pats, _) = arm.pats[0].node;
if pats.len() == 1 && match_qpath(path, &paths::OPTION_SOME);
if let PatKind::Binding(rb, _, ident, _) = pats[0].node;
if let PatKind::Binding(rb, .., ident, _) = pats[0].node;
if rb == BindingAnnotation::Ref || rb == BindingAnnotation::RefMut;
if let ExprKind::Call(ref e, ref args) = remove_blocks(&arm.body).node;
if let ExprKind::Path(ref some_path) = e.node;
Expand Down
7 changes: 3 additions & 4 deletions clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
}
for arg in iter_input_pats(decl, body) {
match arg.pat.node {
PatKind::Binding(BindingAnnotation::Ref, _, _, _)
| PatKind::Binding(BindingAnnotation::RefMut, _, _, _) => {
PatKind::Binding(BindingAnnotation::Ref, ..) | PatKind::Binding(BindingAnnotation::RefMut, ..) => {
span_lint(
cx,
TOPLEVEL_REF_ARG,
Expand All @@ -282,7 +281,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) {
if_chain! {
if let StmtKind::Local(ref l) = s.node;
if let PatKind::Binding(an, _, i, None) = l.pat.node;
if let PatKind::Binding(an, .., i, None) = l.pat.node;
if let Some(ref init) = l.init;
then {
if an == BindingAnnotation::Ref || an == BindingAnnotation::RefMut {
Expand Down Expand Up @@ -445,7 +444,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
}

fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
if let PatKind::Binding(_, _, ident, Some(ref right)) = pat.node {
if let PatKind::Binding(.., ident, Some(ref right)) = pat.node {
if let PatKind::Wild = right.node {
span_lint(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
return;
}
if_chain! {
if let PatKind::Binding(BindingAnnotation::Ref, _, name, _) = pat.node;
if let PatKind::Binding(BindingAnnotation::Ref, .., name, _) = pat.node;
if let ty::Ref(_, tam, mutbl) = cx.tables.pat_ty(pat).sty;
if mutbl == MutImmutable;
if let ty::Ref(_, _, mutbl) = tam.sty;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_borrowed_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef {
if let PatKind::Ref(ref sub_pat, MutImmutable) = pat.node;

// Check sub_pat got a `ref` keyword (excluding `ref mut`).
if let PatKind::Binding(BindingAnnotation::Ref, _, spanned_name, ..) = sub_pat.node;
if let PatKind::Binding(BindingAnnotation::Ref, .., spanned_name, _) = sub_pat.node;
then {
span_lint_and_then(cx, NEEDLESS_BORROWED_REFERENCE, pat.span,
"this pattern takes a reference on something that is being de-referenced",
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {

// Ignore `self`s.
if idx == 0 {
if let PatKind::Binding(_, _, ident, ..) = arg.pat.node {
if let PatKind::Binding(.., ident, _) = arg.pat.node {
if ident.as_str() == "self" {
continue;
}
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 @@ -108,7 +108,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, body: &'tcx Body) {
let mut bindings = Vec::new();
for arg in iter_input_pats(decl, body) {
if let PatKind::Binding(_, _, ident, _) = arg.pat.node {
if let PatKind::Binding(.., ident, _) = arg.pat.node {
bindings.push((ident.name, ident.span))
}
}
Expand Down Expand Up @@ -172,7 +172,7 @@ fn check_pat<'a, 'tcx>(
) {
// TODO: match more stuff / destructuring
match pat.node {
PatKind::Binding(_, _, ident, ref inner) => {
PatKind::Binding(.., ident, ref inner) => {
let name = ident.name;
if is_binding(cx, pat.hir_id) {
let mut new_binding = true;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/slow_vector_initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
// Matches statements which initializes vectors. For example: `let mut vec = Vec::with_capacity(10)`
if_chain! {
if let StmtKind::Local(ref local) = stmt.node;
if let PatKind::Binding(BindingAnnotation::Mutable, _, variable_name, None) = local.pat.node;
if let PatKind::Binding(BindingAnnotation::Mutable, .., variable_name, None) = local.pat.node;
if let Some(ref init) = local.init;
if let Some(ref len_arg) = Self::is_vec_with_capacity(init);

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) {
// let t = foo();
if let StmtKind::Local(ref tmp) = w[0].node;
if let Some(ref tmp_init) = tmp.init;
if let PatKind::Binding(_, _, ident, None) = tmp.pat.node;
if let PatKind::Binding(.., ident, None) = tmp.pat.node;

// foo() = bar();
if let StmtKind::Semi(ref first) = w[1].node;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
let current = format!("{}.node", self.current);
match pat.node {
PatKind::Wild => println!("Wild = {};", current),
PatKind::Binding(anno, _, ident, ref sub) => {
PatKind::Binding(anno, .., ident, ref sub) => {
let anno_pat = match anno {
BindingAnnotation::Unannotated => "BindingAnnotation::Unannotated",
BindingAnnotation::Mutable => "BindingAnnotation::Mutable",
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
(&PatKind::TupleStruct(ref lp, ref la, ls), &PatKind::TupleStruct(ref rp, ref ra, rs)) => {
self.eq_qpath(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs
},
(&PatKind::Binding(ref lb, _, ref li, ref lp), &PatKind::Binding(ref rb, _, ref ri, ref rp)) => {
(&PatKind::Binding(ref lb, .., ref li, ref lp), &PatKind::Binding(ref rb, .., ref ri, ref rp)) => {
lb == rb && li.name.as_str() == ri.name.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
},
(&PatKind::Path(ref l), &PatKind::Path(ref r)) => self.eq_qpath(l, r),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ fn print_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat, indent: usize) {
println!("{}+", ind);
match pat.node {
hir::PatKind::Wild => println!("{}Wild", ind),
hir::PatKind::Binding(ref mode, _, ident, ref inner) => {
hir::PatKind::Binding(ref mode, .., ident, ref inner) => {
println!("{}Binding", ind);
println!("{}mode: {:?}", ind, mode);
println!("{}name: {}", ind, ident.name);
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Name> {
/// Get the name of a `Pat`, if any
pub fn get_pat_name(pat: &Pat) -> Option<Name> {
match pat.node {
PatKind::Binding(_, _, ref spname, _) => Some(spname.name),
PatKind::Binding(.., ref spname, _) => Some(spname.name),
PatKind::Path(ref qpath) => single_segment_path(qpath).map(|ps| ps.ident.name),
PatKind::Box(ref p) | PatKind::Ref(ref p, _) => get_pat_name(&*p),
_ => None,
Expand Down Expand Up @@ -1008,7 +1008,7 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {
}

pub fn is_self(slf: &Arg) -> bool {
if let PatKind::Binding(_, _, name, _) = slf.pat.node {
if let PatKind::Binding(.., name, _) = slf.pat.node {
name.name == keywords::SelfLower.name()
} else {
false
Expand Down Expand Up @@ -1038,7 +1038,7 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> {
if_chain! {
if let PatKind::TupleStruct(ref path, ref pat, None) = arm.pats[0].node;
if match_qpath(path, &paths::RESULT_OK[1..]);
if let PatKind::Binding(_, defid, _, None) = pat[0].node;
if let PatKind::Binding(_, defid, _, _, None) = pat[0].node;
if let ExprKind::Path(QPath::Resolved(None, ref path)) = arm.body.node;
if let Def::Local(lid) = path.def;
if lid == defid;
Expand Down Expand Up @@ -1087,7 +1087,7 @@ pub fn is_allowed(cx: &LateContext<'_, '_>, lint: &'static Lint, id: NodeId) ->

pub fn get_arg_name(pat: &Pat) -> Option<ast::Name> {
match pat.node {
PatKind::Binding(_, _, ident, None) => Some(ident.name),
PatKind::Binding(.., ident, None) => Some(ident.name),
PatKind::Ref(ref subpat, _) => get_arg_name(subpat),
_ => None,
}
Expand Down