Skip to content

change the box_free lang item to accept pointers to unsized types - #37708

Merged
bors merged 1 commit into
rust-lang:masterfrom
oli-obk:box_free
Nov 12, 2016
Merged

change the box_free lang item to accept pointers to unsized types#37708
bors merged 1 commit into
rust-lang:masterfrom
oli-obk:box_free

Conversation

@oli-obk

Copy link
Copy Markdown
Contributor

in miri we use the box_free lang item as the destructor for Box objects, since the function's api matches that of an fn drop(&mut self) in a hypothetical impl<T: ?Sized> Drop for Box<T> exactly.

This works fine except if we insert a check in the size_of intrinsic to ensure that it is only called with sized types, since the box_free lang item calls that intrinsic.

cc @eddyb

no clue who to r? here, probably lang team?

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@sfackler

Copy link
Copy Markdown
Member

r? @eddyb

@rust-highfiverust-highfive assigned eddyb and unassigned sfacklerNov 11, 2016
@eddyb

Copy link
Copy Markdown
Contributor

Do you think you could also change trans to take advantage of this? IIRC it does its own DST logic.
I prefer this form because it's closer to an eventual Drop impl for Box.
r=me with an issue open about changing trans otherwise.

@oli-obk

Copy link
Copy Markdown
ContributorAuthor

The only places rustc generates calls to box_free are in librustc_mir and librustc_borrowck, and these don't check for sizedness, but instead are at locations where the Box is guaranteed to point to a Sized type. There's some interaction with exchange_free that I don't grok. It would probably be better to leave this until Box gets a real Drop impl. I'll open an issue as advised.

@oli-obk

Copy link
Copy Markdown
ContributorAuthor

travis likes it + issue reported.

@eddyb

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Nov 11, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit de371e5 has been approved by eddyb

@bluss

Copy link
Copy Markdown
Contributor

Doesn't have the [breaking-change] text in the commit log, which we use to signal breaking changes in unstable APIs. (I'll continue nagging about this until we officially abandon the practice...)

@oli-obk

Copy link
Copy Markdown
ContributorAuthor

added [breaking-change] to commit message

@eddyb

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Nov 11, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 323c20c has been approved by eddyb

eddyb added a commit to eddyb/rust that referenced this pull request Nov 11, 2016
change the `box_free` lang item to accept pointers to unsized types
in miri we use the `box_free` lang item as the destructor for `Box` objects, since the function's api matches that of an `fn drop(&mut self)` in a hypothetical `impl<T: ?Sized> Drop for Box<T>` exactly.
This works fine except if we insert a check in the `size_of` intrinsic to ensure that it is only called with sized types, since the `box_free` lang item calls that intrinsic.
cc @eddyb
no clue who to r? here, probably lang team?
@eddybeddyb mentioned this pull request Nov 11, 2016
eddyb added a commit to eddyb/rust that referenced this pull request Nov 12, 2016
change the `box_free` lang item to accept pointers to unsized types
in miri we use the `box_free` lang item as the destructor for `Box` objects, since the function's api matches that of an `fn drop(&mut self)` in a hypothetical `impl<T: ?Sized> Drop for Box<T>` exactly.
This works fine except if we insert a check in the `size_of` intrinsic to ensure that it is only called with sized types, since the `box_free` lang item calls that intrinsic.
cc @eddyb
no clue who to r? here, probably lang team?
@eddybeddyb mentioned this pull request Nov 12, 2016
bors added a commit that referenced this pull request Nov 12, 2016
@bors
bors merged commit 323c20c into rust-lang:masterNov 12, 2016
@oli-obk
oli-obk deleted the box_free branch June 15, 2020 15:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@oli-obk@rust-highfive@sfackler@eddyb@bors@bluss