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

Make transmuting from fn item types to pointer-sized types a hard error. #34198

Merged

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Jun 10, 2016

Closes #19925 by removing the future compatibility lint and the associated workarounds.
This is a [breaking-change] if you transmute from a function item without casting first.
For more information on how to fix your code, see #19925.

@rust-highfive
Copy link
Collaborator

r? @nrc

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

@eddyb
Copy link
Member Author

eddyb commented Jun 10, 2016

r? @nikomatsakis

I'll start a crater run to see if there's any measurable impact.

@rust-highfive rust-highfive assigned nikomatsakis and unassigned nrc Jun 10, 2016
@eddyb eddyb force-pushed the you're-a-bad-transmute-and-you-should-feel-bad branch 2 times, most recently from 41ffc25 to ddf2469 Compare June 10, 2016 10:00
@eddyb
Copy link
Member Author

eddyb commented Jun 10, 2016

Crater report: https://gist.github.com/eddyb/c9a976482be44529e3cdd79ca97db0ce.

This looks pretty bad, much worse than what I remember. It seems a bunch of crates haven't fixed their code, although the warning only now got into beta, so nobody staying on stable has ever seen it.

@eddyb
Copy link
Member Author

eddyb commented Jun 10, 2016

Looks like nix was fixed in https://github.com/nix-rust/nix, but crates.io still has a 3-month old version.
cc @carllerche

@nikomatsakis
Copy link
Contributor

I've been meaning to alter the future compatibility warnings so that they
always (at least) warn, even if the user (or cap lints) sets them to allow.
That might also help.
On Jun 10, 2016 11:04 AM, "Eduard-Mihai Burtescu" notifications@github.com
wrote:

Looks like nix was fixed in https://github.com/nix-rust/nix, but crates.io
still has a 3-month old version.
cc @carllerche https://github.com/carllerche


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#34198 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAJeZsyi-DJ3AF-sLviSdqoLNAO-aHiFks5qKX0PgaJpZM4Iyy6A
.

@bluss
Copy link
Member

bluss commented Jun 10, 2016

@nikomatsakis That's great, because it alerts users that depend on outdated (unfixed) versions.

@kamalmarhubi
Copy link
Contributor

I just got the ability to publish and published nix v0.6.0 which builds on nightly.

@eddyb
Copy link
Member Author

eddyb commented Jun 10, 2016

Crater report 2: https://gist.github.com/eddyb/defd09acfd0c1d6036334d147d7fc040.

@kamalmarhubi As I feared, releasing 0.6.0 wasn't enough (e.g. notify still uses 0.5.0).
Could you release 0.5.1 with 0.5.0's code + the transmute fix?

EDIT: Even worse, 0.4.2 is also still in use (e.g. signal), so that would need a new release (0.4.3) too.
Also 0.3.9 (only in utp). You can see all of the versions used by other crates.io crates at https://crates.io/crates/nix/reverse_dependencies.
AFAICT, you wouldn't need more than 0.5.1, 0.4.3 and 0.3.10 to cover everyone.

@eddyb
Copy link
Member Author

eddyb commented Jun 10, 2016

@SSheldon objc-0.1.8 is still broken, all but the last 2 transmute calls (the ones in the macro) in src/message.rs need casts on their arguments.
You would have to release 0.1.9 to solve this, as some crates are still using 0.1.8.

@kamalmarhubi
Copy link
Contributor

@eddyb I just published a v0.5.1, which builds on nightly. Publishing things in earlier release series is harder as we don't have git tags for those releases. I can try to narrow it down, but it will probably not be today.

@eddyb
Copy link
Member Author

eddyb commented Jun 11, 2016

@kamalmarhubi Thanks for the help with this!
For releases without tags, it might be easier to get the package from crates.io (I don't know how to do that without adding it as a dependency of something and then looking in ~/.cargo/registry/src/), modify it and republish that.
It might be possible to of course bisect git to find out what commit matches in the source (modulo metadata/files that were not included in crates.io?).

@eddyb
Copy link
Member Author

eddyb commented Jun 11, 2016

@GuillaumeGomez @gkoz Reminder that glib-0.0.8 is still broken, gtk-rs/glib#116 needs to be released in 0.0.9 (not 0.1.*) (EDIT: see below, releasing 0.0.9 won't do any good anyway 😞).

@bluss
Copy link
Member

bluss commented Jun 11, 2016

0.0.x versions don't upgrade automatically to anything, so nothing can be done.

@eddyb
Copy link
Member Author

eddyb commented Jun 11, 2016

@bluss I just checked and indeed that's the case - why do we even allow depending on such an "unfixable" version?!

@eddyb
Copy link
Member Author

eddyb commented Jun 11, 2016

@nikomatsakis I've went through all of the 50 root regressions and here's what I found:

Partially fixed and/or yet unpublished fixes

Yet unfixed

@GuillaumeGomez
Copy link
Member

@eddyb: Fine fine!

@tomaka tomaka mentioned this pull request Jun 11, 2016
@Ameliorate
Copy link

Ameliorate commented Jun 11, 2016

@eddyb I've yanked hlua_master, so you can check that one off. It wasn't really meant to be used by anyone. I just made it because at the time hlua's github master branch didn't match what was on crates.io.

@SSheldon
Copy link
Contributor

@eddyb, if the crates relying on objc 0.1 were upgraded to use 0.2, would that be satisfactory? Or must there be a fix for 0.1? The fix for 0.1 would be a lot of copy-pasting and I'm not super keen on it 😅

Looking at the crates that require 0.1:

  • clipboard: I could go send a PR to update this
  • metl: it actually has already updated to 0.2 but not published a new version (any plans to publish a new version @burtonageo?)
  • glutin_cocoa: this is a defunct fork of cocoa
  • uikit: this is mine, I'll go update it

If it's amenable to you I might just take this as an opportunity to get clipboard and uikit updated.

@eddyb
Copy link
Member Author

eddyb commented Jun 11, 2016

@SSheldon That sounds great, thank you! Having seen the code, I agree that not fixing the transmute-laden version is better.

@eddyb
Copy link
Member Author

eddyb commented Jun 11, 2016

@tomaka Is glutin_cocoa completely unused anymore?
@alexcrichton Is yanking all the versions of such a package an acceptable policy?

@alexcrichton
Copy link
Member

Yeah it'll work in terms of preventing new dependencies on it, but it's the same standard "lockfiles continue to work" semantics which means it's not 100% fixed if someone's using it.

If no one's using it though then shouldn't matter too much either way.

@eddyb
Copy link
Member Author

eddyb commented Jun 11, 2016

@alexcrichton It has... downloads. I wonder if that's all from crater though, heh.

@nikomatsakis
Copy link
Contributor

@eddyb see also #19925 (comment), which I think is a nifty idea, though orthogonal-ish from this PR

@eddyb eddyb force-pushed the you're-a-bad-transmute-and-you-should-feel-bad branch from fb4663b to e1c3a6f Compare February 28, 2017 11:30
@eddyb
Copy link
Member Author

eddyb commented Feb 28, 2017

Latest crater run shows the same regressions as before - see #34198 (comment).

@eddyb eddyb added the relnotes Marks issues that should be documented in the release notes of the next release. label Feb 28, 2017
@eddyb
Copy link
Member Author

eddyb commented Feb 28, 2017

@nikomatsakis Oh I almost forgot about the Option thing, I guess I'll do that now.

EDIT: done!

@eddyb eddyb force-pushed the you're-a-bad-transmute-and-you-should-feel-bad branch from e1c3a6f to 6b99df6 Compare February 28, 2017 16:20
of `foo` tells us precisely what function is being called.

As noted above, coercions mean that most code continues to work just fine
before and after this behavior was implemented. However, you can tell the
Copy link
Contributor

Choose a reason for hiding this comment

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

probably we don't want to say "this behavior was implemented" here...I would just say "Coercions mean that most code doesn't have to be concerned with this distinction."

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah that's a better phrasing. I did try to remove temporal indicators, this one was trickiest.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

r=me modulo the extended error description change I suggested.

I still think we may want to consider making extern "C" fn types be pointer-sized, but that's a separate change that ought to go through the RFC process IMO.

@eddyb eddyb force-pushed the you're-a-bad-transmute-and-you-should-feel-bad branch from 6b99df6 to 7650afc Compare February 28, 2017 21:48
@eddyb
Copy link
Member Author

eddyb commented Feb 28, 2017

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Feb 28, 2017

📌 Commit 7650afc has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Feb 28, 2017

⌛ Testing commit 7650afc with merge a6e96ad...

@bors
Copy link
Contributor

bors commented Feb 28, 2017

💔 Test failed - status-appveyor

@eddyb
Copy link
Member Author

eddyb commented Feb 28, 2017

@bors retry

  • chocolatey network error

@bors
Copy link
Contributor

bors commented Feb 28, 2017

⌛ Testing commit 7650afc with merge d5d59ca...

@bors
Copy link
Contributor

bors commented Feb 28, 2017

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member

alexcrichton commented Feb 28, 2017 via email

@bors
Copy link
Contributor

bors commented Mar 1, 2017

⌛ Testing commit 7650afc with merge 5bddaa4...

@bors
Copy link
Contributor

bors commented Mar 1, 2017

💔 Test failed - status-travis

@eddyb
Copy link
Member Author

eddyb commented Mar 1, 2017

@bors retry

  • I can't see the log... because S3?

@bors
Copy link
Contributor

bors commented Mar 1, 2017

⌛ Testing commit 7650afc with merge 691eba1...

bors added a commit that referenced this pull request Mar 1, 2017
…el-bad, r=nikomatsakis

Make transmuting from fn item types to pointer-sized types a hard error.

Closes #19925 by removing the future compatibility lint and the associated workarounds.
This is a `[breaking-change]` if you `transmute` from a function item without casting first.
For more information on how to fix your code, see #19925.
@bors
Copy link
Contributor

bors commented Mar 1, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 691eba1 to master...

@bors bors merged commit 7650afc into rust-lang:master Mar 1, 2017
@eddyb eddyb deleted the you're-a-bad-transmute-and-you-should-feel-bad branch March 1, 2017 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set transmute from fn item to type fn lint a hard error