Skip to content
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

Move fn safety out of the subtyping relationship and into coercions #23452

Merged
merged 2 commits into from
Mar 18, 2015

Conversation

nikomatsakis
Copy link
Contributor

Safe fns are no longer subtypes of unsafe fns, but you can coerce from one to the other.

This is a [breaking-change] in that impl fns must now be declared unsafe if the trait is declared unsafe. In some rare cases, the subtyping change may also direct affect you, but no such cases were encountered in practice.

Fixes #23449.

r? @nrc

@nrc
Copy link
Member

nrc commented Mar 17, 2015

@bors: r+ 0947f40

bors added a commit that referenced this pull request Mar 18, 2015
Safe fns are no longer subtypes of unsafe fns, but you can coerce from one to the other.

This is a [breaking-change] in that impl fns must now be declared `unsafe` if the trait is declared `unsafe`. In some rare cases, the subtyping change may also direct affect you, but no such cases were encountered in practice.

Fixes #23449.

r? @nrc
@bors
Copy link
Contributor

bors commented Mar 18, 2015

⌛ Testing commit 0947f40 with merge c109189...

@@ -282,6 +282,7 @@ pub enum Variance {
#[derive(Clone, Debug)]
pub enum AutoAdjustment<'tcx> {
AdjustReifyFnPointer(ast::DefId), // go from a fn-item type to a fn-pointer type
AdjustUnsafeFnPointer, // go from a safe fn pointer to an unsafe fn pointer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa, you can match against this with ty::AdjustUnsafeFnPointer(..), that's an interesting... feature.

@bors bors merged commit 0947f40 into rust-lang:master Mar 18, 2015
lilyball added a commit to lilyball/rust-lua that referenced this pull request Mar 23, 2015
rust-lang/rust#23452 makes safe functions no longer a subtype of unsafe
functions. For consistency, change the definitions of `raw::lua_Reader`,
`raw::lua_Writer`, and `raw::lua_Alloc` to be `unsafe` and update all
places where we provide these functions. Also update the `lua_extern!`
and `lua_extern_pub!` macros to produce `unsafe` functions.
@nikomatsakis nikomatsakis deleted the unsafety-subtyping branch March 30, 2016 16:17
Sign up for free to 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.

remove subtyping relationship for safe/unsafe fns and replace with coercion
4 participants