Skip to content

Commit 259d1fc

Browse files
committed
Rollup merge of rust-lang#36599 - jonas-schievink:whats-a-pirates-favorite-data-structure, r=pnkfelix
Contains a syntax-[breaking-change] as a separate commit (cc rust-lang#31645).nnAlso renames slice patterns from `PatKind::Vec` to `PatKind::Slice`.
2 parents a73ba8b + bc2b283 commit 259d1fc

Some content is hidden

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

42 files changed

+121
-156
lines changed

src/librustc/cfg/construct.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
126126
self.add_ast_node(pat.id, &[pats_exit])
127127
}
128128

129-
PatKind::Vec(ref pre, ref vec, ref post) => {
129+
PatKind::Slice(ref pre, ref vec, ref post) => {
130130
let pre_exit = self.pats_all(pre.iter(), pred);
131131
let vec_exit = self.pats_all(vec.iter(), pre_exit);
132132
let post_exit = self.pats_all(post.iter(), vec_exit);
@@ -298,7 +298,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
298298
self.add_unreachable_node()
299299
}
300300

301-
hir::ExprVec(ref elems) => {
301+
hir::ExprArray(ref elems) => {
302302
self.straightline(expr, pred, elems.iter().map(|e| &**e))
303303
}
304304

src/librustc/hir/intravisit.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
394394
visitor.visit_id(typ.id);
395395

396396
match typ.node {
397-
TyVec(ref ty) => {
397+
TySlice(ref ty) => {
398398
visitor.visit_ty(ty)
399399
}
400400
TyPtr(ref mutable_type) => {
@@ -422,7 +422,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
422422
visitor.visit_ty(ty);
423423
walk_list!(visitor, visit_ty_param_bound, bounds);
424424
}
425-
TyFixedLengthVec(ref ty, ref expression) => {
425+
TyArray(ref ty, ref expression) => {
426426
visitor.visit_ty(ty);
427427
visitor.visit_expr(expression)
428428
}
@@ -520,7 +520,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
520520
visitor.visit_expr(upper_bound)
521521
}
522522
PatKind::Wild => (),
523-
PatKind::Vec(ref prepatterns, ref slice_pattern, ref postpatterns) => {
523+
PatKind::Slice(ref prepatterns, ref slice_pattern, ref postpatterns) => {
524524
walk_list!(visitor, visit_pat, prepatterns);
525525
walk_list!(visitor, visit_pat, slice_pattern);
526526
walk_list!(visitor, visit_pat, postpatterns);
@@ -749,7 +749,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
749749
ExprBox(ref subexpression) => {
750750
visitor.visit_expr(subexpression)
751751
}
752-
ExprVec(ref subexpressions) => {
752+
ExprArray(ref subexpressions) => {
753753
walk_list!(visitor, visit_expr, subexpressions);
754754
}
755755
ExprRepeat(ref element, ref count) => {

src/librustc/hir/lowering.rs

+21-20
Original file line numberDiff line numberDiff line change
@@ -222,30 +222,31 @@ impl<'a> LoweringContext<'a> {
222222
}
223223

224224
fn lower_ty(&mut self, t: &Ty) -> P<hir::Ty> {
225-
use syntax::ast::TyKind::*;
226225
P(hir::Ty {
227226
id: t.id,
228227
node: match t.node {
229-
Infer | ImplicitSelf => hir::TyInfer,
230-
Vec(ref ty) => hir::TyVec(self.lower_ty(ty)),
231-
Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt)),
232-
Rptr(ref region, ref mt) => {
228+
TyKind::Infer | TyKind::ImplicitSelf => hir::TyInfer,
229+
TyKind::Slice(ref ty) => hir::TySlice(self.lower_ty(ty)),
230+
TyKind::Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt)),
231+
TyKind::Rptr(ref region, ref mt) => {
233232
hir::TyRptr(self.lower_opt_lifetime(region), self.lower_mt(mt))
234233
}
235-
BareFn(ref f) => {
234+
TyKind::BareFn(ref f) => {
236235
hir::TyBareFn(P(hir::BareFnTy {
237236
lifetimes: self.lower_lifetime_defs(&f.lifetimes),
238237
unsafety: self.lower_unsafety(f.unsafety),
239238
abi: f.abi,
240239
decl: self.lower_fn_decl(&f.decl),
241240
}))
242241
}
243-
Never => hir::TyNever,
244-
Tup(ref tys) => hir::TyTup(tys.iter().map(|ty| self.lower_ty(ty)).collect()),
245-
Paren(ref ty) => {
242+
TyKind::Never => hir::TyNever,
243+
TyKind::Tup(ref tys) => {
244+
hir::TyTup(tys.iter().map(|ty| self.lower_ty(ty)).collect())
245+
}
246+
TyKind::Paren(ref ty) => {
246247
return self.lower_ty(ty);
247248
}
248-
Path(ref qself, ref path) => {
249+
TyKind::Path(ref qself, ref path) => {
249250
let qself = qself.as_ref().map(|&QSelf { ref ty, position }| {
250251
hir::QSelf {
251252
ty: self.lower_ty(ty),
@@ -254,22 +255,22 @@ impl<'a> LoweringContext<'a> {
254255
});
255256
hir::TyPath(qself, self.lower_path(path))
256257
}
257-
ObjectSum(ref ty, ref bounds) => {
258+
TyKind::ObjectSum(ref ty, ref bounds) => {
258259
hir::TyObjectSum(self.lower_ty(ty), self.lower_bounds(bounds))
259260
}
260-
FixedLengthVec(ref ty, ref e) => {
261-
hir::TyFixedLengthVec(self.lower_ty(ty), self.lower_expr(e))
261+
TyKind::Array(ref ty, ref e) => {
262+
hir::TyArray(self.lower_ty(ty), self.lower_expr(e))
262263
}
263-
Typeof(ref expr) => {
264+
TyKind::Typeof(ref expr) => {
264265
hir::TyTypeof(self.lower_expr(expr))
265266
}
266-
PolyTraitRef(ref bounds) => {
267+
TyKind::PolyTraitRef(ref bounds) => {
267268
hir::TyPolyTraitRef(self.lower_bounds(bounds))
268269
}
269-
ImplTrait(ref bounds) => {
270+
TyKind::ImplTrait(ref bounds) => {
270271
hir::TyImplTrait(self.lower_bounds(bounds))
271272
}
272-
Mac(_) => panic!("TyMac should have been expanded by now."),
273+
TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
273274
},
274275
span: t.span,
275276
})
@@ -891,8 +892,8 @@ impl<'a> LoweringContext<'a> {
891892
PatKind::Range(ref e1, ref e2) => {
892893
hir::PatKind::Range(self.lower_expr(e1), self.lower_expr(e2))
893894
}
894-
PatKind::Vec(ref before, ref slice, ref after) => {
895-
hir::PatKind::Vec(before.iter().map(|x| self.lower_pat(x)).collect(),
895+
PatKind::Slice(ref before, ref slice, ref after) => {
896+
hir::PatKind::Slice(before.iter().map(|x| self.lower_pat(x)).collect(),
896897
slice.as_ref().map(|x| self.lower_pat(x)),
897898
after.iter().map(|x| self.lower_pat(x)).collect())
898899
}
@@ -1031,7 +1032,7 @@ impl<'a> LoweringContext<'a> {
10311032
}
10321033

10331034
ExprKind::Vec(ref exprs) => {
1034-
hir::ExprVec(exprs.iter().map(|x| self.lower_expr(x)).collect())
1035+
hir::ExprArray(exprs.iter().map(|x| self.lower_expr(x)).collect())
10351036
}
10361037
ExprKind::Repeat(ref expr, ref count) => {
10371038
let expr = self.lower_expr(expr);

src/librustc/hir/map/def_collector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'a> visit::Visitor for DefCollector<'a> {
286286
fn visit_ty(&mut self, ty: &Ty) {
287287
match ty.node {
288288
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id, false),
289-
TyKind::FixedLengthVec(_, ref length) => self.visit_ast_const_integer(length),
289+
TyKind::Array(_, ref length) => self.visit_ast_const_integer(length),
290290
TyKind::ImplTrait(..) => {
291291
self.create_def(ty.id, DefPathData::ImplTrait);
292292
}
@@ -448,7 +448,7 @@ impl<'ast> intravisit::Visitor<'ast> for DefCollector<'ast> {
448448
}
449449

450450
fn visit_ty(&mut self, ty: &'ast hir::Ty) {
451-
if let hir::TyFixedLengthVec(_, ref length) = ty.node {
451+
if let hir::TyArray(_, ref length) = ty.node {
452452
self.visit_hir_const_integer(length);
453453
}
454454
if let hir::TyImplTrait(..) = ty.node {

src/librustc/hir/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl Pat {
478478
PatKind::Box(ref s) | PatKind::Ref(ref s, _) => {
479479
s.walk_(it)
480480
}
481-
PatKind::Vec(ref before, ref slice, ref after) => {
481+
PatKind::Slice(ref before, ref slice, ref after) => {
482482
before.iter().all(|p| p.walk_(it)) &&
483483
slice.iter().all(|p| p.walk_(it)) &&
484484
after.iter().all(|p| p.walk_(it))
@@ -554,8 +554,8 @@ pub enum PatKind {
554554
/// A range pattern, e.g. `1...2`
555555
Range(P<Expr>, P<Expr>),
556556
/// `[a, b, ..i, y, z]` is represented as:
557-
/// `PatKind::Vec(box [a, b], Some(i), box [y, z])`
558-
Vec(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),
557+
/// `PatKind::Slice(box [a, b], Some(i), box [y, z])`
558+
Slice(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),
559559
}
560560

561561
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
@@ -826,7 +826,7 @@ pub enum Expr_ {
826826
/// A `box x` expression.
827827
ExprBox(P<Expr>),
828828
/// An array (`[a, b, c, d]`)
829-
ExprVec(HirVec<P<Expr>>),
829+
ExprArray(HirVec<P<Expr>>),
830830
/// A function call
831831
///
832832
/// The first field resolves to the function itself (usually an `ExprPath`),
@@ -1080,10 +1080,10 @@ pub struct BareFnTy {
10801080
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
10811081
/// The different kinds of types recognized by the compiler
10821082
pub enum Ty_ {
1083-
/// A variable length array (`[T]`)
1084-
TyVec(P<Ty>),
1083+
/// A variable length slice (`[T]`)
1084+
TySlice(P<Ty>),
10851085
/// A fixed length array (`[T; n]`)
1086-
TyFixedLengthVec(P<Ty>, P<Expr>),
1086+
TyArray(P<Ty>, P<Expr>),
10871087
/// A raw pointer (`*const T` or `*mut T`)
10881088
TyPtr(MutTy),
10891089
/// A reference (`&'a T` or `&'a mut T`)

src/librustc/hir/pat_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -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::Slice(..) => true,
6666
_ => false
6767
}
6868
}

src/librustc/hir/print.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl<'a> State<'a> {
486486
self.maybe_print_comment(ty.span.lo)?;
487487
self.ibox(0)?;
488488
match ty.node {
489-
hir::TyVec(ref ty) => {
489+
hir::TySlice(ref ty) => {
490490
word(&mut self.s, "[")?;
491491
self.print_type(&ty)?;
492492
word(&mut self.s, "]")?;
@@ -543,7 +543,7 @@ impl<'a> State<'a> {
543543
hir::TyImplTrait(ref bounds) => {
544544
self.print_bounds("impl ", &bounds[..])?;
545545
}
546-
hir::TyFixedLengthVec(ref ty, ref v) => {
546+
hir::TyArray(ref ty, ref v) => {
547547
word(&mut self.s, "[")?;
548548
self.print_type(&ty)?;
549549
word(&mut self.s, "; ")?;
@@ -1319,7 +1319,7 @@ impl<'a> State<'a> {
13191319
self.word_space("box")?;
13201320
self.print_expr(expr)?;
13211321
}
1322-
hir::ExprVec(ref exprs) => {
1322+
hir::ExprArray(ref exprs) => {
13231323
self.print_expr_vec(&exprs[..])?;
13241324
}
13251325
hir::ExprRepeat(ref element, ref count) => {
@@ -1829,7 +1829,7 @@ impl<'a> State<'a> {
18291829
word(&mut self.s, "...")?;
18301830
self.print_expr(&end)?;
18311831
}
1832-
PatKind::Vec(ref before, ref slice, ref after) => {
1832+
PatKind::Slice(ref before, ref slice, ref after) => {
18331833
word(&mut self.s, "[")?;
18341834
self.commasep(Inconsistent, &before[..], |s, p| s.print_pat(&p))?;
18351835
if let Some(ref p) = *slice {

src/librustc/infer/error_reporting.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1433,8 +1433,8 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
14331433
hir::TyPtr(ref mut_ty) => {
14341434
ty_queue.push(&mut_ty.ty);
14351435
}
1436-
hir::TyVec(ref ty) |
1437-
hir::TyFixedLengthVec(ref ty, _) => {
1436+
hir::TySlice(ref ty) |
1437+
hir::TyArray(ref ty, _) => {
14381438
ty_queue.push(&ty);
14391439
}
14401440
hir::TyTup(ref tys) => ty_queue.extend(tys.iter().map(|ty| &**ty)),
@@ -1469,9 +1469,9 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
14691469
ty: build_to(mut_ty.ty, to),
14701470
})
14711471
}
1472-
hir::TyVec(ty) => hir::TyVec(build_to(ty, to)),
1473-
hir::TyFixedLengthVec(ty, e) => {
1474-
hir::TyFixedLengthVec(build_to(ty, to), e)
1472+
hir::TySlice(ty) => hir::TySlice(build_to(ty, to)),
1473+
hir::TyArray(ty, e) => {
1474+
hir::TyArray(build_to(ty, to), e)
14751475
}
14761476
hir::TyTup(tys) => {
14771477
hir::TyTup(tys.into_iter().map(|ty| build_to(ty, to)).collect())

src/librustc/middle/expr_use_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
442442
}
443443
}
444444

445-
hir::ExprVec(ref exprs) => {
445+
hir::ExprArray(ref exprs) => {
446446
self.consume_exprs(exprs);
447447
}
448448

src/librustc/middle/liveness.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
490490

491491
// otherwise, live nodes are not required:
492492
hir::ExprIndex(..) | hir::ExprField(..) | hir::ExprTupField(..) |
493-
hir::ExprVec(..) | hir::ExprCall(..) | hir::ExprMethodCall(..) |
493+
hir::ExprArray(..) | hir::ExprCall(..) | hir::ExprMethodCall(..) |
494494
hir::ExprTup(..) | hir::ExprBinary(..) | hir::ExprAddrOf(..) |
495495
hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprBreak(_) |
496496
hir::ExprAgain(_) | hir::ExprLit(_) | hir::ExprRet(..) |
@@ -1095,7 +1095,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
10951095

10961096
// Uninteresting cases: just propagate in rev exec order
10971097

1098-
hir::ExprVec(ref exprs) => {
1098+
hir::ExprArray(ref exprs) => {
10991099
self.propagate_through_exprs(&exprs[..], succ)
11001100
}
11011101

@@ -1436,7 +1436,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14361436
hir::ExprCall(..) | hir::ExprMethodCall(..) | hir::ExprIf(..) |
14371437
hir::ExprMatch(..) | hir::ExprWhile(..) | hir::ExprLoop(..) |
14381438
hir::ExprIndex(..) | hir::ExprField(..) | hir::ExprTupField(..) |
1439-
hir::ExprVec(..) | hir::ExprTup(..) | hir::ExprBinary(..) |
1439+
hir::ExprArray(..) | hir::ExprTup(..) | hir::ExprBinary(..) |
14401440
hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprRet(..) |
14411441
hir::ExprBreak(..) | hir::ExprAgain(..) | hir::ExprLit(_) |
14421442
hir::ExprBlock(..) | hir::ExprAddrOf(..) |

src/librustc/middle/mem_categorization.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
503503
hir::ExprClosure(..) | hir::ExprRet(..) |
504504
hir::ExprUnary(..) |
505505
hir::ExprMethodCall(..) | hir::ExprCast(..) |
506-
hir::ExprVec(..) | hir::ExprTup(..) | hir::ExprIf(..) |
506+
hir::ExprArray(..) | hir::ExprTup(..) | hir::ExprIf(..) |
507507
hir::ExprBinary(..) | hir::ExprWhile(..) |
508508
hir::ExprBlock(..) | hir::ExprLoop(..) | hir::ExprMatch(..) |
509509
hir::ExprLit(..) | hir::ExprBreak(..) |
@@ -1155,7 +1155,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
11551155
self.cat_pattern_(subcmt, &subpat, op)?;
11561156
}
11571157

1158-
PatKind::Vec(ref before, ref slice, ref after) => {
1158+
PatKind::Slice(ref before, ref slice, ref after) => {
11591159
let context = InteriorOffsetKind::Pattern;
11601160
let elt_cmt = self.cat_index(pat, cmt, context)?;
11611161
for before_pat in before {

src/librustc/middle/region.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
961961
field_pats.iter().any(|fp| is_binding_pat(&fp.node.pat))
962962
}
963963

964-
PatKind::Vec(ref pats1, ref pats2, ref pats3) => {
964+
PatKind::Slice(ref pats1, ref pats2, ref pats3) => {
965965
pats1.iter().any(|p| is_binding_pat(&p)) ||
966966
pats2.iter().any(|p| is_binding_pat(&p)) ||
967967
pats3.iter().any(|p| is_binding_pat(&p))
@@ -1012,7 +1012,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
10121012
visitor, &field.expr, blk_id);
10131013
}
10141014
}
1015-
hir::ExprVec(ref subexprs) |
1015+
hir::ExprArray(ref subexprs) |
10161016
hir::ExprTup(ref subexprs) => {
10171017
for subexpr in subexprs {
10181018
record_rvalue_scope_if_borrow_expr(

src/librustc/mir/repr.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ pub enum CastKind {
10241024

10251025
#[derive(Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
10261026
pub enum AggregateKind<'tcx> {
1027-
Vec,
1027+
Array,
10281028
Tuple,
10291029
/// The second field is variant number (discriminant), it's equal to 0
10301030
/// for struct and union expressions. The fourth field is active field
@@ -1115,8 +1115,6 @@ impl<'tcx> Debug for Rvalue<'tcx> {
11151115
}
11161116

11171117
Aggregate(ref kind, ref lvs) => {
1118-
use self::AggregateKind::*;
1119-
11201118
fn fmt_tuple(fmt: &mut Formatter, lvs: &[Operand]) -> fmt::Result {
11211119
let mut tuple_fmt = fmt.debug_tuple("");
11221120
for lv in lvs {
@@ -1126,17 +1124,17 @@ impl<'tcx> Debug for Rvalue<'tcx> {
11261124
}
11271125

11281126
match *kind {
1129-
Vec => write!(fmt, "{:?}", lvs),
1127+
AggregateKind::Array => write!(fmt, "{:?}", lvs),
11301128

1131-
Tuple => {
1129+
AggregateKind::Tuple => {
11321130
match lvs.len() {
11331131
0 => write!(fmt, "()"),
11341132
1 => write!(fmt, "({:?},)", lvs[0]),
11351133
_ => fmt_tuple(fmt, lvs),
11361134
}
11371135
}
11381136

1139-
Adt(adt_def, variant, substs, _) => {
1137+
AggregateKind::Adt(adt_def, variant, substs, _) => {
11401138
let variant_def = &adt_def.variants[variant];
11411139

11421140
ppaux::parameterized(fmt, substs, variant_def.did,
@@ -1155,7 +1153,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
11551153
}
11561154
}
11571155

1158-
Closure(def_id, _) => ty::tls::with(|tcx| {
1156+
AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| {
11591157
if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
11601158
let name = format!("[closure@{:?}]", tcx.map.span(node_id));
11611159
let mut struct_fmt = fmt.debug_struct(&name);

0 commit comments

Comments
 (0)