You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structGeneric<V>{val:V,}structConcrete{val:&'static [i32],}// Produces the errorconstGENERIC:Generic<&'static [i32]> = Generic{val:&[0]};constCONCRETE:Concrete = Concrete{val:&[0]};// Works by coercing in a concrete contextconstWORKAROUND:Generic<&'static [i32]> = Generic{val:{constVAL:&'static [i32] = &[0];VAL}};// (Type ascription works as well but is gated)
Produces the following error on stable and nightly (new nightly formatting):
error: mismatched types [--explain E0308]
--> <anon>:9:42
9 |> const GENERIC: Generic<&'static [i32]> = Generic { val: &[0] };
|> ^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 1 elements
note: expected type `Generic<&'static [i32]>`
note: found type `Generic<&[_; 1]>`
error: aborting due to previous error
Comment out line 9 and it compiles successfully.
I did my best to search for a duplicate but nothing came up, although something tells me this is a known issue already. Sorry if it is actually duplicate.
Note: this is not restricted to generic context, it's just where I discovered it.
The text was updated successfully, but these errors were encountered:
abonander
changed the title
Array ref to slice coercion fails in const + generic context
Array ref to slice coercion fails in generic context
Jun 12, 2016
Simplest test case I could come up with:
Playground
Produces the following error on stable and nightly (new nightly formatting):
Comment out line 9 and it compiles successfully.
I did my best to search for a duplicate but nothing came up, although something tells me this is a known issue already. Sorry if it is actually duplicate.
Note: this is not restricted to generic context, it's just where I discovered it.
The text was updated successfully, but these errors were encountered: