}
}
+ ProjectionElem::ConstantIndex {..} |
+ ProjectionElem::Subslice {..} |
ProjectionElem::Field(..) |
ProjectionElem::Index(_) => {
let base_ty = proj.base.ty(this.mir, this.tcx).to_ty(this.tcx);
this.qualif.restrict(ty, this.tcx, this.param_env);
}
- ProjectionElem::ConstantIndex {..} |
- ProjectionElem::Subslice {..} |
ProjectionElem::Downcast(..) => {
this.not_const()
}
Place::Static(_) => Err((span, "cannot access `static` items in const fn".into())),
Place::Projection(proj) => {
match proj.elem {
+ | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. }
| ProjectionElem::Deref | ProjectionElem::Field(..) | ProjectionElem::Index(_) => {
check_place(tcx, mir, &proj.base, span)
}
- // slice patterns are unstable
- | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. } => {
- return Err((span, "slice patterns in const fn are unstable".into()))
- }
| ProjectionElem::Downcast(..) => {
Err((span, "`match` or `if let` in `const fn` is unstable".into()))
}
--- /dev/null
+// compile-pass
+
+fn main() {}
+
+const fn tup((a, b): (i32, i32)) -> i32 {
+ a + b
+}
+
+const fn array([a, b]: [i32; 2]) -> i32 {
+ a + b
+}
--- /dev/null
+fn main() {}
+
+const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument
+ a + b
+}
--- /dev/null
+error[E0005]: refutable pattern in function argument: `&[]` not covered
+ --> $DIR/const_let_refutable.rs:3:16
+ |
+LL | const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument
+ | ^^^^^^ pattern `&[]` not covered
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0005`.