Skip to content

Commit bd8a6d7

Browse files
Allow Downcast projections unconditionally
1 parent d7afaa7 commit bd8a6d7

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

src/librustc_mir/transform/check_consts/ops.rs

-9
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ pub trait NonConstOp: std::fmt::Debug {
5353
}
5454
}
5555

56-
/// A `Downcast` projection.
57-
#[derive(Debug)]
58-
pub struct Downcast;
59-
impl NonConstOp for Downcast {
60-
fn feature_gate() -> Option<Symbol> {
61-
Some(sym::const_if_match)
62-
}
63-
}
64-
6556
/// A function call where the callee is a pointer.
6657
#[derive(Debug)]
6758
pub struct FnCallIndirect;

src/librustc_mir/transform/check_consts/validation.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
448448
}
449449

450450
ProjectionElem::ConstantIndex { .. }
451+
| ProjectionElem::Downcast(..)
451452
| ProjectionElem::Subslice { .. }
452453
| ProjectionElem::Field(..)
453454
| ProjectionElem::Index(_) => {
@@ -460,10 +461,6 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
460461
_ => {}
461462
}
462463
}
463-
464-
ProjectionElem::Downcast(..) => {
465-
self.check_op(ops::Downcast);
466-
}
467464
}
468465
}
469466

src/librustc_mir/transform/qualify_min_const_fn.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,6 @@ fn check_place(
286286
while let &[ref proj_base @ .., elem] = cursor {
287287
cursor = proj_base;
288288
match elem {
289-
ProjectionElem::Downcast(..) if !feature_allowed(tcx, def_id, sym::const_if_match) => {
290-
return Err((span, "`match` or `if let` in `const fn` is unstable".into()));
291-
}
292-
ProjectionElem::Downcast(_symbol, _variant_index) => {}
293-
294289
ProjectionElem::Field(..) => {
295290
let base_ty = Place::ty_from(place.local, &proj_base, body, tcx).ty;
296291
if let Some(def) = base_ty.ty_adt_def() {
@@ -303,6 +298,7 @@ fn check_place(
303298
}
304299
}
305300
ProjectionElem::ConstantIndex { .. }
301+
| ProjectionElem::Downcast(..)
306302
| ProjectionElem::Subslice { .. }
307303
| ProjectionElem::Deref
308304
| ProjectionElem::Index(_) => {}

0 commit comments

Comments
 (0)