-
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
Fix ICE when using Box<T, A> with pointer sized A #94043
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,7 +330,9 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { | |
ty::Ref(..) | ty::RawPtr(_) => { | ||
return self.field(cx, index).llvm_type(cx); | ||
} | ||
ty::Adt(def, _) if def.is_box() => { | ||
// only wide pointer boxes are handled as pointers | ||
// thin pointer boxes with scalar allocators are handled by the general logic below | ||
ty::Adt(def, substs) if def.is_box() && cx.layout_of(substs.type_at(1)).is_zst() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @antoyo I think cg_gcc needs the same fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like applying the same fix cause another issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the problem is that in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, fixed it in cg_clif in bjorn3/rustc_codegen_cranelift@401b034. Feel free to copy the changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, that doesn't solve the issue. I made changes more similar to liballoc itself, but got another ICE:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see what you mean. |
||
let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty()); | ||
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// check-pass | ||
#![feature(allocator_api)] | ||
|
||
fn main() { | ||
Box::new_in((), &std::alloc::Global); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a comment here stating that we only handle wide pointer boxes as pointers, not thin pointer boxes with a scalar allocator. That case is handled in the general logic below