Skip to content

Commit

Permalink
Remove the interprter's check for project_downcast on unihabited vari…
Browse files Browse the repository at this point in the history
…ants
  • Loading branch information
saethlin committed Dec 10, 2023
1 parent 2b399b5 commit eea05d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
5 changes: 0 additions & 5 deletions compiler/rustc_const_eval/src/interpret/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@ where
// see https://github.com/rust-lang/rust/issues/93688#issuecomment-1032929496.)
// So we just "offset" by 0.
let layout = base.layout().for_variant(self, variant);
if layout.abi.is_uninhabited() {
// `read_discriminant` should have excluded uninhabited variants... but ConstProp calls
// us on dead code.
throw_inval!(ConstPropNonsense)
}
// This cannot be `transmute` as variants *can* have a smaller size than the entire enum.
base.offset(Size::ZERO, layout, self)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#![feature(noop_waker)]
use std::future::Future;

enum Runtime {}

async fn run(_: Runtime) {}

async fn apply_timeout() {
let c = async {};
match None::<Runtime> {
None => {
c.await;
},
Some(r) => {
run(r).await;
}
}
}

fn main() {
let waker = std::task::Waker::noop();
let mut ctx = std::task::Context::from_waker(&waker);
let fut = std::pin::pin!(apply_timeout());
let _ = fut.poll(&mut ctx);
}

0 comments on commit eea05d4

Please sign in to comment.