-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[Nightly] LLVM Assertion: SrcTy must be larger than DestTy for Trunc #41744
Comments
The error comes from the |
That was fast. Just to add a bit of context:
The difference between pub trait ToColumnData {
fn to_column_data(&self) -> ColumnData;
}
pub trait ToSql : ToColumnData {
fn to_sql(&self) -> &'static str;
}
Interestingly enough it's not enough for reproduction to just define (And FromColumnData is used for the .get assert) Therefore I'm not quite sure about what's actually causing this. |
Reduced test case: trait Tc {}
impl Tc for bool {}
fn main() {
let _: &[&Tc] = &[&true];
} ( |
LLDB Stack trace
Triggered from this line: if projected_ty.is_bool() {
unsafe {
val = llvm::LLVMConstTrunc(val, Type::i1(self.ccx).to_ref());
}
} Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
...
assert(C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&&
"SrcTy must be larger than DestTy for Trunc!"); |
|
Still fails on master for me, did you build with LLVM Assertions, @kennytm? |
@TimNN Ah |
Introduced in the rollup #41717 which leads me to highly suspect #41625 (cc @nikomatsakis). |
The problem appears to be that in https://github.com/rust-lang/rust/blob/master/src/librustc_trans/mir/constant.rs#L419 I don't know enough about that part of the compiler / LLVM to decide what the fix here should be. |
Here is the diff of |
Ah, so with |
With |
Seems like the right fix is just to skip the call to truncate if the thing is already boolean. @eddyb will take it. |
rustc_trans: do not attempt to truncate an i1 const to i1. Fixes rust-lang#41744 by skipping the truncation when it'd be a noop anyway.
rustc_trans: do not attempt to truncate an i1 const to i1. Fixes rust-lang#41744 by skipping the truncation when it'd be a noop anyway.
rustc_trans: do not attempt to truncate an i1 const to i1. Fixes rust-lang#41744 by skipping the truncation when it'd be a noop anyway.
rustc_trans: do not attempt to truncate an i1 const to i1. Fixes rust-lang#41744 by skipping the truncation when it'd be a noop anyway.
rustc_trans: do not attempt to truncate an i1 const to i1. Fixes rust-lang#41744 by skipping the truncation when it'd be a noop anyway.
rustc_trans: do not attempt to truncate an i1 const to i1. Fixes rust-lang#41744 by skipping the truncation when it'd be a noop anyway.
Last good version:
rustc 1.19.0-nightly (6a5fc9eec 2017-05-02)
(previous nightly)Version:
rustc 1.19.0-nightly (2d4ed8e0c 2017-05-03)
Unfortunately I can't provide a small testcase for reproduction,
but the following works reliably:
Reproduction
EDIT: For readability the reduced example from below:
OLD:
Output:
The text was updated successfully, but these errors were encountered: