Skip to content

Commit 7da24a2

Browse files
authored
Rollup merge of #71149 - RalfJung:check-const-call, r=eddyb
remove an impossible branch from check_consts All function calleess are either `FnPtr` or `FnDef`, so we can remove the alternative from check_consts and just make it ICE instead.
2 parents e4ec796 + 49b745f commit 7da24a2

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/librustc_mir/transform/check_consts/ops.rs

-10
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,6 @@ impl NonConstOp for FnCallNonConst {
9090
}
9191
}
9292

93-
/// A function call where the callee is not a function definition or function pointer, e.g. a
94-
/// closure.
95-
///
96-
/// This can be subdivided in the future to produce a better error message.
97-
#[derive(Debug)]
98-
pub struct FnCallOther;
99-
impl NonConstOp for FnCallOther {
100-
const IS_SUPPORTED_IN_MIRI: bool = false;
101-
}
102-
10393
/// A call to a `#[unstable]` const fn or `#[rustc_const_unstable]` function.
10494
///
10595
/// Contains the name of the feature that would allow the use of this function.

src/librustc_mir/transform/check_consts/validation.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,11 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
495495
}
496496
}
497497

498-
fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, location: Location) {
499-
trace!("visit_terminator_kind: kind={:?} location={:?}", kind, location);
500-
self.super_terminator_kind(kind, location);
498+
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
499+
trace!("visit_terminator: terminator={:?} location={:?}", terminator, location);
500+
self.super_terminator(terminator, location);
501501

502-
match kind {
502+
match &terminator.kind {
503503
TerminatorKind::Call { func, .. } => {
504504
let fn_ty = func.ty(*self.body, self.tcx);
505505

@@ -511,8 +511,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
511511
return;
512512
}
513513
_ => {
514-
self.check_op(ops::FnCallOther);
515-
return;
514+
span_bug!(terminator.source_info.span, "invalid callee of type {:?}", fn_ty)
516515
}
517516
};
518517

0 commit comments

Comments
 (0)