Skip to content
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

Miri comparison sanity check is wrong #70804

Closed
RalfJung opened this issue Apr 5, 2020 · 1 comment · Fixed by #70806
Closed

Miri comparison sanity check is wrong #70804

RalfJung opened this issue Apr 5, 2020 · 1 comment · Fixed by #70806
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-miri Area: The miri tool C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@RalfJung
Copy link
Member

RalfJung commented Apr 5, 2020

The following ICEs (example by @eddyb):

#![feature(const_fn)]

const fn nested(x: (for<'a> fn(&'a ()), String)) -> (fn(&'static ()), String) {
    x
}

pub const TEST: (fn(&'static ()), String) = nested((|_x| (), String::new()));

fn main() {}

shows

thread 'rustc' panicked at 'type mismatch when copying!
src: (for<'r> fn(&'r ()), std::string::String),
dest: (fn(&()), std::string::String)', /rustc/853c4774e26ea97b45fe74de9a6f68e526784323/src/libstd/macros.rs:16:9

This means that the check here is wrong. It might be possible to also trigger this without nightly features through const_prop.

@RalfJung RalfJung added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. A-const-eval Area: Constant evaluation (MIR interpretation) A-miri Area: The miri tool F-const_fn labels Apr 5, 2020
@RalfJung
Copy link
Member Author

RalfJung commented Apr 5, 2020

Baring a way to do the proper structural subtyping check, the only solution I see is to go back to comparing layouts in all cases (as a fallback after types mismatch) -- but @eddyb does not like this, as far as I recall. Any other proposals?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-miri Area: The miri tool C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant