Skip to content

Spurious "this expression will panic at runtime" error (regression) #52603

Closed
@alexcrichton

Description

@alexcrichton

This code:

pub trait Foo {
    fn foo(self) -> u32;
}

impl<T> Foo for T {
    fn foo(self) -> u32 {
        fn bar<T>() { loop {} }
        bar::<T> as u32
    }
}

when compiled yields:

$ rustc +nightly foo.rs --crate-type lib
error: this expression will panic at runtime
 --> foo.rs:8:9
  |
8 |         bar::<T> as u32
  |         ^^^^^^^^^^^^^^^ a raw memory access tried to access part of a pointer value as raw bytes
  |
  = note: #[deny(const_err)] on by default

error: aborting due to previous error

but it compiles on stable/beta!

cc @oli-obk, you may know where this is coming from?

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions