-
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
[const_generics]: encountered bad ConstKind in codegen #70125
Comments
Got same error with: #![feature(const_generics)]
pub fn broke(const_g: u8) -> () {}
pub trait A<const CONST_GEN: u8> {
fn call_broken() -> () {
broke(CONST_GEN)
}
}
// Cloning the const works. (if you need a temporary workaround)
//pub trait A<const CONST_GEN: u8> {
// fn call_ok() -> () {
// let x = CONST_GEN.clone();
// broke(x)
// }
//}
const CONST: u8 = 2;
struct Test {}
impl A<CONST> for Test {}
impl Test {
fn call_broken_<const CONST: u8>() -> () {
broke(CONST)
}
}
fn call_ok<const CONST: u8>() -> () {
broke(CONST)
}
fn main() {
call_ok::<CONST>();
Test::call_broken();
Test::call_broken_::<CONST>();
} It seems unrelated to the type of the const |
@rustbot claim |
Reduced: #![feature(const_generics)]
fn main() {
<()>::foo();
}
trait Foo<const X: usize> {
fn foo() -> usize {
X
}
}
impl Foo<{3}> for () {} Looks like a normalization failure to me, but that shouldn't happen for |
So I found the bug, rust/src/librustc/ty/normalize_erasing_regions.rs Lines 96 to 98 in a039217
But also, it's worrying that an equivalent to this is missing for consts (even if it's not relevant here):
|
handle ConstKind::Unresolved after monomorphizing fixes rust-lang#70125 r? @bjorn3
handle ConstKind::Unresolved after monomorphizing fixes rust-lang#70125 r? @bjorn3
@varkor @yodaldevoid @wesleywiser @oli-obk For the record, what I described above (#70125 (comment)) isn't fixed, just worked around. EDIT: opened #70317. |
correctly normalize constants closes rust-lang#70317 implements rust-lang#70125 (comment) r? eddyb cc @varkor
correctly normalize constants closes rust-lang#70317 implements rust-lang#70125 (comment) r? eddyb cc @varkor
correctly normalize constants closes rust-lang#70317 implements rust-lang#70125 (comment) r? eddyb cc @varkor
correctly normalize constants closes rust-lang#70317 implements rust-lang#70125 (comment) r? eddyb cc @varkor
Code
Meta
rustc --version --verbose
:Error output
Backtrace
This issue has been assigned to @lcnr via this comment.
The text was updated successfully, but these errors were encountered: