Skip to content

Commit 91f057d

Browse files
authored
Auto merge of #36203 - petrochenkov:uvsdot, r=nrc
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.
2 parents 9cc430d + e05e74a commit 91f057d

File tree

128 files changed

+392
-374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+392
-374
lines changed

src/libgetopts/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl OptGroup {
279279
}],
280280
}
281281
}
282-
(_, _) => panic!("something is wrong with the long-form opt"),
282+
_ => panic!("something is wrong with the long-form opt"),
283283
}
284284
}
285285
}

src/librustc/cfg/construct.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
9999

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

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

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

src/librustc/hir/def.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Def {
104104
pub fn var_id(&self) -> ast::NodeId {
105105
match *self {
106106
Def::Local(_, id) |
107-
Def::Upvar(_, id, _, _) => {
107+
Def::Upvar(_, id, ..) => {
108108
id
109109
}
110110

@@ -124,7 +124,7 @@ impl Def {
124124
Def::Variant(_, id) | Def::Enum(id) | Def::TyAlias(id) | Def::AssociatedTy(_, id) |
125125
Def::TyParam(id) | Def::Struct(id) | Def::Union(id) | Def::Trait(id) |
126126
Def::Method(id) | Def::Const(id) | Def::AssociatedConst(id) |
127-
Def::Local(id, _) | Def::Upvar(id, _, _, _) => {
127+
Def::Local(id, _) | Def::Upvar(id, ..) => {
128128
id
129129
}
130130

src/librustc/hir/intravisit.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pub enum FnKind<'a> {
4949
impl<'a> FnKind<'a> {
5050
pub fn attrs(&self) -> &'a [Attribute] {
5151
match *self {
52-
FnKind::ItemFn(_, _, _, _, _, _, attrs) => attrs,
53-
FnKind::Method(_, _, _, attrs) => attrs,
52+
FnKind::ItemFn(.., attrs) => attrs,
53+
FnKind::Method(.., attrs) => attrs,
5454
FnKind::Closure(attrs) => attrs,
5555
}
5656
}
@@ -341,7 +341,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
341341
visitor.visit_id(item.id);
342342
visitor.visit_trait_ref(trait_ref)
343343
}
344-
ItemImpl(_, _, ref type_parameters, ref opt_trait_reference, ref typ, ref impl_items) => {
344+
ItemImpl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_items) => {
345345
visitor.visit_id(item.id);
346346
visitor.visit_generics(type_parameters);
347347
walk_list!(visitor, visit_trait_ref, opt_trait_reference);
@@ -622,10 +622,10 @@ pub fn walk_fn_decl_nopat<'v, V: Visitor<'v>>(visitor: &mut V, function_declarat
622622

623623
pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V, function_kind: FnKind<'v>) {
624624
match function_kind {
625-
FnKind::ItemFn(_, generics, _, _, _, _, _) => {
625+
FnKind::ItemFn(_, generics, ..) => {
626626
visitor.visit_generics(generics);
627627
}
628-
FnKind::Method(_, sig, _, _) => {
628+
FnKind::Method(_, sig, ..) => {
629629
visitor.visit_generics(&sig.generics);
630630
}
631631
FnKind::Closure(_) => {}

src/librustc/hir/map/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
109109
this.insert(struct_def.id(), NodeStructCtor(struct_def));
110110
}
111111
}
112-
ItemTrait(_, _, ref bounds, _) => {
112+
ItemTrait(.., ref bounds, _) => {
113113
for b in bounds.iter() {
114114
if let TraitTyParamBound(ref t, TraitBoundModifier::None) = *b {
115115
this.insert(t.trait_ref.ref_id, NodeItem(i));

src/librustc/hir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl Pat {
469469
}
470470

471471
match self.node {
472-
PatKind::Binding(_, _, Some(ref p)) => p.walk_(it),
472+
PatKind::Binding(.., Some(ref p)) => p.walk_(it),
473473
PatKind::Struct(_, ref fields, _) => {
474474
fields.iter().all(|field| field.node.pat.walk_(it))
475475
}
@@ -486,7 +486,7 @@ impl Pat {
486486
}
487487
PatKind::Wild |
488488
PatKind::Lit(_) |
489-
PatKind::Range(_, _) |
489+
PatKind::Range(..) |
490490
PatKind::Binding(..) |
491491
PatKind::Path(..) => {
492492
true

src/librustc/hir/pat_util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
5353

5454
pub fn pat_is_refutable(dm: &DefMap, pat: &hir::Pat) -> bool {
5555
match pat.node {
56-
PatKind::Lit(_) | PatKind::Range(_, _) | PatKind::Path(Some(..), _) => true,
56+
PatKind::Lit(_) | PatKind::Range(..) | PatKind::Path(Some(..), _) => true,
5757
PatKind::TupleStruct(..) |
5858
PatKind::Path(..) |
5959
PatKind::Struct(..) => {
@@ -62,7 +62,7 @@ pub fn pat_is_refutable(dm: &DefMap, pat: &hir::Pat) -> bool {
6262
_ => false
6363
}
6464
}
65-
PatKind::Vec(_, _, _) => true,
65+
PatKind::Vec(..) => true,
6666
_ => false
6767
}
6868
}

src/librustc/infer/error_reporting.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
140140
Some(ast_map::NodeExpr(expr)) => match expr.node {
141141
hir::ExprCall(..) => "call",
142142
hir::ExprMethodCall(..) => "method call",
143-
hir::ExprMatch(_, _, hir::MatchSource::IfLetDesugar { .. }) => "if let",
144-
hir::ExprMatch(_, _, hir::MatchSource::WhileLetDesugar) => "while let",
145-
hir::ExprMatch(_, _, hir::MatchSource::ForLoopDesugar) => "for",
143+
hir::ExprMatch(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
144+
hir::ExprMatch(.., hir::MatchSource::WhileLetDesugar) => "while let",
145+
hir::ExprMatch(.., hir::MatchSource::ForLoopDesugar) => "for",
146146
hir::ExprMatch(..) => "match",
147147
_ => "expression",
148148
},
@@ -1787,7 +1787,7 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
17871787
let method_id_opt = match tcx.map.find(parent) {
17881788
Some(node) => match node {
17891789
ast_map::NodeItem(item) => match item.node {
1790-
hir::ItemFn(_, _, _, _, ref gen, _) => {
1790+
hir::ItemFn(.., ref gen, _) => {
17911791
taken.extend_from_slice(&gen.lifetimes);
17921792
None
17931793
},
@@ -1811,7 +1811,7 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
18111811
if let Some(node) = tcx.map.find(parent) {
18121812
match node {
18131813
ast_map::NodeItem(item) => match item.node {
1814-
hir::ItemImpl(_, _, ref gen, _, _, _) => {
1814+
hir::ItemImpl(_, _, ref gen, ..) => {
18151815
taken.extend_from_slice(&gen.lifetimes);
18161816
}
18171817
_ => ()

src/librustc/infer/higher_ranked/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
684684
warnings.extend(
685685
match self.region_vars.var_origin(vid) {
686686
LateBoundRegion(_,
687-
ty::BrNamed(_, _, wc),
687+
ty::BrNamed(.., wc),
688688
_) => Some(wc),
689689
_ => None,
690690
});

src/librustc/infer/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl TypeOrigin {
225225
&TypeOrigin::RelateOutputImplTypes(_) |
226226
&TypeOrigin::ExprAssignable(_) => "mismatched types",
227227
&TypeOrigin::MethodCompatCheck(_) => "method not compatible with trait",
228-
&TypeOrigin::MatchExpressionArm(_, _, source) => match source {
228+
&TypeOrigin::MatchExpressionArm(.., source) => match source {
229229
hir::MatchSource::IfLetDesugar{..} => "`if let` arms have incompatible types",
230230
_ => "match arms have incompatible types",
231231
},
@@ -248,7 +248,7 @@ impl TypeOrigin {
248248
&TypeOrigin::RelateOutputImplTypes(_) => {
249249
"trait type parameters matches those specified on the impl"
250250
}
251-
&TypeOrigin::MatchExpressionArm(_, _, _) => "match arms have compatible types",
251+
&TypeOrigin::MatchExpressionArm(..) => "match arms have compatible types",
252252
&TypeOrigin::IfExpression(_) => "if and else have compatible types",
253253
&TypeOrigin::IfExpressionWithNoElse(_) => "if missing an else returns ()",
254254
&TypeOrigin::RangeExpression(_) => "start and end of range have compatible types",
@@ -1712,7 +1712,7 @@ impl TypeOrigin {
17121712
TypeOrigin::ExprAssignable(span) => span,
17131713
TypeOrigin::Misc(span) => span,
17141714
TypeOrigin::RelateOutputImplTypes(span) => span,
1715-
TypeOrigin::MatchExpressionArm(match_span, _, _) => match_span,
1715+
TypeOrigin::MatchExpressionArm(match_span, ..) => match_span,
17161716
TypeOrigin::IfExpression(span) => span,
17171717
TypeOrigin::IfExpressionWithNoElse(span) => span,
17181718
TypeOrigin::RangeExpression(span) => span,
@@ -1765,7 +1765,7 @@ impl RegionVariableOrigin {
17651765
Autoref(a) => a,
17661766
Coercion(a) => a,
17671767
EarlyBoundRegion(a, _) => a,
1768-
LateBoundRegion(a, _, _) => a,
1768+
LateBoundRegion(a, ..) => a,
17691769
BoundRegionInCoherence(_) => syntax_pos::DUMMY_SP,
17701770
UpvarRegion(_, a) => a
17711771
}

src/librustc/infer/region_inference/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -605,15 +605,15 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
605605
undo_entry: &UndoLogEntry<'tcx>)
606606
-> bool {
607607
match undo_entry {
608-
&AddConstraint(ConstrainVarSubVar(_, _)) =>
608+
&AddConstraint(ConstrainVarSubVar(..)) =>
609609
false,
610610
&AddConstraint(ConstrainRegSubVar(a, _)) =>
611611
skols.contains(&a),
612612
&AddConstraint(ConstrainVarSubReg(_, b)) =>
613613
skols.contains(&b),
614614
&AddConstraint(ConstrainRegSubReg(a, b)) =>
615615
skols.contains(&a) || skols.contains(&b),
616-
&AddGiven(_, _) =>
616+
&AddGiven(..) =>
617617
false,
618618
&AddVerify(_) =>
619619
false,
@@ -1372,7 +1372,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
13721372
(&ReFree(..), &ReFree(..)) => Equal,
13731373
(&ReFree(..), _) => Less,
13741374
(_, &ReFree(..)) => Greater,
1375-
(_, _) => Equal,
1375+
(..) => Equal,
13761376
}
13771377
}
13781378
lower_bounds.sort_by(|a, b| free_regions_first(a, b));

src/librustc/infer/type_variable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
267267
debug!("NewElem({}) new_elem_threshold={}", index, new_elem_threshold);
268268
}
269269

270-
sv::UndoLog::Other(SpecifyVar(vid, _, _)) => {
270+
sv::UndoLog::Other(SpecifyVar(vid, ..)) => {
271271
if vid.index < new_elem_threshold {
272272
// quick check to see if this variable was
273273
// created since the snapshot started or not.

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#![feature(conservative_impl_trait)]
3131
#![feature(const_fn)]
3232
#![feature(core_intrinsics)]
33+
#![feature(dotdot_in_tuple_patterns)]
3334
#![feature(enumset)]
3435
#![feature(libc)]
3536
#![feature(nonzero)]

src/librustc/middle/dead.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
344344
self.worklist.extend(enum_def.variants.iter()
345345
.map(|variant| variant.node.data.id()));
346346
}
347-
hir::ItemTrait(_, _, _, ref trait_items) => {
347+
hir::ItemTrait(.., ref trait_items) => {
348348
for trait_item in trait_items {
349349
match trait_item.node {
350350
hir::ConstTraitItem(_, Some(_)) |
@@ -357,7 +357,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
357357
}
358358
}
359359
}
360-
hir::ItemImpl(_, _, _, ref opt_trait, _, ref impl_items) => {
360+
hir::ItemImpl(.., ref opt_trait, _, ref impl_items) => {
361361
for impl_item in impl_items {
362362
if opt_trait.is_some() ||
363363
has_allow_dead_code_or_lang_attr(&impl_item.attrs) {

src/librustc/middle/effect.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum RootUnsafeContext {
4343

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

8585
let (is_item_fn, is_unsafe_fn) = match fn_kind {
86-
FnKind::ItemFn(_, _, unsafety, _, _, _, _) =>
86+
FnKind::ItemFn(_, _, unsafety, ..) =>
8787
(true, unsafety == hir::Unsafety::Unsafe),
88-
FnKind::Method(_, sig, _, _) =>
88+
FnKind::Method(_, sig, ..) =>
8989
(true, sig.unsafety == hir::Unsafety::Unsafe),
9090
_ => (false, false),
9191
};
@@ -143,7 +143,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
143143

144144
fn visit_expr(&mut self, expr: &hir::Expr) {
145145
match expr.node {
146-
hir::ExprMethodCall(_, _, _) => {
146+
hir::ExprMethodCall(..) => {
147147
let method_call = MethodCall::expr(expr.id);
148148
let base_type = self.tcx.tables.borrow().method_map[&method_call].ty;
149149
debug!("effect: method call case, base type is {:?}",

src/librustc/middle/expr_use_visitor.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
409409
self.consume_exprs(args);
410410
}
411411

412-
hir::ExprMethodCall(_, _, ref args) => { // callee.m(args)
412+
hir::ExprMethodCall(.., ref args) => { // callee.m(args)
413413
self.consume_exprs(args);
414414
}
415415

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

547-
hir::ExprClosure(_, _, _, fn_decl_span) => {
547+
hir::ExprClosure(.., fn_decl_span) => {
548548
self.walk_captures(expr, fn_decl_span)
549549
}
550550

@@ -940,9 +940,9 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
940940
pat);
941941
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| {
942942
match pat.node {
943-
PatKind::Binding(hir::BindByRef(..), _, _) =>
943+
PatKind::Binding(hir::BindByRef(..), ..) =>
944944
mode.lub(BorrowingMatch),
945-
PatKind::Binding(hir::BindByValue(..), _, _) => {
945+
PatKind::Binding(hir::BindByValue(..), ..) => {
946946
match copy_or_move(self.mc.infcx, &cmt_pat, PatBindingMove) {
947947
Copy => mode.lub(CopyingMatch),
948948
Move(..) => mode.lub(MovingMatch),
@@ -964,7 +964,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
964964
let infcx = self.mc.infcx;
965965
let delegate = &mut self.delegate;
966966
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
967-
if let PatKind::Binding(bmode, _, _) = pat.node {
967+
if let PatKind::Binding(bmode, ..) = pat.node {
968968
debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}", cmt_pat, pat, match_mode);
969969

970970
// pat_ty: the type of the binding being produced.

src/librustc/middle/intrinsicck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct ExprVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
5252
impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
5353
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
5454
let intrinsic = match self.infcx.tcx.lookup_item_type(def_id).ty.sty {
55-
ty::TyFnDef(_, _, ref bfty) => bfty.abi == RustIntrinsic,
55+
ty::TyFnDef(.., ref bfty) => bfty.abi == RustIntrinsic,
5656
_ => return false
5757
};
5858
intrinsic && self.infcx.tcx.item_name(def_id).as_str() == "transmute"
@@ -160,7 +160,7 @@ impl<'a, 'gcx, 'tcx, 'v> Visitor<'v> for ExprVisitor<'a, 'gcx, 'tcx> {
160160
Def::Fn(did) if self.def_id_is_transmute(did) => {
161161
let typ = self.infcx.tcx.node_id_to_type(expr.id);
162162
match typ.sty {
163-
ty::TyFnDef(_, _, ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
163+
ty::TyFnDef(.., ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
164164
let from = bare_fn_ty.sig.0.inputs[0];
165165
let to = bare_fn_ty.sig.0.output;
166166
self.check_transmute(expr.span, from, to, expr.id);

src/librustc/middle/liveness.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
482482
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
483483
intravisit::walk_expr(ir, expr);
484484
}
485-
hir::ExprBinary(op, _, _) if op.node.is_lazy() => {
485+
hir::ExprBinary(op, ..) if op.node.is_lazy() => {
486486
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
487487
intravisit::walk_expr(ir, expr);
488488
}
@@ -943,7 +943,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
943943
self.propagate_through_expr(&e, succ)
944944
}
945945

946-
hir::ExprClosure(_, _, ref blk, _) => {
946+
hir::ExprClosure(.., ref blk, _) => {
947947
debug!("{} is an ExprClosure",
948948
expr_to_string(expr));
949949

@@ -1123,7 +1123,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11231123
self.propagate_through_expr(&f, succ)
11241124
}
11251125

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

0 commit comments

Comments
 (0)