-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
I saw that #51086 was closed when #51225 was merged so I thought it would fix the same error on my own code as well however as of nightly: rustc 1.28.0-nightly (aa094a43c 2018-06-01)
it still happens.
Code:
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct Stat {
pub id: u8,
pub index: usize,
}
impl Stat {
pub const STUDENT_HAPPINESS: Stat = Stat{
id: 0,
index: 0,
};
pub const STUDENT_HUNGER: Stat = Stat{
id: 0,
index: Self::STUDENT_HAPPINESS.index + 1,
};
}
pub fn from_index(id: u8, index: usize) -> Option<Stat> {
let stat = Stat{id, index};
match stat {
Stat::STUDENT_HAPPINESS => Some(Stat::STUDENT_HAPPINESS),
Stat::STUDENT_HUNGER => Some(Stat::STUDENT_HUNGER),
_ => None,
}
}
fn main() { }
Playground: http://play.rust-lang.org/?gist=cf51c77c20f06ca15f1dc2cc4fa779b0&version=nightly&mode=debug
From what I can tell its an alignment issue because changing id from a u8
to a u64
fixes the issue.
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.