diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-09-22 14:48:59 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-22 14:48:59 +0300 |
| commit | a5503a33e6bfe503089cd776c97da9cc8e00bd37 (patch) | |
| tree | 9887f7e0bfee51386e57adeed7c402174b9bee34 /src | |
| parent | 728e66473999abf7de5a037158df8e3a7d19be40 (diff) | |
| parent | 1ad9709e0032c2f3c37c4a156419cadb7e9c17ac (diff) | |
| download | rust-a5503a33e6bfe503089cd776c97da9cc8e00bd37.tar.gz rust-a5503a33e6bfe503089cd776c97da9cc8e00bd37.zip | |
Merge pull request #350 from RalfJung/inhabited
get rid of ad-hoc inhabitedness test
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 6 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/terminator/mod.rs | 3 |
2 files changed, 1 insertions, 8 deletions
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 8fb63b3cb2c..0d761c24593 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -1818,7 +1818,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { let val = match val { PrimVal::Bytes(0) => false, PrimVal::Bytes(1) => true, - // TODO: This seems a little overeager, should reading at bool type already be UB? + // TODO: This seems a little overeager, should reading at bool type already be insta-UB? _ => return err!(InvalidBool), }; PrimVal::from_bool(val) @@ -2237,10 +2237,6 @@ impl IntegerExt for layout::Integer { } } -pub fn is_inhabited<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { - ty.uninhabited_from(&mut HashMap::default(), tcx).is_empty() -} - /// FIXME: expose trans::monomorphize::resolve_closure pub fn resolve_closure<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc_mir/interpret/terminator/mod.rs b/src/librustc_mir/interpret/terminator/mod.rs index bee0fe23f7f..e01777cdb4e 100644 --- a/src/librustc_mir/interpret/terminator/mod.rs +++ b/src/librustc_mir/interpret/terminator/mod.rs @@ -251,9 +251,6 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { _ => return err!(Unreachable), }; let ty = sig.output(); - if !eval_context::is_inhabited(self.tcx, ty) { - return err!(Unreachable); - } let layout = self.type_layout(ty)?; M::call_intrinsic(self, instance, args, ret, ty, layout, target)?; self.dump_local(ret); |
