-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
broken MIR when transmuting integer to &'static () in const generic #72293
Comments
Still ICEs but needs const_transmute removed from features after #72920 #![feature(const_generics)]
struct Const<const P: &'static ()>;
fn main() {
const A: &'static () = unsafe {
std::mem::transmute(10 as *const ())
};
let _ = Const::<{A}>;
} |
…lcnr,estebank Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics` Closes rust-lang#61410. Adds `min_const_generics` tests for: - rust-lang#73727 - rust-lang#72293 - rust-lang#67375 - rust-lang#75153 - rust-lang#71922 - rust-lang#69913 - rust-lang#67945 - rust-lang#69239 Adds `const_generics` tests for: - rust-lang#67375 - rust-lang#75153 - rust-lang#71922 - rust-lang#69913 - rust-lang#67945 - rust-lang#69239 (I only added separate `min_const_generics` and `const_generics` tests if they were handled differently by the two features.) We need to figure out how to deduplicate when `const_generics` is stabilised, but we can discuss that later. For now, we should be checking neither feature breaks, so require regression tests for both. I've given them identical names when I've added both, which should make it easier to spot them later. r? @lcnr
No longer ICEs, bisect shows since #82936 Could do with a test for full const_generics I believe |
@oli-obk is that an expected side-effect of your PR? |
Not expected before that PR, but the ICE in this issue "obviously" (in hindsight) occurred because before 019dba0 the problem was that types were compared exactly (including lifetimes), so a constant of type |
You can have constants with non-static lifetimes, even if their target actually does live forever. use std::marker::PhantomData;
struct Foo<'a>(&'a (), PhantomData<fn(&'a ()) -> &'a ()>);
fn covariant<'a>(v: Foo<'static>) -> Foo<'a> {
v // ERROR mismatched types
}
fn covariant_xd<'a>(_: Foo<'static>) -> Foo<'a> {
Foo::<'a>::ASSOC
}
impl<'a> Foo<'a> {
const ASSOC: Foo<'a> = Foo(&(), PhantomData);
} (https://twitter.com/lcnr7/status/1360218268703817733) Or just struct Foo<'a>(&'a ());
impl<'a> Foo<'a> {
const N: &'a () = &();
} |
Right. Even so, this doesn't affect |
…i-obk Run full const-generics test for issue-72293 Closes rust-lang#72293 r? `@oli-obk`
…i-obk Run full const-generics test for issue-72293 Closes rust-lang#72293 r? ``@oli-obk``
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: