do not promote comparing function pointers#54702
Conversation
|
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
133ba56 to
1397836
Compare
| &(main as fn() == main as fn()); | ||
| // Also check nested case | ||
| &(&(main as fn()) == &(main as fn())); | ||
| } |
There was a problem hiding this comment.
How does this test verify lack of promotion? Shouldn't we instead have a compile-fail test?
There was a problem hiding this comment.
The promotion causes crashes, because function pointer equality can't be done in constants
There was a problem hiding this comment.
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".
That code is broken anyway |
|
r? @arielb1 |
Fair enough. |
f5b5ec0 to
4cbfc93
Compare
|
r? @eddyb |
|
@bors r+ |
|
📌 Commit 4cbfc93 has been approved by |
|
@dtolnay That's a different issue, but thanks for pointing me to it. |
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
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
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
This could break existing code that relied on fn ptr comparison getting promoted to
'staticlifetime.Fixes #54696