Rollup merge of #36599 - jonas-schievink:whats-a-pirates-favorite-data-structure, r=pnkfelix
Contains a syntax-[breaking-change] as a separate commit (cc #31645).nnAlso renames slice patterns from `PatKind::Vec` to `PatKind::Slice`.
This commit is contained in:
commit
259d1fcd47
42 changed files with 121 additions and 156 deletions
|
@ -126,7 +126,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
||||||
self.add_ast_node(pat.id, &[pats_exit])
|
self.add_ast_node(pat.id, &[pats_exit])
|
||||||
}
|
}
|
||||||
|
|
||||||
PatKind::Vec(ref pre, ref vec, ref post) => {
|
PatKind::Slice(ref pre, ref vec, ref post) => {
|
||||||
let pre_exit = self.pats_all(pre.iter(), pred);
|
let pre_exit = self.pats_all(pre.iter(), pred);
|
||||||
let vec_exit = self.pats_all(vec.iter(), pre_exit);
|
let vec_exit = self.pats_all(vec.iter(), pre_exit);
|
||||||
let post_exit = self.pats_all(post.iter(), vec_exit);
|
let post_exit = self.pats_all(post.iter(), vec_exit);
|
||||||
|
@ -298,7 +298,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
||||||
self.add_unreachable_node()
|
self.add_unreachable_node()
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprVec(ref elems) => {
|
hir::ExprArray(ref elems) => {
|
||||||
self.straightline(expr, pred, elems.iter().map(|e| &**e))
|
self.straightline(expr, pred, elems.iter().map(|e| &**e))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,7 +394,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
|
||||||
visitor.visit_id(typ.id);
|
visitor.visit_id(typ.id);
|
||||||
|
|
||||||
match typ.node {
|
match typ.node {
|
||||||
TyVec(ref ty) => {
|
TySlice(ref ty) => {
|
||||||
visitor.visit_ty(ty)
|
visitor.visit_ty(ty)
|
||||||
}
|
}
|
||||||
TyPtr(ref mutable_type) => {
|
TyPtr(ref mutable_type) => {
|
||||||
|
@ -422,7 +422,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
walk_list!(visitor, visit_ty_param_bound, bounds);
|
walk_list!(visitor, visit_ty_param_bound, bounds);
|
||||||
}
|
}
|
||||||
TyFixedLengthVec(ref ty, ref expression) => {
|
TyArray(ref ty, ref expression) => {
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
visitor.visit_expr(expression)
|
visitor.visit_expr(expression)
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
|
||||||
visitor.visit_expr(upper_bound)
|
visitor.visit_expr(upper_bound)
|
||||||
}
|
}
|
||||||
PatKind::Wild => (),
|
PatKind::Wild => (),
|
||||||
PatKind::Vec(ref prepatterns, ref slice_pattern, ref postpatterns) => {
|
PatKind::Slice(ref prepatterns, ref slice_pattern, ref postpatterns) => {
|
||||||
walk_list!(visitor, visit_pat, prepatterns);
|
walk_list!(visitor, visit_pat, prepatterns);
|
||||||
walk_list!(visitor, visit_pat, slice_pattern);
|
walk_list!(visitor, visit_pat, slice_pattern);
|
||||||
walk_list!(visitor, visit_pat, postpatterns);
|
walk_list!(visitor, visit_pat, postpatterns);
|
||||||
|
@ -749,7 +749,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
||||||
ExprBox(ref subexpression) => {
|
ExprBox(ref subexpression) => {
|
||||||
visitor.visit_expr(subexpression)
|
visitor.visit_expr(subexpression)
|
||||||
}
|
}
|
||||||
ExprVec(ref subexpressions) => {
|
ExprArray(ref subexpressions) => {
|
||||||
walk_list!(visitor, visit_expr, subexpressions);
|
walk_list!(visitor, visit_expr, subexpressions);
|
||||||
}
|
}
|
||||||
ExprRepeat(ref element, ref count) => {
|
ExprRepeat(ref element, ref count) => {
|
||||||
|
|
|
@ -222,17 +222,16 @@ impl<'a> LoweringContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_ty(&mut self, t: &Ty) -> P<hir::Ty> {
|
fn lower_ty(&mut self, t: &Ty) -> P<hir::Ty> {
|
||||||
use syntax::ast::TyKind::*;
|
|
||||||
P(hir::Ty {
|
P(hir::Ty {
|
||||||
id: t.id,
|
id: t.id,
|
||||||
node: match t.node {
|
node: match t.node {
|
||||||
Infer | ImplicitSelf => hir::TyInfer,
|
TyKind::Infer | TyKind::ImplicitSelf => hir::TyInfer,
|
||||||
Vec(ref ty) => hir::TyVec(self.lower_ty(ty)),
|
TyKind::Slice(ref ty) => hir::TySlice(self.lower_ty(ty)),
|
||||||
Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt)),
|
TyKind::Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt)),
|
||||||
Rptr(ref region, ref mt) => {
|
TyKind::Rptr(ref region, ref mt) => {
|
||||||
hir::TyRptr(self.lower_opt_lifetime(region), self.lower_mt(mt))
|
hir::TyRptr(self.lower_opt_lifetime(region), self.lower_mt(mt))
|
||||||
}
|
}
|
||||||
BareFn(ref f) => {
|
TyKind::BareFn(ref f) => {
|
||||||
hir::TyBareFn(P(hir::BareFnTy {
|
hir::TyBareFn(P(hir::BareFnTy {
|
||||||
lifetimes: self.lower_lifetime_defs(&f.lifetimes),
|
lifetimes: self.lower_lifetime_defs(&f.lifetimes),
|
||||||
unsafety: self.lower_unsafety(f.unsafety),
|
unsafety: self.lower_unsafety(f.unsafety),
|
||||||
|
@ -240,12 +239,14 @@ impl<'a> LoweringContext<'a> {
|
||||||
decl: self.lower_fn_decl(&f.decl),
|
decl: self.lower_fn_decl(&f.decl),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
Never => hir::TyNever,
|
TyKind::Never => hir::TyNever,
|
||||||
Tup(ref tys) => hir::TyTup(tys.iter().map(|ty| self.lower_ty(ty)).collect()),
|
TyKind::Tup(ref tys) => {
|
||||||
Paren(ref ty) => {
|
hir::TyTup(tys.iter().map(|ty| self.lower_ty(ty)).collect())
|
||||||
|
}
|
||||||
|
TyKind::Paren(ref ty) => {
|
||||||
return self.lower_ty(ty);
|
return self.lower_ty(ty);
|
||||||
}
|
}
|
||||||
Path(ref qself, ref path) => {
|
TyKind::Path(ref qself, ref path) => {
|
||||||
let qself = qself.as_ref().map(|&QSelf { ref ty, position }| {
|
let qself = qself.as_ref().map(|&QSelf { ref ty, position }| {
|
||||||
hir::QSelf {
|
hir::QSelf {
|
||||||
ty: self.lower_ty(ty),
|
ty: self.lower_ty(ty),
|
||||||
|
@ -254,22 +255,22 @@ impl<'a> LoweringContext<'a> {
|
||||||
});
|
});
|
||||||
hir::TyPath(qself, self.lower_path(path))
|
hir::TyPath(qself, self.lower_path(path))
|
||||||
}
|
}
|
||||||
ObjectSum(ref ty, ref bounds) => {
|
TyKind::ObjectSum(ref ty, ref bounds) => {
|
||||||
hir::TyObjectSum(self.lower_ty(ty), self.lower_bounds(bounds))
|
hir::TyObjectSum(self.lower_ty(ty), self.lower_bounds(bounds))
|
||||||
}
|
}
|
||||||
FixedLengthVec(ref ty, ref e) => {
|
TyKind::Array(ref ty, ref e) => {
|
||||||
hir::TyFixedLengthVec(self.lower_ty(ty), self.lower_expr(e))
|
hir::TyArray(self.lower_ty(ty), self.lower_expr(e))
|
||||||
}
|
}
|
||||||
Typeof(ref expr) => {
|
TyKind::Typeof(ref expr) => {
|
||||||
hir::TyTypeof(self.lower_expr(expr))
|
hir::TyTypeof(self.lower_expr(expr))
|
||||||
}
|
}
|
||||||
PolyTraitRef(ref bounds) => {
|
TyKind::PolyTraitRef(ref bounds) => {
|
||||||
hir::TyPolyTraitRef(self.lower_bounds(bounds))
|
hir::TyPolyTraitRef(self.lower_bounds(bounds))
|
||||||
}
|
}
|
||||||
ImplTrait(ref bounds) => {
|
TyKind::ImplTrait(ref bounds) => {
|
||||||
hir::TyImplTrait(self.lower_bounds(bounds))
|
hir::TyImplTrait(self.lower_bounds(bounds))
|
||||||
}
|
}
|
||||||
Mac(_) => panic!("TyMac should have been expanded by now."),
|
TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
|
||||||
},
|
},
|
||||||
span: t.span,
|
span: t.span,
|
||||||
})
|
})
|
||||||
|
@ -891,8 +892,8 @@ impl<'a> LoweringContext<'a> {
|
||||||
PatKind::Range(ref e1, ref e2) => {
|
PatKind::Range(ref e1, ref e2) => {
|
||||||
hir::PatKind::Range(self.lower_expr(e1), self.lower_expr(e2))
|
hir::PatKind::Range(self.lower_expr(e1), self.lower_expr(e2))
|
||||||
}
|
}
|
||||||
PatKind::Vec(ref before, ref slice, ref after) => {
|
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||||
hir::PatKind::Vec(before.iter().map(|x| self.lower_pat(x)).collect(),
|
hir::PatKind::Slice(before.iter().map(|x| self.lower_pat(x)).collect(),
|
||||||
slice.as_ref().map(|x| self.lower_pat(x)),
|
slice.as_ref().map(|x| self.lower_pat(x)),
|
||||||
after.iter().map(|x| self.lower_pat(x)).collect())
|
after.iter().map(|x| self.lower_pat(x)).collect())
|
||||||
}
|
}
|
||||||
|
@ -1031,7 +1032,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprKind::Vec(ref exprs) => {
|
ExprKind::Vec(ref exprs) => {
|
||||||
hir::ExprVec(exprs.iter().map(|x| self.lower_expr(x)).collect())
|
hir::ExprArray(exprs.iter().map(|x| self.lower_expr(x)).collect())
|
||||||
}
|
}
|
||||||
ExprKind::Repeat(ref expr, ref count) => {
|
ExprKind::Repeat(ref expr, ref count) => {
|
||||||
let expr = self.lower_expr(expr);
|
let expr = self.lower_expr(expr);
|
||||||
|
|
|
@ -286,7 +286,7 @@ impl<'a> visit::Visitor for DefCollector<'a> {
|
||||||
fn visit_ty(&mut self, ty: &Ty) {
|
fn visit_ty(&mut self, ty: &Ty) {
|
||||||
match ty.node {
|
match ty.node {
|
||||||
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id, false),
|
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id, false),
|
||||||
TyKind::FixedLengthVec(_, ref length) => self.visit_ast_const_integer(length),
|
TyKind::Array(_, ref length) => self.visit_ast_const_integer(length),
|
||||||
TyKind::ImplTrait(..) => {
|
TyKind::ImplTrait(..) => {
|
||||||
self.create_def(ty.id, DefPathData::ImplTrait);
|
self.create_def(ty.id, DefPathData::ImplTrait);
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ impl<'ast> intravisit::Visitor<'ast> for DefCollector<'ast> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, ty: &'ast hir::Ty) {
|
fn visit_ty(&mut self, ty: &'ast hir::Ty) {
|
||||||
if let hir::TyFixedLengthVec(_, ref length) = ty.node {
|
if let hir::TyArray(_, ref length) = ty.node {
|
||||||
self.visit_hir_const_integer(length);
|
self.visit_hir_const_integer(length);
|
||||||
}
|
}
|
||||||
if let hir::TyImplTrait(..) = ty.node {
|
if let hir::TyImplTrait(..) = ty.node {
|
||||||
|
|
|
@ -478,7 +478,7 @@ impl Pat {
|
||||||
PatKind::Box(ref s) | PatKind::Ref(ref s, _) => {
|
PatKind::Box(ref s) | PatKind::Ref(ref s, _) => {
|
||||||
s.walk_(it)
|
s.walk_(it)
|
||||||
}
|
}
|
||||||
PatKind::Vec(ref before, ref slice, ref after) => {
|
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||||
before.iter().all(|p| p.walk_(it)) &&
|
before.iter().all(|p| p.walk_(it)) &&
|
||||||
slice.iter().all(|p| p.walk_(it)) &&
|
slice.iter().all(|p| p.walk_(it)) &&
|
||||||
after.iter().all(|p| p.walk_(it))
|
after.iter().all(|p| p.walk_(it))
|
||||||
|
@ -554,8 +554,8 @@ pub enum PatKind {
|
||||||
/// A range pattern, e.g. `1...2`
|
/// A range pattern, e.g. `1...2`
|
||||||
Range(P<Expr>, P<Expr>),
|
Range(P<Expr>, P<Expr>),
|
||||||
/// `[a, b, ..i, y, z]` is represented as:
|
/// `[a, b, ..i, y, z]` is represented as:
|
||||||
/// `PatKind::Vec(box [a, b], Some(i), box [y, z])`
|
/// `PatKind::Slice(box [a, b], Some(i), box [y, z])`
|
||||||
Vec(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),
|
Slice(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||||
|
@ -826,7 +826,7 @@ pub enum Expr_ {
|
||||||
/// A `box x` expression.
|
/// A `box x` expression.
|
||||||
ExprBox(P<Expr>),
|
ExprBox(P<Expr>),
|
||||||
/// An array (`[a, b, c, d]`)
|
/// An array (`[a, b, c, d]`)
|
||||||
ExprVec(HirVec<P<Expr>>),
|
ExprArray(HirVec<P<Expr>>),
|
||||||
/// A function call
|
/// A function call
|
||||||
///
|
///
|
||||||
/// The first field resolves to the function itself (usually an `ExprPath`),
|
/// The first field resolves to the function itself (usually an `ExprPath`),
|
||||||
|
@ -1080,10 +1080,10 @@ pub struct BareFnTy {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
/// The different kinds of types recognized by the compiler
|
/// The different kinds of types recognized by the compiler
|
||||||
pub enum Ty_ {
|
pub enum Ty_ {
|
||||||
/// A variable length array (`[T]`)
|
/// A variable length slice (`[T]`)
|
||||||
TyVec(P<Ty>),
|
TySlice(P<Ty>),
|
||||||
/// A fixed length array (`[T; n]`)
|
/// A fixed length array (`[T; n]`)
|
||||||
TyFixedLengthVec(P<Ty>, P<Expr>),
|
TyArray(P<Ty>, P<Expr>),
|
||||||
/// A raw pointer (`*const T` or `*mut T`)
|
/// A raw pointer (`*const T` or `*mut T`)
|
||||||
TyPtr(MutTy),
|
TyPtr(MutTy),
|
||||||
/// A reference (`&'a T` or `&'a mut T`)
|
/// A reference (`&'a T` or `&'a mut T`)
|
||||||
|
|
|
@ -62,7 +62,7 @@ pub fn pat_is_refutable(dm: &DefMap, pat: &hir::Pat) -> bool {
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PatKind::Vec(..) => true,
|
PatKind::Slice(..) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,7 +486,7 @@ impl<'a> State<'a> {
|
||||||
self.maybe_print_comment(ty.span.lo)?;
|
self.maybe_print_comment(ty.span.lo)?;
|
||||||
self.ibox(0)?;
|
self.ibox(0)?;
|
||||||
match ty.node {
|
match ty.node {
|
||||||
hir::TyVec(ref ty) => {
|
hir::TySlice(ref ty) => {
|
||||||
word(&mut self.s, "[")?;
|
word(&mut self.s, "[")?;
|
||||||
self.print_type(&ty)?;
|
self.print_type(&ty)?;
|
||||||
word(&mut self.s, "]")?;
|
word(&mut self.s, "]")?;
|
||||||
|
@ -543,7 +543,7 @@ impl<'a> State<'a> {
|
||||||
hir::TyImplTrait(ref bounds) => {
|
hir::TyImplTrait(ref bounds) => {
|
||||||
self.print_bounds("impl ", &bounds[..])?;
|
self.print_bounds("impl ", &bounds[..])?;
|
||||||
}
|
}
|
||||||
hir::TyFixedLengthVec(ref ty, ref v) => {
|
hir::TyArray(ref ty, ref v) => {
|
||||||
word(&mut self.s, "[")?;
|
word(&mut self.s, "[")?;
|
||||||
self.print_type(&ty)?;
|
self.print_type(&ty)?;
|
||||||
word(&mut self.s, "; ")?;
|
word(&mut self.s, "; ")?;
|
||||||
|
@ -1319,7 +1319,7 @@ impl<'a> State<'a> {
|
||||||
self.word_space("box")?;
|
self.word_space("box")?;
|
||||||
self.print_expr(expr)?;
|
self.print_expr(expr)?;
|
||||||
}
|
}
|
||||||
hir::ExprVec(ref exprs) => {
|
hir::ExprArray(ref exprs) => {
|
||||||
self.print_expr_vec(&exprs[..])?;
|
self.print_expr_vec(&exprs[..])?;
|
||||||
}
|
}
|
||||||
hir::ExprRepeat(ref element, ref count) => {
|
hir::ExprRepeat(ref element, ref count) => {
|
||||||
|
@ -1829,7 +1829,7 @@ impl<'a> State<'a> {
|
||||||
word(&mut self.s, "...")?;
|
word(&mut self.s, "...")?;
|
||||||
self.print_expr(&end)?;
|
self.print_expr(&end)?;
|
||||||
}
|
}
|
||||||
PatKind::Vec(ref before, ref slice, ref after) => {
|
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||||
word(&mut self.s, "[")?;
|
word(&mut self.s, "[")?;
|
||||||
self.commasep(Inconsistent, &before[..], |s, p| s.print_pat(&p))?;
|
self.commasep(Inconsistent, &before[..], |s, p| s.print_pat(&p))?;
|
||||||
if let Some(ref p) = *slice {
|
if let Some(ref p) = *slice {
|
||||||
|
|
|
@ -1433,8 +1433,8 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
|
||||||
hir::TyPtr(ref mut_ty) => {
|
hir::TyPtr(ref mut_ty) => {
|
||||||
ty_queue.push(&mut_ty.ty);
|
ty_queue.push(&mut_ty.ty);
|
||||||
}
|
}
|
||||||
hir::TyVec(ref ty) |
|
hir::TySlice(ref ty) |
|
||||||
hir::TyFixedLengthVec(ref ty, _) => {
|
hir::TyArray(ref ty, _) => {
|
||||||
ty_queue.push(&ty);
|
ty_queue.push(&ty);
|
||||||
}
|
}
|
||||||
hir::TyTup(ref tys) => ty_queue.extend(tys.iter().map(|ty| &**ty)),
|
hir::TyTup(ref tys) => ty_queue.extend(tys.iter().map(|ty| &**ty)),
|
||||||
|
@ -1469,9 +1469,9 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
|
||||||
ty: build_to(mut_ty.ty, to),
|
ty: build_to(mut_ty.ty, to),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
hir::TyVec(ty) => hir::TyVec(build_to(ty, to)),
|
hir::TySlice(ty) => hir::TySlice(build_to(ty, to)),
|
||||||
hir::TyFixedLengthVec(ty, e) => {
|
hir::TyArray(ty, e) => {
|
||||||
hir::TyFixedLengthVec(build_to(ty, to), e)
|
hir::TyArray(build_to(ty, to), e)
|
||||||
}
|
}
|
||||||
hir::TyTup(tys) => {
|
hir::TyTup(tys) => {
|
||||||
hir::TyTup(tys.into_iter().map(|ty| build_to(ty, to)).collect())
|
hir::TyTup(tys.into_iter().map(|ty| build_to(ty, to)).collect())
|
||||||
|
|
|
@ -442,7 +442,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprVec(ref exprs) => {
|
hir::ExprArray(ref exprs) => {
|
||||||
self.consume_exprs(exprs);
|
self.consume_exprs(exprs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -490,7 +490,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
|
||||||
|
|
||||||
// otherwise, live nodes are not required:
|
// otherwise, live nodes are not required:
|
||||||
hir::ExprIndex(..) | hir::ExprField(..) | hir::ExprTupField(..) |
|
hir::ExprIndex(..) | hir::ExprField(..) | hir::ExprTupField(..) |
|
||||||
hir::ExprVec(..) | hir::ExprCall(..) | hir::ExprMethodCall(..) |
|
hir::ExprArray(..) | hir::ExprCall(..) | hir::ExprMethodCall(..) |
|
||||||
hir::ExprTup(..) | hir::ExprBinary(..) | hir::ExprAddrOf(..) |
|
hir::ExprTup(..) | hir::ExprBinary(..) | hir::ExprAddrOf(..) |
|
||||||
hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprBreak(_) |
|
hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprBreak(_) |
|
||||||
hir::ExprAgain(_) | hir::ExprLit(_) | hir::ExprRet(..) |
|
hir::ExprAgain(_) | hir::ExprLit(_) | hir::ExprRet(..) |
|
||||||
|
@ -1095,7 +1095,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
|
|
||||||
// Uninteresting cases: just propagate in rev exec order
|
// Uninteresting cases: just propagate in rev exec order
|
||||||
|
|
||||||
hir::ExprVec(ref exprs) => {
|
hir::ExprArray(ref exprs) => {
|
||||||
self.propagate_through_exprs(&exprs[..], succ)
|
self.propagate_through_exprs(&exprs[..], succ)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,7 +1436,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
|
||||||
hir::ExprCall(..) | hir::ExprMethodCall(..) | hir::ExprIf(..) |
|
hir::ExprCall(..) | hir::ExprMethodCall(..) | hir::ExprIf(..) |
|
||||||
hir::ExprMatch(..) | hir::ExprWhile(..) | hir::ExprLoop(..) |
|
hir::ExprMatch(..) | hir::ExprWhile(..) | hir::ExprLoop(..) |
|
||||||
hir::ExprIndex(..) | hir::ExprField(..) | hir::ExprTupField(..) |
|
hir::ExprIndex(..) | hir::ExprField(..) | hir::ExprTupField(..) |
|
||||||
hir::ExprVec(..) | hir::ExprTup(..) | hir::ExprBinary(..) |
|
hir::ExprArray(..) | hir::ExprTup(..) | hir::ExprBinary(..) |
|
||||||
hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprRet(..) |
|
hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprRet(..) |
|
||||||
hir::ExprBreak(..) | hir::ExprAgain(..) | hir::ExprLit(_) |
|
hir::ExprBreak(..) | hir::ExprAgain(..) | hir::ExprLit(_) |
|
||||||
hir::ExprBlock(..) | hir::ExprAddrOf(..) |
|
hir::ExprBlock(..) | hir::ExprAddrOf(..) |
|
||||||
|
|
|
@ -503,7 +503,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
hir::ExprClosure(..) | hir::ExprRet(..) |
|
hir::ExprClosure(..) | hir::ExprRet(..) |
|
||||||
hir::ExprUnary(..) |
|
hir::ExprUnary(..) |
|
||||||
hir::ExprMethodCall(..) | hir::ExprCast(..) |
|
hir::ExprMethodCall(..) | hir::ExprCast(..) |
|
||||||
hir::ExprVec(..) | hir::ExprTup(..) | hir::ExprIf(..) |
|
hir::ExprArray(..) | hir::ExprTup(..) | hir::ExprIf(..) |
|
||||||
hir::ExprBinary(..) | hir::ExprWhile(..) |
|
hir::ExprBinary(..) | hir::ExprWhile(..) |
|
||||||
hir::ExprBlock(..) | hir::ExprLoop(..) | hir::ExprMatch(..) |
|
hir::ExprBlock(..) | hir::ExprLoop(..) | hir::ExprMatch(..) |
|
||||||
hir::ExprLit(..) | hir::ExprBreak(..) |
|
hir::ExprLit(..) | hir::ExprBreak(..) |
|
||||||
|
@ -1155,7 +1155,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
self.cat_pattern_(subcmt, &subpat, op)?;
|
self.cat_pattern_(subcmt, &subpat, op)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
PatKind::Vec(ref before, ref slice, ref after) => {
|
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||||
let context = InteriorOffsetKind::Pattern;
|
let context = InteriorOffsetKind::Pattern;
|
||||||
let elt_cmt = self.cat_index(pat, cmt, context)?;
|
let elt_cmt = self.cat_index(pat, cmt, context)?;
|
||||||
for before_pat in before {
|
for before_pat in before {
|
||||||
|
|
|
@ -961,7 +961,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
|
||||||
field_pats.iter().any(|fp| is_binding_pat(&fp.node.pat))
|
field_pats.iter().any(|fp| is_binding_pat(&fp.node.pat))
|
||||||
}
|
}
|
||||||
|
|
||||||
PatKind::Vec(ref pats1, ref pats2, ref pats3) => {
|
PatKind::Slice(ref pats1, ref pats2, ref pats3) => {
|
||||||
pats1.iter().any(|p| is_binding_pat(&p)) ||
|
pats1.iter().any(|p| is_binding_pat(&p)) ||
|
||||||
pats2.iter().any(|p| is_binding_pat(&p)) ||
|
pats2.iter().any(|p| is_binding_pat(&p)) ||
|
||||||
pats3.iter().any(|p| is_binding_pat(&p))
|
pats3.iter().any(|p| is_binding_pat(&p))
|
||||||
|
@ -1012,7 +1012,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
|
||||||
visitor, &field.expr, blk_id);
|
visitor, &field.expr, blk_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprVec(ref subexprs) |
|
hir::ExprArray(ref subexprs) |
|
||||||
hir::ExprTup(ref subexprs) => {
|
hir::ExprTup(ref subexprs) => {
|
||||||
for subexpr in subexprs {
|
for subexpr in subexprs {
|
||||||
record_rvalue_scope_if_borrow_expr(
|
record_rvalue_scope_if_borrow_expr(
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ pub enum CastKind {
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
|
||||||
pub enum AggregateKind<'tcx> {
|
pub enum AggregateKind<'tcx> {
|
||||||
Vec,
|
Array,
|
||||||
Tuple,
|
Tuple,
|
||||||
/// The second field is variant number (discriminant), it's equal to 0
|
/// The second field is variant number (discriminant), it's equal to 0
|
||||||
/// for struct and union expressions. The fourth field is active field
|
/// for struct and union expressions. The fourth field is active field
|
||||||
|
@ -1115,8 +1115,6 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Aggregate(ref kind, ref lvs) => {
|
Aggregate(ref kind, ref lvs) => {
|
||||||
use self::AggregateKind::*;
|
|
||||||
|
|
||||||
fn fmt_tuple(fmt: &mut Formatter, lvs: &[Operand]) -> fmt::Result {
|
fn fmt_tuple(fmt: &mut Formatter, lvs: &[Operand]) -> fmt::Result {
|
||||||
let mut tuple_fmt = fmt.debug_tuple("");
|
let mut tuple_fmt = fmt.debug_tuple("");
|
||||||
for lv in lvs {
|
for lv in lvs {
|
||||||
|
@ -1126,9 +1124,9 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
match *kind {
|
match *kind {
|
||||||
Vec => write!(fmt, "{:?}", lvs),
|
AggregateKind::Array => write!(fmt, "{:?}", lvs),
|
||||||
|
|
||||||
Tuple => {
|
AggregateKind::Tuple => {
|
||||||
match lvs.len() {
|
match lvs.len() {
|
||||||
0 => write!(fmt, "()"),
|
0 => write!(fmt, "()"),
|
||||||
1 => write!(fmt, "({:?},)", lvs[0]),
|
1 => write!(fmt, "({:?},)", lvs[0]),
|
||||||
|
@ -1136,7 +1134,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Adt(adt_def, variant, substs, _) => {
|
AggregateKind::Adt(adt_def, variant, substs, _) => {
|
||||||
let variant_def = &adt_def.variants[variant];
|
let variant_def = &adt_def.variants[variant];
|
||||||
|
|
||||||
ppaux::parameterized(fmt, substs, variant_def.did,
|
ppaux::parameterized(fmt, substs, variant_def.did,
|
||||||
|
@ -1155,7 +1153,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Closure(def_id, _) => ty::tls::with(|tcx| {
|
AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| {
|
||||||
if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
|
if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
|
||||||
let name = format!("[closure@{:?}]", tcx.map.span(node_id));
|
let name = format!("[closure@{:?}]", tcx.map.span(node_id));
|
||||||
let mut struct_fmt = fmt.debug_struct(&name);
|
let mut struct_fmt = fmt.debug_struct(&name);
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl<'tcx> Rvalue<'tcx> {
|
||||||
}
|
}
|
||||||
&Rvalue::Aggregate(ref ak, ref ops) => {
|
&Rvalue::Aggregate(ref ak, ref ops) => {
|
||||||
match *ak {
|
match *ak {
|
||||||
AggregateKind::Vec => {
|
AggregateKind::Array => {
|
||||||
if let Some(operand) = ops.get(0) {
|
if let Some(operand) = ops.get(0) {
|
||||||
let ty = operand.ty(mir, tcx);
|
let ty = operand.ty(mir, tcx);
|
||||||
Some(tcx.mk_array(ty, ops.len()))
|
Some(tcx.mk_array(ty, ops.len()))
|
||||||
|
|
|
@ -513,7 +513,7 @@ macro_rules! make_mir_visitor {
|
||||||
Rvalue::Aggregate(ref $($mutability)* kind,
|
Rvalue::Aggregate(ref $($mutability)* kind,
|
||||||
ref $($mutability)* operands) => {
|
ref $($mutability)* operands) => {
|
||||||
match *kind {
|
match *kind {
|
||||||
AggregateKind::Vec => {
|
AggregateKind::Array => {
|
||||||
}
|
}
|
||||||
AggregateKind::Tuple => {
|
AggregateKind::Tuple => {
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,8 @@ pub enum TypeError<'tcx> {
|
||||||
UnsafetyMismatch(ExpectedFound<hir::Unsafety>),
|
UnsafetyMismatch(ExpectedFound<hir::Unsafety>),
|
||||||
AbiMismatch(ExpectedFound<abi::Abi>),
|
AbiMismatch(ExpectedFound<abi::Abi>),
|
||||||
Mutability,
|
Mutability,
|
||||||
BoxMutability,
|
|
||||||
PtrMutability,
|
|
||||||
RefMutability,
|
|
||||||
VecMutability,
|
|
||||||
TupleSize(ExpectedFound<usize>),
|
TupleSize(ExpectedFound<usize>),
|
||||||
FixedArraySize(ExpectedFound<usize>),
|
FixedArraySize(ExpectedFound<usize>),
|
||||||
TyParamSize(ExpectedFound<usize>),
|
|
||||||
ArgCount,
|
ArgCount,
|
||||||
RegionsDoesNotOutlive(&'tcx Region, &'tcx Region),
|
RegionsDoesNotOutlive(&'tcx Region, &'tcx Region),
|
||||||
RegionsNotSame(&'tcx Region, &'tcx Region),
|
RegionsNotSame(&'tcx Region, &'tcx Region),
|
||||||
|
@ -47,14 +42,12 @@ pub enum TypeError<'tcx> {
|
||||||
RegionsInsufficientlyPolymorphic(BoundRegion, &'tcx Region),
|
RegionsInsufficientlyPolymorphic(BoundRegion, &'tcx Region),
|
||||||
RegionsOverlyPolymorphic(BoundRegion, &'tcx Region),
|
RegionsOverlyPolymorphic(BoundRegion, &'tcx Region),
|
||||||
Sorts(ExpectedFound<Ty<'tcx>>),
|
Sorts(ExpectedFound<Ty<'tcx>>),
|
||||||
IntegerAsChar,
|
|
||||||
IntMismatch(ExpectedFound<ty::IntVarValue>),
|
IntMismatch(ExpectedFound<ty::IntVarValue>),
|
||||||
FloatMismatch(ExpectedFound<ast::FloatTy>),
|
FloatMismatch(ExpectedFound<ast::FloatTy>),
|
||||||
Traits(ExpectedFound<DefId>),
|
Traits(ExpectedFound<DefId>),
|
||||||
BuiltinBoundsMismatch(ExpectedFound<ty::BuiltinBounds>),
|
BuiltinBoundsMismatch(ExpectedFound<ty::BuiltinBounds>),
|
||||||
VariadicMismatch(ExpectedFound<bool>),
|
VariadicMismatch(ExpectedFound<bool>),
|
||||||
CyclicTy,
|
CyclicTy,
|
||||||
ConvergenceMismatch(ExpectedFound<bool>),
|
|
||||||
ProjectionNameMismatched(ExpectedFound<Name>),
|
ProjectionNameMismatched(ExpectedFound<Name>),
|
||||||
ProjectionBoundsLength(ExpectedFound<usize>),
|
ProjectionBoundsLength(ExpectedFound<usize>),
|
||||||
TyParamDefaultMismatch(ExpectedFound<type_variable::Default<'tcx>>)
|
TyParamDefaultMismatch(ExpectedFound<type_variable::Default<'tcx>>)
|
||||||
|
@ -99,18 +92,6 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
||||||
values.found)
|
values.found)
|
||||||
}
|
}
|
||||||
Mutability => write!(f, "types differ in mutability"),
|
Mutability => write!(f, "types differ in mutability"),
|
||||||
BoxMutability => {
|
|
||||||
write!(f, "boxed types differ in mutability")
|
|
||||||
}
|
|
||||||
VecMutability => write!(f, "vectors differ in mutability"),
|
|
||||||
PtrMutability => write!(f, "pointers differ in mutability"),
|
|
||||||
RefMutability => write!(f, "references differ in mutability"),
|
|
||||||
TyParamSize(values) => {
|
|
||||||
write!(f, "expected a type with {} type params, \
|
|
||||||
found one with {} type params",
|
|
||||||
values.expected,
|
|
||||||
values.found)
|
|
||||||
}
|
|
||||||
FixedArraySize(values) => {
|
FixedArraySize(values) => {
|
||||||
write!(f, "expected an array with a fixed size of {} elements, \
|
write!(f, "expected an array with a fixed size of {} elements, \
|
||||||
found one with {} elements",
|
found one with {} elements",
|
||||||
|
@ -167,9 +148,6 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
||||||
values.found)
|
values.found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IntegerAsChar => {
|
|
||||||
write!(f, "expected an integral type, found `char`")
|
|
||||||
}
|
|
||||||
IntMismatch(ref values) => {
|
IntMismatch(ref values) => {
|
||||||
write!(f, "expected `{:?}`, found `{:?}`",
|
write!(f, "expected `{:?}`, found `{:?}`",
|
||||||
values.expected,
|
values.expected,
|
||||||
|
@ -185,11 +163,6 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
||||||
if values.expected { "variadic" } else { "non-variadic" },
|
if values.expected { "variadic" } else { "non-variadic" },
|
||||||
if values.found { "variadic" } else { "non-variadic" })
|
if values.found { "variadic" } else { "non-variadic" })
|
||||||
}
|
}
|
||||||
ConvergenceMismatch(ref values) => {
|
|
||||||
write!(f, "expected {} fn, found {} function",
|
|
||||||
if values.expected { "converging" } else { "diverging" },
|
|
||||||
if values.found { "converging" } else { "diverging" })
|
|
||||||
}
|
|
||||||
ProjectionNameMismatched(ref values) => {
|
ProjectionNameMismatched(ref values) => {
|
||||||
write!(f, "expected {}, found {}",
|
write!(f, "expected {}, found {}",
|
||||||
values.expected,
|
values.expected,
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub enum SimplifiedType {
|
||||||
FloatSimplifiedType(ast::FloatTy),
|
FloatSimplifiedType(ast::FloatTy),
|
||||||
AdtSimplifiedType(DefId),
|
AdtSimplifiedType(DefId),
|
||||||
StrSimplifiedType,
|
StrSimplifiedType,
|
||||||
VecSimplifiedType,
|
ArraySimplifiedType,
|
||||||
PtrSimplifiedType,
|
PtrSimplifiedType,
|
||||||
NeverSimplifiedType,
|
NeverSimplifiedType,
|
||||||
TupleSimplifiedType(usize),
|
TupleSimplifiedType(usize),
|
||||||
|
@ -57,7 +57,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
|
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
|
||||||
ty::TyAdt(def, _) => Some(AdtSimplifiedType(def.did)),
|
ty::TyAdt(def, _) => Some(AdtSimplifiedType(def.did)),
|
||||||
ty::TyStr => Some(StrSimplifiedType),
|
ty::TyStr => Some(StrSimplifiedType),
|
||||||
ty::TyArray(..) | ty::TySlice(_) => Some(VecSimplifiedType),
|
ty::TyArray(..) | ty::TySlice(_) => Some(ArraySimplifiedType),
|
||||||
ty::TyRawPtr(_) => Some(PtrSimplifiedType),
|
ty::TyRawPtr(_) => Some(PtrSimplifiedType),
|
||||||
ty::TyTrait(ref trait_info) => {
|
ty::TyTrait(ref trait_info) => {
|
||||||
Some(TraitSimplifiedType(trait_info.principal.def_id()))
|
Some(TraitSimplifiedType(trait_info.principal.def_id()))
|
||||||
|
|
|
@ -2228,7 +2228,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
hir::ExprClosure(..) |
|
hir::ExprClosure(..) |
|
||||||
hir::ExprBlock(..) |
|
hir::ExprBlock(..) |
|
||||||
hir::ExprRepeat(..) |
|
hir::ExprRepeat(..) |
|
||||||
hir::ExprVec(..) |
|
hir::ExprArray(..) |
|
||||||
hir::ExprBreak(..) |
|
hir::ExprBreak(..) |
|
||||||
hir::ExprAgain(..) |
|
hir::ExprAgain(..) |
|
||||||
hir::ExprRet(..) |
|
hir::ExprRet(..) |
|
||||||
|
|
|
@ -296,13 +296,8 @@ impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> {
|
||||||
UnsafetyMismatch(x) => UnsafetyMismatch(x),
|
UnsafetyMismatch(x) => UnsafetyMismatch(x),
|
||||||
AbiMismatch(x) => AbiMismatch(x),
|
AbiMismatch(x) => AbiMismatch(x),
|
||||||
Mutability => Mutability,
|
Mutability => Mutability,
|
||||||
BoxMutability => BoxMutability,
|
|
||||||
PtrMutability => PtrMutability,
|
|
||||||
RefMutability => RefMutability,
|
|
||||||
VecMutability => VecMutability,
|
|
||||||
TupleSize(x) => TupleSize(x),
|
TupleSize(x) => TupleSize(x),
|
||||||
FixedArraySize(x) => FixedArraySize(x),
|
FixedArraySize(x) => FixedArraySize(x),
|
||||||
TyParamSize(x) => TyParamSize(x),
|
|
||||||
ArgCount => ArgCount,
|
ArgCount => ArgCount,
|
||||||
RegionsDoesNotOutlive(a, b) => {
|
RegionsDoesNotOutlive(a, b) => {
|
||||||
return tcx.lift(&(a, b)).map(|(a, b)| RegionsDoesNotOutlive(a, b))
|
return tcx.lift(&(a, b)).map(|(a, b)| RegionsDoesNotOutlive(a, b))
|
||||||
|
@ -319,14 +314,12 @@ impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> {
|
||||||
RegionsOverlyPolymorphic(a, b) => {
|
RegionsOverlyPolymorphic(a, b) => {
|
||||||
return tcx.lift(&b).map(|b| RegionsOverlyPolymorphic(a, b))
|
return tcx.lift(&b).map(|b| RegionsOverlyPolymorphic(a, b))
|
||||||
}
|
}
|
||||||
IntegerAsChar => IntegerAsChar,
|
|
||||||
IntMismatch(x) => IntMismatch(x),
|
IntMismatch(x) => IntMismatch(x),
|
||||||
FloatMismatch(x) => FloatMismatch(x),
|
FloatMismatch(x) => FloatMismatch(x),
|
||||||
Traits(x) => Traits(x),
|
Traits(x) => Traits(x),
|
||||||
BuiltinBoundsMismatch(x) => BuiltinBoundsMismatch(x),
|
BuiltinBoundsMismatch(x) => BuiltinBoundsMismatch(x),
|
||||||
VariadicMismatch(x) => VariadicMismatch(x),
|
VariadicMismatch(x) => VariadicMismatch(x),
|
||||||
CyclicTy => CyclicTy,
|
CyclicTy => CyclicTy,
|
||||||
ConvergenceMismatch(x) => ConvergenceMismatch(x),
|
|
||||||
ProjectionNameMismatched(x) => ProjectionNameMismatched(x),
|
ProjectionNameMismatched(x) => ProjectionNameMismatched(x),
|
||||||
ProjectionBoundsLength(x) => ProjectionBoundsLength(x),
|
ProjectionBoundsLength(x) => ProjectionBoundsLength(x),
|
||||||
|
|
||||||
|
|
|
@ -536,8 +536,8 @@ impl<'a, 'tcx> StaticInliner<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
PatKind::Box(inner) => PatKind::Box(self.fold_pat(inner)),
|
PatKind::Box(inner) => PatKind::Box(self.fold_pat(inner)),
|
||||||
PatKind::Ref(inner, mutbl) => PatKind::Ref(self.fold_pat(inner), mutbl),
|
PatKind::Ref(inner, mutbl) => PatKind::Ref(self.fold_pat(inner), mutbl),
|
||||||
PatKind::Vec(before, slice, after) => {
|
PatKind::Slice(before, slice, after) => {
|
||||||
PatKind::Vec(before.move_map(|x| self.fold_pat(x)),
|
PatKind::Slice(before.move_map(|x| self.fold_pat(x)),
|
||||||
slice.map(|x| self.fold_pat(x)),
|
slice.map(|x| self.fold_pat(x)),
|
||||||
after.move_map(|x| self.fold_pat(x)))
|
after.move_map(|x| self.fold_pat(x)))
|
||||||
}
|
}
|
||||||
|
@ -610,14 +610,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
|
||||||
ty::TySlice(_) => match ctor {
|
ty::TySlice(_) => match ctor {
|
||||||
&Slice(n) => {
|
&Slice(n) => {
|
||||||
assert_eq!(pats_len, n);
|
assert_eq!(pats_len, n);
|
||||||
PatKind::Vec(pats.collect(), None, hir::HirVec::new())
|
PatKind::Slice(pats.collect(), None, hir::HirVec::new())
|
||||||
},
|
},
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
},
|
},
|
||||||
|
|
||||||
ty::TyArray(_, len) => {
|
ty::TyArray(_, len) => {
|
||||||
assert_eq!(pats_len, len);
|
assert_eq!(pats_len, len);
|
||||||
PatKind::Vec(pats.collect(), None, hir::HirVec::new())
|
PatKind::Slice(pats.collect(), None, hir::HirVec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -713,7 +713,7 @@ fn is_useful<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>,
|
||||||
};
|
};
|
||||||
|
|
||||||
let max_slice_length = rows.iter().filter_map(|row| match row[0].0.node {
|
let max_slice_length = rows.iter().filter_map(|row| match row[0].0.node {
|
||||||
PatKind::Vec(ref before, _, ref after) => Some(before.len() + after.len()),
|
PatKind::Slice(ref before, _, ref after) => Some(before.len() + after.len()),
|
||||||
_ => None
|
_ => None
|
||||||
}).max().map_or(0, |v| v + 1);
|
}).max().map_or(0, |v| v + 1);
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
|
||||||
vec![ConstantValue(eval_const_expr(cx.tcx, &expr))],
|
vec![ConstantValue(eval_const_expr(cx.tcx, &expr))],
|
||||||
PatKind::Range(ref lo, ref hi) =>
|
PatKind::Range(ref lo, ref hi) =>
|
||||||
vec![ConstantRange(eval_const_expr(cx.tcx, &lo), eval_const_expr(cx.tcx, &hi))],
|
vec![ConstantRange(eval_const_expr(cx.tcx, &lo), eval_const_expr(cx.tcx, &hi))],
|
||||||
PatKind::Vec(ref before, ref slice, ref after) =>
|
PatKind::Slice(ref before, ref slice, ref after) =>
|
||||||
match left_ty.sty {
|
match left_ty.sty {
|
||||||
ty::TyArray(..) => vec![Single],
|
ty::TyArray(..) => vec![Single],
|
||||||
ty::TySlice(_) if slice.is_some() => {
|
ty::TySlice(_) if slice.is_some() => {
|
||||||
|
@ -1001,7 +1001,7 @@ pub fn specialize<'a, 'b, 'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PatKind::Vec(ref before, ref slice, ref after) => {
|
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||||
let pat_len = before.len() + after.len();
|
let pat_len = before.len() + after.len();
|
||||||
match *constructor {
|
match *constructor {
|
||||||
Single => {
|
Single => {
|
||||||
|
|
|
@ -317,11 +317,11 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
PatKind::Struct(path.clone(), field_pats, false)
|
PatKind::Struct(path.clone(), field_pats, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprVec(ref exprs) => {
|
hir::ExprArray(ref exprs) => {
|
||||||
let pats = exprs.iter()
|
let pats = exprs.iter()
|
||||||
.map(|expr| const_expr_to_pat(tcx, &expr, pat_id, span))
|
.map(|expr| const_expr_to_pat(tcx, &expr, pat_id, span))
|
||||||
.collect::<Result<_, _>>()?;
|
.collect::<Result<_, _>>()?;
|
||||||
PatKind::Vec(pats, None, hir::HirVec::new())
|
PatKind::Slice(pats, None, hir::HirVec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprPath(_, ref path) => {
|
hir::ExprPath(_, ref path) => {
|
||||||
|
@ -898,7 +898,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
Array(_, n) if idx >= n => {
|
Array(_, n) if idx >= n => {
|
||||||
signal!(e, IndexOutOfBounds { len: n, index: idx })
|
signal!(e, IndexOutOfBounds { len: n, index: idx })
|
||||||
}
|
}
|
||||||
Array(v, n) => if let hir::ExprVec(ref v) = tcx.map.expect_expr(v).node {
|
Array(v, n) => if let hir::ExprArray(ref v) = tcx.map.expect_expr(v).node {
|
||||||
assert_eq!(n as usize as u64, n);
|
assert_eq!(n as usize as u64, n);
|
||||||
eval_const_expr_partial(tcx, &v[idx as usize], ty_hint, fn_args)?
|
eval_const_expr_partial(tcx, &v[idx as usize], ty_hint, fn_args)?
|
||||||
} else {
|
} else {
|
||||||
|
@ -925,7 +925,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
_ => signal!(e, IndexedNonVec),
|
_ => signal!(e, IndexedNonVec),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprVec(ref v) => Array(e.id, v.len() as u64),
|
hir::ExprArray(ref v) => Array(e.id, v.len() as u64),
|
||||||
hir::ExprRepeat(_, ref n) => {
|
hir::ExprRepeat(_, ref n) => {
|
||||||
let len_hint = ty_hint.checked_or(tcx.types.usize);
|
let len_hint = ty_hint.checked_or(tcx.types.usize);
|
||||||
Repeat(
|
Repeat(
|
||||||
|
|
|
@ -207,7 +207,7 @@ enum SawExprComponent<'a> {
|
||||||
SawExprAgain(Option<token::InternedString>),
|
SawExprAgain(Option<token::InternedString>),
|
||||||
|
|
||||||
SawExprBox,
|
SawExprBox,
|
||||||
SawExprVec,
|
SawExprArray,
|
||||||
SawExprCall,
|
SawExprCall,
|
||||||
SawExprMethodCall,
|
SawExprMethodCall,
|
||||||
SawExprTup,
|
SawExprTup,
|
||||||
|
@ -235,7 +235,7 @@ enum SawExprComponent<'a> {
|
||||||
fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
|
fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
|
||||||
match *node {
|
match *node {
|
||||||
ExprBox(..) => SawExprBox,
|
ExprBox(..) => SawExprBox,
|
||||||
ExprVec(..) => SawExprVec,
|
ExprArray(..) => SawExprArray,
|
||||||
ExprCall(..) => SawExprCall,
|
ExprCall(..) => SawExprCall,
|
||||||
ExprMethodCall(..) => SawExprMethodCall,
|
ExprMethodCall(..) => SawExprMethodCall,
|
||||||
ExprTup(..) => SawExprTup,
|
ExprTup(..) => SawExprTup,
|
||||||
|
|
|
@ -160,7 +160,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||||
.map(|f| unpack!(block = this.as_operand(block, f)))
|
.map(|f| unpack!(block = this.as_operand(block, f)))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
block.and(Rvalue::Aggregate(AggregateKind::Vec, fields))
|
block.and(Rvalue::Aggregate(AggregateKind::Array, fields))
|
||||||
}
|
}
|
||||||
ExprKind::Tuple { fields } => { // see (*) above
|
ExprKind::Tuple { fields } => { // see (*) above
|
||||||
// first process the set of fields
|
// first process the set of fields
|
||||||
|
|
|
@ -613,7 +613,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
value: value.to_ref(),
|
value: value.to_ref(),
|
||||||
value_extents: cx.tcx.region_maps.node_extent(value.id)
|
value_extents: cx.tcx.region_maps.node_extent(value.id)
|
||||||
},
|
},
|
||||||
hir::ExprVec(ref fields) =>
|
hir::ExprArray(ref fields) =>
|
||||||
ExprKind::Vec { fields: fields.to_ref() },
|
ExprKind::Vec { fields: fields.to_ref() },
|
||||||
hir::ExprTup(ref fields) =>
|
hir::ExprTup(ref fields) =>
|
||||||
ExprKind::Tuple { fields: fields.to_ref() },
|
ExprKind::Tuple { fields: fields.to_ref() },
|
||||||
|
|
|
@ -113,7 +113,7 @@ impl<'patcx, 'cx, 'gcx, 'tcx> PatCx<'patcx, 'cx, 'gcx, 'tcx> {
|
||||||
PatternKind::Deref { subpattern: self.to_pattern(subpattern) }
|
PatternKind::Deref { subpattern: self.to_pattern(subpattern) }
|
||||||
}
|
}
|
||||||
|
|
||||||
PatKind::Vec(ref prefix, ref slice, ref suffix) => {
|
PatKind::Slice(ref prefix, ref slice, ref suffix) => {
|
||||||
let ty = self.cx.tcx.node_id_to_type(pat.id);
|
let ty = self.cx.tcx.node_id_to_type(pat.id);
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyRef(_, mt) =>
|
ty::TyRef(_, mt) =>
|
||||||
|
|
|
@ -202,7 +202,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
|
||||||
|
|
||||||
// Array lengths, i.e. [T; constant].
|
// Array lengths, i.e. [T; constant].
|
||||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
||||||
if let hir::TyFixedLengthVec(_, ref length) = ty.node {
|
if let hir::TyArray(_, ref length) = ty.node {
|
||||||
self.build_const_integer(length);
|
self.build_const_integer(length);
|
||||||
}
|
}
|
||||||
intravisit::walk_ty(self, ty);
|
intravisit::walk_ty(self, ty);
|
||||||
|
|
|
@ -602,7 +602,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
|
||||||
hir::ExprIndex(..) |
|
hir::ExprIndex(..) |
|
||||||
hir::ExprField(..) |
|
hir::ExprField(..) |
|
||||||
hir::ExprTupField(..) |
|
hir::ExprTupField(..) |
|
||||||
hir::ExprVec(_) |
|
hir::ExprArray(_) |
|
||||||
hir::ExprType(..) |
|
hir::ExprType(..) |
|
||||||
hir::ExprTup(..) => {}
|
hir::ExprTup(..) => {}
|
||||||
|
|
||||||
|
|
|
@ -569,7 +569,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
match *kind {
|
match *kind {
|
||||||
mir::AggregateKind::Vec => {
|
mir::AggregateKind::Array => {
|
||||||
self.const_array(dest_ty, &fields)
|
self.const_array(dest_ty, &fields)
|
||||||
}
|
}
|
||||||
mir::AggregateKind::Adt(..) |
|
mir::AggregateKind::Adt(..) |
|
||||||
|
|
|
@ -1623,7 +1623,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
}
|
}
|
||||||
|
|
||||||
let result_ty = match ast_ty.node {
|
let result_ty = match ast_ty.node {
|
||||||
hir::TyVec(ref ty) => {
|
hir::TySlice(ref ty) => {
|
||||||
tcx.mk_slice(self.ast_ty_to_ty(rscope, &ty))
|
tcx.mk_slice(self.ast_ty_to_ty(rscope, &ty))
|
||||||
}
|
}
|
||||||
hir::TyObjectSum(ref ty, ref bounds) => {
|
hir::TyObjectSum(ref ty, ref bounds) => {
|
||||||
|
@ -1758,7 +1758,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
|
|
||||||
ty
|
ty
|
||||||
}
|
}
|
||||||
hir::TyFixedLengthVec(ref ty, ref e) => {
|
hir::TyArray(ref ty, ref e) => {
|
||||||
if let Ok(length) = eval_length(tcx.global_tcx(), &e, "array length") {
|
if let Ok(length) = eval_length(tcx.global_tcx(), &e, "array length") {
|
||||||
tcx.mk_array(self.ast_ty_to_ty(rscope, &ty), length)
|
tcx.mk_array(self.ast_ty_to_ty(rscope, &ty), length)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
tcx.types.err
|
tcx.types.err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PatKind::Vec(ref before, ref slice, ref after) => {
|
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||||
let expected_ty = self.structurally_resolved_type(pat.span, expected);
|
let expected_ty = self.structurally_resolved_type(pat.span, expected);
|
||||||
let (inner_ty, slice_ty) = match expected_ty.sty {
|
let (inner_ty, slice_ty) = match expected_ty.sty {
|
||||||
ty::TyArray(inner_ty, size) => {
|
ty::TyArray(inner_ty, size) => {
|
||||||
|
|
|
@ -450,7 +450,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: &'tcx hir::Ty) {
|
fn visit_ty(&mut self, t: &'tcx hir::Ty) {
|
||||||
match t.node {
|
match t.node {
|
||||||
hir::TyFixedLengthVec(_, ref expr) => {
|
hir::TyArray(_, ref expr) => {
|
||||||
check_const_with_type(self.ccx, &expr, self.ccx.tcx.types.usize, expr.id);
|
check_const_with_type(self.ccx, &expr, self.ccx.tcx.types.usize, expr.id);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -626,7 +626,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||||
// need to record the type for that node
|
// need to record the type for that node
|
||||||
fn visit_ty(&mut self, t: &'gcx hir::Ty) {
|
fn visit_ty(&mut self, t: &'gcx hir::Ty) {
|
||||||
match t.node {
|
match t.node {
|
||||||
hir::TyFixedLengthVec(ref ty, ref count_expr) => {
|
hir::TyArray(ref ty, ref count_expr) => {
|
||||||
self.visit_ty(&ty);
|
self.visit_ty(&ty);
|
||||||
self.fcx.check_expr_with_hint(&count_expr, self.fcx.tcx.types.usize);
|
self.fcx.check_expr_with_hint(&count_expr, self.fcx.tcx.types.usize);
|
||||||
}
|
}
|
||||||
|
@ -3590,7 +3590,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.check_method_call(expr, name, &args[..], &tps[..], expected, lvalue_pref)
|
self.check_method_call(expr, name, &args[..], &tps[..], expected, lvalue_pref)
|
||||||
}
|
}
|
||||||
hir::ExprCast(ref e, ref t) => {
|
hir::ExprCast(ref e, ref t) => {
|
||||||
if let hir::TyFixedLengthVec(_, ref count_expr) = t.node {
|
if let hir::TyArray(_, ref count_expr) = t.node {
|
||||||
self.check_expr_with_hint(&count_expr, tcx.types.usize);
|
self.check_expr_with_hint(&count_expr, tcx.types.usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3623,7 +3623,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.check_expr_eq_type(&e, typ);
|
self.check_expr_eq_type(&e, typ);
|
||||||
typ
|
typ
|
||||||
}
|
}
|
||||||
hir::ExprVec(ref args) => {
|
hir::ExprArray(ref args) => {
|
||||||
let uty = expected.to_option(self).and_then(|uty| {
|
let uty = expected.to_option(self).and_then(|uty| {
|
||||||
match uty.sty {
|
match uty.sty {
|
||||||
ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty),
|
ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty),
|
||||||
|
|
|
@ -247,7 +247,7 @@ impl<'cx, 'gcx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'gcx, 'tcx> {
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: &hir::Ty) {
|
fn visit_ty(&mut self, t: &hir::Ty) {
|
||||||
match t.node {
|
match t.node {
|
||||||
hir::TyFixedLengthVec(ref ty, ref count_expr) => {
|
hir::TyArray(ref ty, ref count_expr) => {
|
||||||
self.visit_ty(&ty);
|
self.visit_ty(&ty);
|
||||||
write_ty_to_tcx(self.fcx.ccx, count_expr.id, self.tcx().types.usize);
|
write_ty_to_tcx(self.fcx.ccx, count_expr.id, self.tcx().types.usize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1646,8 +1646,8 @@ impl Clean<Type> for hir::Ty {
|
||||||
TyRptr(ref l, ref m) =>
|
TyRptr(ref l, ref m) =>
|
||||||
BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx),
|
BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx),
|
||||||
type_: box m.ty.clean(cx)},
|
type_: box m.ty.clean(cx)},
|
||||||
TyVec(ref ty) => Vector(box ty.clean(cx)),
|
TySlice(ref ty) => Vector(box ty.clean(cx)),
|
||||||
TyFixedLengthVec(ref ty, ref e) => {
|
TyArray(ref ty, ref e) => {
|
||||||
let n = if let Some(tcx) = cx.tcx_opt() {
|
let n = if let Some(tcx) = cx.tcx_opt() {
|
||||||
use rustc_const_math::{ConstInt, ConstUsize};
|
use rustc_const_math::{ConstInt, ConstUsize};
|
||||||
use rustc_const_eval::eval_const_expr;
|
use rustc_const_eval::eval_const_expr;
|
||||||
|
@ -2699,7 +2699,7 @@ fn name_from_pat(p: &hir::Pat) -> String {
|
||||||
},
|
},
|
||||||
PatKind::Range(..) => panic!("tried to get argument name from PatKind::Range, \
|
PatKind::Range(..) => panic!("tried to get argument name from PatKind::Range, \
|
||||||
which is not allowed in function arguments"),
|
which is not allowed in function arguments"),
|
||||||
PatKind::Vec(ref begin, ref mid, ref end) => {
|
PatKind::Slice(ref begin, ref mid, ref end) => {
|
||||||
let begin = begin.iter().map(|p| name_from_pat(&**p));
|
let begin = begin.iter().map(|p| name_from_pat(&**p));
|
||||||
let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter();
|
let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter();
|
||||||
let end = end.iter().map(|p| name_from_pat(&**p));
|
let end = end.iter().map(|p| name_from_pat(&**p));
|
||||||
|
|
|
@ -593,7 +593,7 @@ impl Pat {
|
||||||
PatKind::Box(ref s) | PatKind::Ref(ref s, _) => {
|
PatKind::Box(ref s) | PatKind::Ref(ref s, _) => {
|
||||||
s.walk(it)
|
s.walk(it)
|
||||||
}
|
}
|
||||||
PatKind::Vec(ref before, ref slice, ref after) => {
|
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||||
before.iter().all(|p| p.walk(it)) &&
|
before.iter().all(|p| p.walk(it)) &&
|
||||||
slice.iter().all(|p| p.walk(it)) &&
|
slice.iter().all(|p| p.walk(it)) &&
|
||||||
after.iter().all(|p| p.walk(it))
|
after.iter().all(|p| p.walk(it))
|
||||||
|
@ -669,8 +669,8 @@ pub enum PatKind {
|
||||||
/// A range pattern, e.g. `1...2`
|
/// A range pattern, e.g. `1...2`
|
||||||
Range(P<Expr>, P<Expr>),
|
Range(P<Expr>, P<Expr>),
|
||||||
/// `[a, b, ..i, y, z]` is represented as:
|
/// `[a, b, ..i, y, z]` is represented as:
|
||||||
/// `PatKind::Vec(box [a, b], Some(i), box [y, z])`
|
/// `PatKind::Slice(box [a, b], Some(i), box [y, z])`
|
||||||
Vec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
|
Slice(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
|
||||||
/// A macro pattern; pre-expansion
|
/// A macro pattern; pre-expansion
|
||||||
Mac(Mac),
|
Mac(Mac),
|
||||||
}
|
}
|
||||||
|
@ -1431,10 +1431,10 @@ pub struct BareFnTy {
|
||||||
/// The different kinds of types recognized by the compiler
|
/// The different kinds of types recognized by the compiler
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub enum TyKind {
|
pub enum TyKind {
|
||||||
/// A variable-length array (`[T]`)
|
/// A variable-length slice (`[T]`)
|
||||||
Vec(P<Ty>),
|
Slice(P<Ty>),
|
||||||
/// A fixed length array (`[T; n]`)
|
/// A fixed length array (`[T; n]`)
|
||||||
FixedLengthVec(P<Ty>, P<Expr>),
|
Array(P<Ty>, P<Expr>),
|
||||||
/// A raw pointer (`*const T` or `*mut T`)
|
/// A raw pointer (`*const T` or `*mut T`)
|
||||||
Ptr(MutTy),
|
Ptr(MutTy),
|
||||||
/// A reference (`&'a T` or `&'a mut T`)
|
/// A reference (`&'a T` or `&'a mut T`)
|
||||||
|
|
|
@ -215,7 +215,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
||||||
|
|
||||||
let ty = ecx.ty(
|
let ty = ecx.ty(
|
||||||
span,
|
span,
|
||||||
ast::TyKind::FixedLengthVec(
|
ast::TyKind::Array(
|
||||||
ecx.ty(
|
ecx.ty(
|
||||||
span,
|
span,
|
||||||
ast::TyKind::Tup(vec![ty_str.clone(), ty_str])
|
ast::TyKind::Tup(vec![ty_str.clone(), ty_str])
|
||||||
|
|
|
@ -1082,14 +1082,14 @@ impl<'a> Visitor for PostExpansionVisitor<'a> {
|
||||||
|
|
||||||
fn visit_pat(&mut self, pattern: &ast::Pat) {
|
fn visit_pat(&mut self, pattern: &ast::Pat) {
|
||||||
match pattern.node {
|
match pattern.node {
|
||||||
PatKind::Vec(_, Some(_), ref last) if !last.is_empty() => {
|
PatKind::Slice(_, Some(_), ref last) if !last.is_empty() => {
|
||||||
gate_feature_post!(&self, advanced_slice_patterns,
|
gate_feature_post!(&self, advanced_slice_patterns,
|
||||||
pattern.span,
|
pattern.span,
|
||||||
"multiple-element slice matches anywhere \
|
"multiple-element slice matches anywhere \
|
||||||
but at the end of a slice (e.g. \
|
but at the end of a slice (e.g. \
|
||||||
`[0, ..xs, 0]`) are experimental")
|
`[0, ..xs, 0]`) are experimental")
|
||||||
}
|
}
|
||||||
PatKind::Vec(..) => {
|
PatKind::Slice(..) => {
|
||||||
gate_feature_post!(&self, slice_patterns,
|
gate_feature_post!(&self, slice_patterns,
|
||||||
pattern.span,
|
pattern.span,
|
||||||
"slice pattern syntax is experimental");
|
"slice pattern syntax is experimental");
|
||||||
|
|
|
@ -356,7 +356,7 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
|
||||||
id: fld.new_id(id),
|
id: fld.new_id(id),
|
||||||
node: match node {
|
node: match node {
|
||||||
TyKind::Infer | TyKind::ImplicitSelf => node,
|
TyKind::Infer | TyKind::ImplicitSelf => node,
|
||||||
TyKind::Vec(ty) => TyKind::Vec(fld.fold_ty(ty)),
|
TyKind::Slice(ty) => TyKind::Slice(fld.fold_ty(ty)),
|
||||||
TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)),
|
TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)),
|
||||||
TyKind::Rptr(region, mt) => {
|
TyKind::Rptr(region, mt) => {
|
||||||
TyKind::Rptr(fld.fold_opt_lifetime(region), fld.fold_mt(mt))
|
TyKind::Rptr(fld.fold_opt_lifetime(region), fld.fold_mt(mt))
|
||||||
|
@ -385,8 +385,8 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
|
||||||
TyKind::ObjectSum(fld.fold_ty(ty),
|
TyKind::ObjectSum(fld.fold_ty(ty),
|
||||||
fld.fold_bounds(bounds))
|
fld.fold_bounds(bounds))
|
||||||
}
|
}
|
||||||
TyKind::FixedLengthVec(ty, e) => {
|
TyKind::Array(ty, e) => {
|
||||||
TyKind::FixedLengthVec(fld.fold_ty(ty), fld.fold_expr(e))
|
TyKind::Array(fld.fold_ty(ty), fld.fold_expr(e))
|
||||||
}
|
}
|
||||||
TyKind::Typeof(expr) => {
|
TyKind::Typeof(expr) => {
|
||||||
TyKind::Typeof(fld.fold_expr(expr))
|
TyKind::Typeof(fld.fold_expr(expr))
|
||||||
|
@ -1092,8 +1092,8 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
|
||||||
PatKind::Range(e1, e2) => {
|
PatKind::Range(e1, e2) => {
|
||||||
PatKind::Range(folder.fold_expr(e1), folder.fold_expr(e2))
|
PatKind::Range(folder.fold_expr(e1), folder.fold_expr(e2))
|
||||||
},
|
},
|
||||||
PatKind::Vec(before, slice, after) => {
|
PatKind::Slice(before, slice, after) => {
|
||||||
PatKind::Vec(before.move_map(|x| folder.fold_pat(x)),
|
PatKind::Slice(before.move_map(|x| folder.fold_pat(x)),
|
||||||
slice.map(|x| folder.fold_pat(x)),
|
slice.map(|x| folder.fold_pat(x)),
|
||||||
after.move_map(|x| folder.fold_pat(x)))
|
after.move_map(|x| folder.fold_pat(x)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1386,8 +1386,8 @@ impl<'a> Parser<'a> {
|
||||||
// Parse the `; e` in `[ i32; e ]`
|
// Parse the `; e` in `[ i32; e ]`
|
||||||
// where `e` is a const expression
|
// where `e` is a const expression
|
||||||
let t = match self.maybe_parse_fixed_length_of_vec()? {
|
let t = match self.maybe_parse_fixed_length_of_vec()? {
|
||||||
None => TyKind::Vec(t),
|
None => TyKind::Slice(t),
|
||||||
Some(suffix) => TyKind::FixedLengthVec(t, suffix)
|
Some(suffix) => TyKind::Array(t, suffix)
|
||||||
};
|
};
|
||||||
self.expect(&token::CloseDelim(token::Bracket))?;
|
self.expect(&token::CloseDelim(token::Bracket))?;
|
||||||
t
|
t
|
||||||
|
@ -3587,7 +3587,7 @@ impl<'a> Parser<'a> {
|
||||||
self.bump();
|
self.bump();
|
||||||
let (before, slice, after) = self.parse_pat_vec_elements()?;
|
let (before, slice, after) = self.parse_pat_vec_elements()?;
|
||||||
self.expect(&token::CloseDelim(token::Bracket))?;
|
self.expect(&token::CloseDelim(token::Bracket))?;
|
||||||
pat = PatKind::Vec(before, slice, after);
|
pat = PatKind::Slice(before, slice, after);
|
||||||
}
|
}
|
||||||
// At this point, token != _, &, &&, (, [
|
// At this point, token != _, &, &&, (, [
|
||||||
_ => if self.eat_keyword(keywords::Mut) {
|
_ => if self.eat_keyword(keywords::Mut) {
|
||||||
|
|
|
@ -972,7 +972,7 @@ impl<'a> State<'a> {
|
||||||
try!(self.maybe_print_comment(ty.span.lo));
|
try!(self.maybe_print_comment(ty.span.lo));
|
||||||
try!(self.ibox(0));
|
try!(self.ibox(0));
|
||||||
match ty.node {
|
match ty.node {
|
||||||
ast::TyKind::Vec(ref ty) => {
|
ast::TyKind::Slice(ref ty) => {
|
||||||
try!(word(&mut self.s, "["));
|
try!(word(&mut self.s, "["));
|
||||||
try!(self.print_type(&ty));
|
try!(self.print_type(&ty));
|
||||||
try!(word(&mut self.s, "]"));
|
try!(word(&mut self.s, "]"));
|
||||||
|
@ -1039,7 +1039,7 @@ impl<'a> State<'a> {
|
||||||
ast::TyKind::ImplTrait(ref bounds) => {
|
ast::TyKind::ImplTrait(ref bounds) => {
|
||||||
try!(self.print_bounds("impl ", &bounds[..]));
|
try!(self.print_bounds("impl ", &bounds[..]));
|
||||||
}
|
}
|
||||||
ast::TyKind::FixedLengthVec(ref ty, ref v) => {
|
ast::TyKind::Array(ref ty, ref v) => {
|
||||||
try!(word(&mut self.s, "["));
|
try!(word(&mut self.s, "["));
|
||||||
try!(self.print_type(&ty));
|
try!(self.print_type(&ty));
|
||||||
try!(word(&mut self.s, "; "));
|
try!(word(&mut self.s, "; "));
|
||||||
|
@ -2573,7 +2573,7 @@ impl<'a> State<'a> {
|
||||||
try!(word(&mut self.s, "..."));
|
try!(word(&mut self.s, "..."));
|
||||||
try!(self.print_expr(&end));
|
try!(self.print_expr(&end));
|
||||||
}
|
}
|
||||||
PatKind::Vec(ref before, ref slice, ref after) => {
|
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||||
try!(word(&mut self.s, "["));
|
try!(word(&mut self.s, "["));
|
||||||
try!(self.commasep(Inconsistent,
|
try!(self.commasep(Inconsistent,
|
||||||
&before[..],
|
&before[..],
|
||||||
|
|
|
@ -572,7 +572,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
|
||||||
let static_lt = ecx.lifetime(sp, keywords::StaticLifetime.name());
|
let static_lt = ecx.lifetime(sp, keywords::StaticLifetime.name());
|
||||||
// &'static [self::test::TestDescAndFn]
|
// &'static [self::test::TestDescAndFn]
|
||||||
let static_type = ecx.ty_rptr(sp,
|
let static_type = ecx.ty_rptr(sp,
|
||||||
ecx.ty(sp, ast::TyKind::Vec(struct_type)),
|
ecx.ty(sp, ast::TyKind::Slice(struct_type)),
|
||||||
Some(static_lt),
|
Some(static_lt),
|
||||||
ast::Mutability::Immutable);
|
ast::Mutability::Immutable);
|
||||||
// static TESTS: $static_type = &[...];
|
// static TESTS: $static_type = &[...];
|
||||||
|
|
|
@ -313,7 +313,7 @@ pub fn walk_variant<V>(visitor: &mut V, variant: &Variant, generics: &Generics,
|
||||||
|
|
||||||
pub fn walk_ty<V: Visitor>(visitor: &mut V, typ: &Ty) {
|
pub fn walk_ty<V: Visitor>(visitor: &mut V, typ: &Ty) {
|
||||||
match typ.node {
|
match typ.node {
|
||||||
TyKind::Vec(ref ty) | TyKind::Paren(ref ty) => {
|
TyKind::Slice(ref ty) | TyKind::Paren(ref ty) => {
|
||||||
visitor.visit_ty(ty)
|
visitor.visit_ty(ty)
|
||||||
}
|
}
|
||||||
TyKind::Ptr(ref mutable_type) => {
|
TyKind::Ptr(ref mutable_type) => {
|
||||||
|
@ -341,7 +341,7 @@ pub fn walk_ty<V: Visitor>(visitor: &mut V, typ: &Ty) {
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
walk_list!(visitor, visit_ty_param_bound, bounds);
|
walk_list!(visitor, visit_ty_param_bound, bounds);
|
||||||
}
|
}
|
||||||
TyKind::FixedLengthVec(ref ty, ref expression) => {
|
TyKind::Array(ref ty, ref expression) => {
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
visitor.visit_expr(expression)
|
visitor.visit_expr(expression)
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,7 @@ pub fn walk_pat<V: Visitor>(visitor: &mut V, pattern: &Pat) {
|
||||||
visitor.visit_expr(upper_bound)
|
visitor.visit_expr(upper_bound)
|
||||||
}
|
}
|
||||||
PatKind::Wild => (),
|
PatKind::Wild => (),
|
||||||
PatKind::Vec(ref prepatterns, ref slice_pattern, ref postpatterns) => {
|
PatKind::Slice(ref prepatterns, ref slice_pattern, ref postpatterns) => {
|
||||||
walk_list!(visitor, visit_pat, prepatterns);
|
walk_list!(visitor, visit_pat, prepatterns);
|
||||||
walk_list!(visitor, visit_pat, slice_pattern);
|
walk_list!(visitor, visit_pat, slice_pattern);
|
||||||
walk_list!(visitor, visit_pat, postpatterns);
|
walk_list!(visitor, visit_pat, postpatterns);
|
||||||
|
|
|
@ -506,7 +506,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||||
-> P<ast::Expr> {
|
-> P<ast::Expr> {
|
||||||
let sp = piece_ty.span;
|
let sp = piece_ty.span;
|
||||||
let ty = ecx.ty_rptr(sp,
|
let ty = ecx.ty_rptr(sp,
|
||||||
ecx.ty(sp, ast::TyKind::Vec(piece_ty)),
|
ecx.ty(sp, ast::TyKind::Slice(piece_ty)),
|
||||||
Some(ecx.lifetime(sp, keywords::StaticLifetime.name())),
|
Some(ecx.lifetime(sp, keywords::StaticLifetime.name())),
|
||||||
ast::Mutability::Immutable);
|
ast::Mutability::Immutable);
|
||||||
let slice = ecx.expr_vec_slice(sp, pieces);
|
let slice = ecx.expr_vec_slice(sp, pieces);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue