Repository navigation
Closed
Labels
regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
I discovered this bug while tinkering with the frunk crate.
#[derive(PartialEq, Debug)]
struct Cons<H, T: Hlist> {
head: H,
tail: T
}
#[derive(PartialEq, Debug)]
struct Nil;
trait Hlist {}
impl<H, T: Hlist> Hlist for Cons<H, T> {}
impl Hlist for Nil {}
fn main() {
// This part works fine
let x = Cons {head: Some(&0), tail: Nil};
let y = Cons {head: Some(&0), tail: Nil};
assert_eq!(x, y);
// This apparently-equivalent code fails to compile (passes cargo-check but not cargo-build)
assert_eq!(
Cons {head: Some(&0), tail: Nil},
Cons {head: Some(&0), tail: Nil}
);
}
This code compiles and runs on stable.
➜ rustup default stable
info: using existing install for 'stable-x86_64-unknown-linux-gnu'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
stable-x86_64-unknown-linux-gnu unchanged - rustc 1.30.0 (da5f414c2 2018-10-24)
➜ cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.12s
But fails on nightly
➜ rustup default nightly
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'
nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.31.0-nightly (cae6efc37 2018-10-27)
➜ cargo build
Compiling typeck v0.1.0
error[E0080]: it is undefined behavior to use this value
--> src/main.rs:15:1
|
15 | / fn main() {
16 | |
17 | | // This part works fine
18 | | let x = Cons {head: Some(&0), tail: Nil};
... |
26 | | );
27 | | }
| |_^ type validation failed: encountered a pointer, but expected something that cannot possibly be outside the (wrapping) range 1..=0
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.
error: Could not compile `typeck`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Activity
jesskfullwood commentedon Oct 28, 2018
Reduced repro:
memoryruins commentedon Oct 29, 2018
rustc 1.31.0-nightly (4bd4e4130 2018-10-25)rustc 1.31.0-nightly (3e6f30ec3 2018-10-26)rustc 1.31.0-nightly (cae6efc37 2018-10-27)rustc 1.31.0-nightly (96064eb61 2018-10-28)oli-obk commentedon Oct 29, 2018
I cannot reproduce this on the playground
RalfJung commentedon Oct 29, 2018
Playground has an "ancient" nightly (2018-10-25).
RalfJung commentedon Oct 29, 2018
@memoryruins can you also test 2018-10-26?
So far, we got this commit range: 4bd4e41...cae6efc. @oli-obk's CTFE query PR landed there.
memoryruins commentedon Oct 29, 2018
(3e6f30ec3 2018-10-26)also produces the errorRalfJung commentedon Oct 29, 2018
@memoryruins thanks! Regression range is 4bd4e41...3e6f30e then.
oli-obk commentedon Oct 29, 2018
I have confirmed the issue to been exposed by the CTFE query PR.
We didn't use to validate promoteds. My PR only exposed the preexisting issue:
Fails on nightly even before my PR.
memoryruins commentedon Oct 29, 2018
Oh cool! cargo-bisect can pinpoint a regressing PR. Unable to try it out today, but definitely bookmarking :)
edit: wonder how it would handle this after seeing oli’s comment.
oli-obk commentedon Oct 29, 2018
easy: bisect my example with the constant instead of the original one
I have a very good idea which change is at fault though: https://github.com/rust-lang/rust/pull/54762/files#diff-269a7510489262b796ff39a89b2dbdc2R283 was introduced replacing https://github.com/rust-lang/rust/pull/54762/files#diff-269a7510489262b796ff39a89b2dbdc2L142
fix-PR incoming
Rollup merge of rust-lang#55474 - oli-obk:const_eval_promoted, r=Ralf…