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

Projects
None yet
4 participants
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Mar 17, 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

@nikomatsakis nikomatsakis force-pushed the nikomatsakis:unsafety-subtyping branch from 90f9a77 to 0947f40 Mar 17, 2015

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Mar 17, 2015

bors added a commit that referenced this pull request Mar 18, 2015

Auto merge of #23452 - nikomatsakis:unsafety-subtyping, r=nrc
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

This comment has been minimized.

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

This comment has been minimized.

@eddyb

eddyb Mar 18, 2015

Member

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

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@lilyball lilyball referenced this pull request Mar 23, 2015

Closed

Make State::panic unsafe #24

lilyball added a commit to lilyball/rust-lua that referenced this pull request Mar 23, 2015

Make all extern "C" functions unsafe
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 nikomatsakis:unsafety-subtyping branch Mar 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.