use syntax::ast;
use syntax_pos;
use errors::DiagnosticBuilder;
-use rustc::hir;
pub struct MoveErrorCollector<'tcx> {
errors: Vec<MoveError<'tcx>>
err
}
- Categorization::Interior(ref b, mc::InteriorElement(Kind::Index, _)) => {
- let expr = bccx.tcx.map.expect_expr(move_from.id);
- if let hir::ExprIndex(..) = expr.node {
- let mut err = struct_span_err!(bccx, move_from.span, E0508,
- "cannot move out of type `{}`, \
- a non-copy fixed-size array",
- b.ty);
- err.span_label(move_from.span, &format!("cannot move out of here"));
- err
- } else {
- span_bug!(move_from.span, "this path should not cause illegal move");
+ Categorization::Interior(ref b, mc::InteriorElement(ik, _)) => {
+ match (&b.ty.sty, ik) {
+ (&ty::TySlice(..), _) |
+ (_, Kind::Index) => {
+ let mut err = struct_span_err!(bccx, move_from.span, E0508,
+ "cannot move out of type `{}`, \
+ a non-copy array",
+ b.ty);
+ err.span_label(move_from.span, &format!("cannot move out of here"));
+ err
+ }
+ (_, Kind::Pattern) => {
+ span_bug!(move_from.span, "this path should not cause illegal move");
+ }
}
}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(slice_patterns, box_patterns)]
+
+struct A;
+
+fn main() {
+ let a: Box<[A]> = Box::new([A]);
+ match a {
+ box [a] => {}, //~ ERROR cannot move out of type `[A]`
+ _ => {}
+ }
+}