Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexcrichton opened this issue Jul 22, 2018 · 2 comments · Fixed by #52695
Closed

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

alexcrichton opened this issue Jul 22, 2018 · 2 comments · Fixed by #52695
Labels
regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@alexcrichton
Copy link
Member

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?

@alexcrichton alexcrichton added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 22, 2018
@alexcrichton alexcrichton added this to the 1.29 milestone Jul 22, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Jul 22, 2018

Yea I do. This is fallout from making sure 1/(false as usize) lints about division by zero.

While the lint message is nonsensical, we should be linting the truncation of addresses, should we not?

@alexcrichton
Copy link
Member Author

True! I'd be fine with a warning to say "you should use usize to avoid losing data"

koute added a commit to koute/stdweb that referenced this issue Jul 23, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 26, 2018
…nkov

Hide some lints which are not quite right the way they are reported to the user

fixes rust-lang#52603
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants