Skip to content

Commit

Permalink
Auto merge of #36203 - petrochenkov:uvsdot, r=nrc
Browse files Browse the repository at this point in the history
Replace `_, _` with `..` in patterns

This is how #33627 looks in action.

Looks especially nice in leftmost/rightmost positions `(first, ..)`/`(.., last)`.
I haven't touched libsyntax intentionally because the feature is still unstable.
  • Loading branch information
bors committed Sep 4, 2016
2 parents 9cc430d + e05e74a commit 91f057d
Show file tree
Hide file tree
Showing 128 changed files with 392 additions and 374 deletions.
2 changes: 1 addition & 1 deletion src/libgetopts/lib.rs
Expand Up @@ -279,7 +279,7 @@ impl OptGroup {
}],
}
}
(_, _) => panic!("something is wrong with the long-form opt"),
_ => panic!("something is wrong with the long-form opt"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/cfg/construct.rs
Expand Up @@ -99,7 +99,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {

fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
match pat.node {
PatKind::Binding(_, _, None) |
PatKind::Binding(.., None) |
PatKind::Path(..) |
PatKind::Lit(..) |
PatKind::Range(..) |
Expand All @@ -109,7 +109,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {

PatKind::Box(ref subpat) |
PatKind::Ref(ref subpat, _) |
PatKind::Binding(_, _, Some(ref subpat)) => {
PatKind::Binding(.., Some(ref subpat)) => {
let subpat_exit = self.pat(&subpat, pred);
self.add_ast_node(pat.id, &[subpat_exit])
}
Expand Down Expand Up @@ -306,7 +306,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
self.call(expr, pred, &func, args.iter().map(|e| &**e))
}

hir::ExprMethodCall(_, _, ref args) => {
hir::ExprMethodCall(.., ref args) => {
self.call(expr, pred, &args[0], args[1..].iter().map(|e| &**e))
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/def.rs
Expand Up @@ -104,7 +104,7 @@ impl Def {
pub fn var_id(&self) -> ast::NodeId {
match *self {
Def::Local(_, id) |
Def::Upvar(_, id, _, _) => {
Def::Upvar(_, id, ..) => {
id
}

Expand All @@ -124,7 +124,7 @@ impl Def {
Def::Variant(_, id) | Def::Enum(id) | Def::TyAlias(id) | Def::AssociatedTy(_, id) |
Def::TyParam(id) | Def::Struct(id) | Def::Union(id) | Def::Trait(id) |
Def::Method(id) | Def::Const(id) | Def::AssociatedConst(id) |
Def::Local(id, _) | Def::Upvar(id, _, _, _) => {
Def::Local(id, _) | Def::Upvar(id, ..) => {
id
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/hir/intravisit.rs
Expand Up @@ -49,8 +49,8 @@ pub enum FnKind<'a> {
impl<'a> FnKind<'a> {
pub fn attrs(&self) -> &'a [Attribute] {
match *self {
FnKind::ItemFn(_, _, _, _, _, _, attrs) => attrs,
FnKind::Method(_, _, _, attrs) => attrs,
FnKind::ItemFn(.., attrs) => attrs,
FnKind::Method(.., attrs) => attrs,
FnKind::Closure(attrs) => attrs,
}
}
Expand Down Expand Up @@ -341,7 +341,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
visitor.visit_id(item.id);
visitor.visit_trait_ref(trait_ref)
}
ItemImpl(_, _, ref type_parameters, ref opt_trait_reference, ref typ, ref impl_items) => {
ItemImpl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_items) => {
visitor.visit_id(item.id);
visitor.visit_generics(type_parameters);
walk_list!(visitor, visit_trait_ref, opt_trait_reference);
Expand Down Expand Up @@ -622,10 +622,10 @@ pub fn walk_fn_decl_nopat<'v, V: Visitor<'v>>(visitor: &mut V, function_declarat

pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V, function_kind: FnKind<'v>) {
match function_kind {
FnKind::ItemFn(_, generics, _, _, _, _, _) => {
FnKind::ItemFn(_, generics, ..) => {
visitor.visit_generics(generics);
}
FnKind::Method(_, sig, _, _) => {
FnKind::Method(_, sig, ..) => {
visitor.visit_generics(&sig.generics);
}
FnKind::Closure(_) => {}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/collector.rs
Expand Up @@ -109,7 +109,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
this.insert(struct_def.id(), NodeStructCtor(struct_def));
}
}
ItemTrait(_, _, ref bounds, _) => {
ItemTrait(.., ref bounds, _) => {
for b in bounds.iter() {
if let TraitTyParamBound(ref t, TraitBoundModifier::None) = *b {
this.insert(t.trait_ref.ref_id, NodeItem(i));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/mod.rs
Expand Up @@ -469,7 +469,7 @@ impl Pat {
}

match self.node {
PatKind::Binding(_, _, Some(ref p)) => p.walk_(it),
PatKind::Binding(.., Some(ref p)) => p.walk_(it),
PatKind::Struct(_, ref fields, _) => {
fields.iter().all(|field| field.node.pat.walk_(it))
}
Expand All @@ -486,7 +486,7 @@ impl Pat {
}
PatKind::Wild |
PatKind::Lit(_) |
PatKind::Range(_, _) |
PatKind::Range(..) |
PatKind::Binding(..) |
PatKind::Path(..) => {
true
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/pat_util.rs
Expand Up @@ -53,7 +53,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {

pub fn pat_is_refutable(dm: &DefMap, pat: &hir::Pat) -> bool {
match pat.node {
PatKind::Lit(_) | PatKind::Range(_, _) | PatKind::Path(Some(..), _) => true,
PatKind::Lit(_) | PatKind::Range(..) | PatKind::Path(Some(..), _) => true,
PatKind::TupleStruct(..) |
PatKind::Path(..) |
PatKind::Struct(..) => {
Expand All @@ -62,7 +62,7 @@ pub fn pat_is_refutable(dm: &DefMap, pat: &hir::Pat) -> bool {
_ => false
}
}
PatKind::Vec(_, _, _) => true,
PatKind::Vec(..) => true,
_ => false
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/infer/error_reporting.rs
Expand Up @@ -140,9 +140,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
Some(ast_map::NodeExpr(expr)) => match expr.node {
hir::ExprCall(..) => "call",
hir::ExprMethodCall(..) => "method call",
hir::ExprMatch(_, _, hir::MatchSource::IfLetDesugar { .. }) => "if let",
hir::ExprMatch(_, _, hir::MatchSource::WhileLetDesugar) => "while let",
hir::ExprMatch(_, _, hir::MatchSource::ForLoopDesugar) => "for",
hir::ExprMatch(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
hir::ExprMatch(.., hir::MatchSource::WhileLetDesugar) => "while let",
hir::ExprMatch(.., hir::MatchSource::ForLoopDesugar) => "for",
hir::ExprMatch(..) => "match",
_ => "expression",
},
Expand Down Expand Up @@ -1787,7 +1787,7 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
let method_id_opt = match tcx.map.find(parent) {
Some(node) => match node {
ast_map::NodeItem(item) => match item.node {
hir::ItemFn(_, _, _, _, ref gen, _) => {
hir::ItemFn(.., ref gen, _) => {
taken.extend_from_slice(&gen.lifetimes);
None
},
Expand All @@ -1811,7 +1811,7 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
if let Some(node) = tcx.map.find(parent) {
match node {
ast_map::NodeItem(item) => match item.node {
hir::ItemImpl(_, _, ref gen, _, _, _) => {
hir::ItemImpl(_, _, ref gen, ..) => {
taken.extend_from_slice(&gen.lifetimes);
}
_ => ()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/higher_ranked/mod.rs
Expand Up @@ -684,7 +684,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
warnings.extend(
match self.region_vars.var_origin(vid) {
LateBoundRegion(_,
ty::BrNamed(_, _, wc),
ty::BrNamed(.., wc),
_) => Some(wc),
_ => None,
});
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/infer/mod.rs
Expand Up @@ -225,7 +225,7 @@ impl TypeOrigin {
&TypeOrigin::RelateOutputImplTypes(_) |
&TypeOrigin::ExprAssignable(_) => "mismatched types",
&TypeOrigin::MethodCompatCheck(_) => "method not compatible with trait",
&TypeOrigin::MatchExpressionArm(_, _, source) => match source {
&TypeOrigin::MatchExpressionArm(.., source) => match source {
hir::MatchSource::IfLetDesugar{..} => "`if let` arms have incompatible types",
_ => "match arms have incompatible types",
},
Expand All @@ -248,7 +248,7 @@ impl TypeOrigin {
&TypeOrigin::RelateOutputImplTypes(_) => {
"trait type parameters matches those specified on the impl"
}
&TypeOrigin::MatchExpressionArm(_, _, _) => "match arms have compatible types",
&TypeOrigin::MatchExpressionArm(..) => "match arms have compatible types",
&TypeOrigin::IfExpression(_) => "if and else have compatible types",
&TypeOrigin::IfExpressionWithNoElse(_) => "if missing an else returns ()",
&TypeOrigin::RangeExpression(_) => "start and end of range have compatible types",
Expand Down Expand Up @@ -1712,7 +1712,7 @@ impl TypeOrigin {
TypeOrigin::ExprAssignable(span) => span,
TypeOrigin::Misc(span) => span,
TypeOrigin::RelateOutputImplTypes(span) => span,
TypeOrigin::MatchExpressionArm(match_span, _, _) => match_span,
TypeOrigin::MatchExpressionArm(match_span, ..) => match_span,
TypeOrigin::IfExpression(span) => span,
TypeOrigin::IfExpressionWithNoElse(span) => span,
TypeOrigin::RangeExpression(span) => span,
Expand Down Expand Up @@ -1765,7 +1765,7 @@ impl RegionVariableOrigin {
Autoref(a) => a,
Coercion(a) => a,
EarlyBoundRegion(a, _) => a,
LateBoundRegion(a, _, _) => a,
LateBoundRegion(a, ..) => a,
BoundRegionInCoherence(_) => syntax_pos::DUMMY_SP,
UpvarRegion(_, a) => a
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/region_inference/mod.rs
Expand Up @@ -605,15 +605,15 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
undo_entry: &UndoLogEntry<'tcx>)
-> bool {
match undo_entry {
&AddConstraint(ConstrainVarSubVar(_, _)) =>
&AddConstraint(ConstrainVarSubVar(..)) =>
false,
&AddConstraint(ConstrainRegSubVar(a, _)) =>
skols.contains(&a),
&AddConstraint(ConstrainVarSubReg(_, b)) =>
skols.contains(&b),
&AddConstraint(ConstrainRegSubReg(a, b)) =>
skols.contains(&a) || skols.contains(&b),
&AddGiven(_, _) =>
&AddGiven(..) =>
false,
&AddVerify(_) =>
false,
Expand Down Expand Up @@ -1372,7 +1372,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
(&ReFree(..), &ReFree(..)) => Equal,
(&ReFree(..), _) => Less,
(_, &ReFree(..)) => Greater,
(_, _) => Equal,
(..) => Equal,
}
}
lower_bounds.sort_by(|a, b| free_regions_first(a, b));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/type_variable.rs
Expand Up @@ -267,7 +267,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
debug!("NewElem({}) new_elem_threshold={}", index, new_elem_threshold);
}

sv::UndoLog::Other(SpecifyVar(vid, _, _)) => {
sv::UndoLog::Other(SpecifyVar(vid, ..)) => {
if vid.index < new_elem_threshold {
// quick check to see if this variable was
// created since the snapshot started or not.
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Expand Up @@ -30,6 +30,7 @@
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(dotdot_in_tuple_patterns)]
#![feature(enumset)]
#![feature(libc)]
#![feature(nonzero)]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/dead.rs
Expand Up @@ -344,7 +344,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
self.worklist.extend(enum_def.variants.iter()
.map(|variant| variant.node.data.id()));
}
hir::ItemTrait(_, _, _, ref trait_items) => {
hir::ItemTrait(.., ref trait_items) => {
for trait_item in trait_items {
match trait_item.node {
hir::ConstTraitItem(_, Some(_)) |
Expand All @@ -357,7 +357,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
}
}
}
hir::ItemImpl(_, _, _, ref opt_trait, _, ref impl_items) => {
hir::ItemImpl(.., ref opt_trait, _, ref impl_items) => {
for impl_item in impl_items {
if opt_trait.is_some() ||
has_allow_dead_code_or_lang_attr(&impl_item.attrs) {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/effect.rs
Expand Up @@ -43,7 +43,7 @@ enum RootUnsafeContext {

fn type_is_unsafe_function(ty: Ty) -> bool {
match ty.sty {
ty::TyFnDef(_, _, ref f) |
ty::TyFnDef(.., ref f) |
ty::TyFnPtr(ref f) => f.unsafety == hir::Unsafety::Unsafe,
_ => false,
}
Expand Down Expand Up @@ -83,9 +83,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
block: &'v hir::Block, span: Span, id: ast::NodeId) {

let (is_item_fn, is_unsafe_fn) = match fn_kind {
FnKind::ItemFn(_, _, unsafety, _, _, _, _) =>
FnKind::ItemFn(_, _, unsafety, ..) =>
(true, unsafety == hir::Unsafety::Unsafe),
FnKind::Method(_, sig, _, _) =>
FnKind::Method(_, sig, ..) =>
(true, sig.unsafety == hir::Unsafety::Unsafe),
_ => (false, false),
};
Expand Down Expand Up @@ -143,7 +143,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {

fn visit_expr(&mut self, expr: &hir::Expr) {
match expr.node {
hir::ExprMethodCall(_, _, _) => {
hir::ExprMethodCall(..) => {
let method_call = MethodCall::expr(expr.id);
let base_type = self.tcx.tables.borrow().method_map[&method_call].ty;
debug!("effect: method call case, base type is {:?}",
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/expr_use_visitor.rs
Expand Up @@ -409,7 +409,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.consume_exprs(args);
}

hir::ExprMethodCall(_, _, ref args) => { // callee.m(args)
hir::ExprMethodCall(.., ref args) => { // callee.m(args)
self.consume_exprs(args);
}

Expand Down Expand Up @@ -544,7 +544,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.consume_expr(&count);
}

hir::ExprClosure(_, _, _, fn_decl_span) => {
hir::ExprClosure(.., fn_decl_span) => {
self.walk_captures(expr, fn_decl_span)
}

Expand Down Expand Up @@ -940,9 +940,9 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
pat);
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| {
match pat.node {
PatKind::Binding(hir::BindByRef(..), _, _) =>
PatKind::Binding(hir::BindByRef(..), ..) =>
mode.lub(BorrowingMatch),
PatKind::Binding(hir::BindByValue(..), _, _) => {
PatKind::Binding(hir::BindByValue(..), ..) => {
match copy_or_move(self.mc.infcx, &cmt_pat, PatBindingMove) {
Copy => mode.lub(CopyingMatch),
Move(..) => mode.lub(MovingMatch),
Expand All @@ -964,7 +964,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
let infcx = self.mc.infcx;
let delegate = &mut self.delegate;
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
if let PatKind::Binding(bmode, _, _) = pat.node {
if let PatKind::Binding(bmode, ..) = pat.node {
debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}", cmt_pat, pat, match_mode);

// pat_ty: the type of the binding being produced.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/intrinsicck.rs
Expand Up @@ -52,7 +52,7 @@ struct ExprVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
let intrinsic = match self.infcx.tcx.lookup_item_type(def_id).ty.sty {
ty::TyFnDef(_, _, ref bfty) => bfty.abi == RustIntrinsic,
ty::TyFnDef(.., ref bfty) => bfty.abi == RustIntrinsic,
_ => return false
};
intrinsic && self.infcx.tcx.item_name(def_id).as_str() == "transmute"
Expand Down Expand Up @@ -160,7 +160,7 @@ impl<'a, 'gcx, 'tcx, 'v> Visitor<'v> for ExprVisitor<'a, 'gcx, 'tcx> {
Def::Fn(did) if self.def_id_is_transmute(did) => {
let typ = self.infcx.tcx.node_id_to_type(expr.id);
match typ.sty {
ty::TyFnDef(_, _, ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
ty::TyFnDef(.., ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
let from = bare_fn_ty.sig.0.inputs[0];
let to = bare_fn_ty.sig.0.output;
self.check_transmute(expr.span, from, to, expr.id);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/liveness.rs
Expand Up @@ -482,7 +482,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
intravisit::walk_expr(ir, expr);
}
hir::ExprBinary(op, _, _) if op.node.is_lazy() => {
hir::ExprBinary(op, ..) if op.node.is_lazy() => {
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
intravisit::walk_expr(ir, expr);
}
Expand Down Expand Up @@ -943,7 +943,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
self.propagate_through_expr(&e, succ)
}

hir::ExprClosure(_, _, ref blk, _) => {
hir::ExprClosure(.., ref blk, _) => {
debug!("{} is an ExprClosure",
expr_to_string(expr));

Expand Down Expand Up @@ -1123,7 +1123,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
self.propagate_through_expr(&f, succ)
}

hir::ExprMethodCall(_, _, ref args) => {
hir::ExprMethodCall(.., ref args) => {
let method_call = ty::MethodCall::expr(expr.id);
let method_ty = self.ir.tcx.tables.borrow().method_map[&method_call].ty;
// FIXME(canndrew): This is_never should really be an is_uninhabited
Expand Down

0 comments on commit 91f057d

Please sign in to comment.