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

do not promote comparing function pointers #54702

Merged
merged 2 commits into from
Oct 3, 2018

Conversation

RalfJung
Copy link
Member

This could break existing code that relied on fn ptr comparison getting promoted to 'static lifetime.

Fixes #54696

@rust-highfive
Copy link
Collaborator

r? @davidtwco

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 30, 2018
&(main as fn() == main as fn());
// Also check nested case
&(&(main as fn()) == &(main as fn()));
}
Copy link
Member

Choose a reason for hiding this comment

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

How does this test verify lack of promotion? Shouldn't we instead have a compile-fail test?

Copy link
Contributor

Choose a reason for hiding this comment

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

The promotion causes crashes, because function pointer equality can't be done in constants

Copy link
Member Author

@RalfJung RalfJung Sep 30, 2018

Choose a reason for hiding this comment

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

I can also add a compile-fail test if you want -- though there is no fundamental reason we shouldn't want to promote this in the future, so that test wouldn't be "normative". OTOH, making this code run (and not emit a trap) is "normative".

@arielb1
Copy link
Contributor

arielb1 commented Sep 30, 2018

This could break existing code that relied on fn ptr comparison getting promoted to 'static lifetime.

That code is broken anyway

@davidtwco
Copy link
Member

r? @arielb1

@rust-highfive rust-highfive assigned arielb1 and unassigned davidtwco Sep 30, 2018
@RalfJung
Copy link
Member Author

That code is broken anyway

Fair enough.

@arielb1
Copy link
Contributor

arielb1 commented Sep 30, 2018

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned arielb1 Sep 30, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Oct 1, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Oct 1, 2018

📌 Commit 4cbfc93 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 1, 2018
@oli-obk oli-obk assigned oli-obk and unassigned eddyb Oct 1, 2018
@dtolnay
Copy link
Member

dtolnay commented Oct 1, 2018

@RalfJung does this also fix #54685 or is that a different issue? That one is also comparing function pointers but the discussion is focused on the LLVM side.

@RalfJung
Copy link
Member Author

RalfJung commented Oct 1, 2018

@dtolnay That's a different issue, but thanks for pointing me to it.

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 2, 2018
do not promote comparing function pointers

This *could* break existing code that relied on fn ptr comparison getting promoted to `'static` lifetime.

Fixes rust-lang#54696
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 2, 2018
do not promote comparing function pointers

This *could* break existing code that relied on fn ptr comparison getting promoted to `'static` lifetime.

Fixes rust-lang#54696
bors added a commit that referenced this pull request Oct 2, 2018
Rollup of 10 pull requests

Successful merges:

 - #54269 (#53840: Consolidate pattern check errors)
 - #54458 (Allow both explicit and elided lifetimes in the same impl header)
 - #54603 (Add `crate::` to trait suggestions in Rust 2018.)
 - #54648 (Update Cargo's submodule)
 - #54680 (make run-pass tests with empty main just compile-pass tests)
 - #54687 (Use impl_header_lifetime_elision in libcore)
 - #54699 (Re-export `getopts` so custom drivers can reference it.)
 - #54702 (do not promote comparing function pointers)
 - #54728 (Renumber `proc_macro` tracking issues)
 - #54745 (make `CStr::from_bytes_with_nul_unchecked()` a const fn)

Failed merges:

r? @ghost
@bors bors merged commit 4cbfc93 into rust-lang:master Oct 3, 2018
@RalfJung RalfJung deleted the fn-ptr-promotion branch November 9, 2018 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants