Conversation
|
The largest area where Box is still special is various layout calculations and translation, I haven't touched anything of it. I believe all of it can be done uniformly with normal structs. |
src/librustc_typeck/check/mod.rs
Outdated
There was a problem hiding this comment.
I'd have substs.type_at(0) everywhere instead of a boxed_ty method.
There was a problem hiding this comment.
But of course, this may be too annoying to repeat at every single use site.
There was a problem hiding this comment.
It's used often. A dedicated method seems to be more convenient and readable.
There was a problem hiding this comment.
Fair enough. My next choice would be box_pointee but boxed_ty seems fine anyway.
src/librustc_trans/glue.rs
Outdated
There was a problem hiding this comment.
The assert started failing when Box got a Drop impl.
There was a problem hiding this comment.
Oh, then skip_dtor should toggle calling free (which can also be the Drop impl?).
There was a problem hiding this comment.
Do you mean something like
--- a/src/librustc_trans/glue.rs
+++ b/src/librustc_trans/glue.rs
@@ -210,7 +210,7 @@ pub fn implement_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKi
};
let bcx = match t.sty {
- ty::TyAdt(def, _) if def.is_box() => {
+ ty::TyAdt(def, _) if def.is_box() && !skip_dtor => {
// Support for Box is built-in as yet and its drop glue is special
// despite having a dummy Drop impl in the library.
let content_ty = t.boxed_ty();
?
I.e. if we get here with skip_dtor == false, we generate full drop glue (including both dropping the inner type and deallocation), otherwise we generate "structural drop" only, which is noop for Box.
There was a problem hiding this comment.
Btw, what happens if full drop glue in generated in both cases? I haven't observed any regressions in tests.
There was a problem hiding this comment.
It might be not used at all. @michaelwoerister and @arielb1 would know.
What I meant is making the trans_exchange_free_ty call conditional on !skip_dtor.
There was a problem hiding this comment.
I've restored the previous behavior in another place (find_drop_glue_neighbors) and put this assert back.
src/librustc/ty/sty.rs
Outdated
There was a problem hiding this comment.
This should be substs.type_at(0).
src/librustc/ty/mod.rs
Outdated
There was a problem hiding this comment.
This seems maybe a bit sketchy but it's a bit of cache so I can live with it.
|
I would like to eventually move the piece-by-piece movable stuff into an internal-only DerefMove. Might need to make it an unsafe trait since we may have to make assumptions about the destructor. |
|
Unsizing coercions and layout go hand in hand. The problem with layout is unpacking newtypes and that's a pretty big can of worms given how LLVM "types" work, several strategical refactors are still needed there. |
|
Rebased, comments addressed. |
|
@bors r+ |
|
📌 Commit 8d36b1c has been approved by |
|
⌛ Testing commit 8d36b1c with merge 4065356... |
|
💔 Test failed - status-appveyor |
|
☔ The latest upstream changes (presumably #39305) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I can't reproduce the Appveyor failure locally. Let's try again. |
|
📌 Commit f6be8fa has been approved by |
|
⌛ Testing commit f6be8fa with merge c3dec74... |
|
💔 Test failed - status-appveyor |
|
I still can't reproduce this assert with all debug and assert options enabled. @alexcrichton |
|
The assert is about MSVC debuginfo: @michaelwoerister Maybe you have ideas what part of this PR could do this? |
|
@petrochenkov it should be whatever the llvm submodule is, but maybe a stale version is cached? You could try touching the llvm trigger and re-send to bors to see if a fresh compile works? |
|
@bors r=eddyb |
|
📌 Commit 468a79d has been approved by |
|
⌛ Testing commit 468a79d with merge a576531... |
|
💔 Test failed - status-appveyor |
|
Phew, reproduced locally. |
I don't see any obvious place. Maybe you could instrument your LLVM to print out which |
|
|
Found it. diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs
index f05d48566d..e9468e5663 100644
--- a/src/librustc_trans/debuginfo/mod.rs
+++ b/src/librustc_trans/debuginfo/mod.rs
@@ -400,7 +400,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Only "class" methods are generally understood by LLVM,
// so avoid methods on other types (e.g. `<*mut T>::null`).
match impl_self_ty.sty {
- ty::TyAdt(..) => {
+ ty::TyAdt(def, ..) if !def.is_box() => {
Some(type_metadata(cx, impl_self_ty, syntax_pos::DUMMY_SP))
}
_ => None
|
|
@bors r=eddyb |
|
📌 Commit 93e3f63 has been approved by |
Refactoring TyBox -> TyAdt r? @eddyb cc @Manishearth
|
☀️ Test successful - status-appveyor, status-travis |
r? @eddyb
cc @Manishearth