Skip to content

Commit

Permalink
Rollup merge of #71149 - RalfJung:check-const-call, r=eddyb
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dylan-DPC authored Apr 16, 2020
2 parents e4ec796 + 49b745f commit 7da24a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
10 changes: 0 additions & 10 deletions src/librustc_mir/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ impl NonConstOp for FnCallNonConst {
}
}

/// A function call where the callee is not a function definition or function pointer, e.g. a
/// closure.
///
/// This can be subdivided in the future to produce a better error message.
#[derive(Debug)]
pub struct FnCallOther;
impl NonConstOp for FnCallOther {
const IS_SUPPORTED_IN_MIRI: bool = false;
}

/// A call to a `#[unstable]` const fn or `#[rustc_const_unstable]` function.
///
/// Contains the name of the feature that would allow the use of this function.
Expand Down
11 changes: 5 additions & 6 deletions src/librustc_mir/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,11 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
}
}

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

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

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

Expand Down

0 comments on commit 7da24a2

Please sign in to comment.