Allow Downcast projections unconditionally

This commit is contained in:
Dylan MacKenzie 2020-04-29 10:29:04 -07:00
parent d7afaa7247
commit bd8a6d7911
3 changed files with 2 additions and 18 deletions

View File

@ -53,15 +53,6 @@ pub trait NonConstOp: std::fmt::Debug {
}
}
/// A `Downcast` projection.
#[derive(Debug)]
pub struct Downcast;
impl NonConstOp for Downcast {
fn feature_gate() -> Option<Symbol> {
Some(sym::const_if_match)
}
}
/// A function call where the callee is a pointer.
#[derive(Debug)]
pub struct FnCallIndirect;

View File

@ -448,6 +448,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
}
ProjectionElem::ConstantIndex { .. }
| ProjectionElem::Downcast(..)
| ProjectionElem::Subslice { .. }
| ProjectionElem::Field(..)
| ProjectionElem::Index(_) => {
@ -460,10 +461,6 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
_ => {}
}
}
ProjectionElem::Downcast(..) => {
self.check_op(ops::Downcast);
}
}
}

View File

@ -286,11 +286,6 @@ fn check_place(
while let &[ref proj_base @ .., elem] = cursor {
cursor = proj_base;
match elem {
ProjectionElem::Downcast(..) if !feature_allowed(tcx, def_id, sym::const_if_match) => {
return Err((span, "`match` or `if let` in `const fn` is unstable".into()));
}
ProjectionElem::Downcast(_symbol, _variant_index) => {}
ProjectionElem::Field(..) => {
let base_ty = Place::ty_from(place.local, &proj_base, body, tcx).ty;
if let Some(def) = base_ty.ty_adt_def() {
@ -303,6 +298,7 @@ fn check_place(
}
}
ProjectionElem::ConstantIndex { .. }
| ProjectionElem::Downcast(..)
| ProjectionElem::Subslice { .. }
| ProjectionElem::Deref
| ProjectionElem::Index(_) => {}