Initial implementation of FnPtr trait#156176
Conversation
|
The Clippy subtree was changed cc @rust-lang/clippy rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @nia-e rustbot has assigned @nia-e. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
Thanks for the PR! I'll take a proper look asap, but in the meantime could you add some tests for the feature & take a look at the build errors? |
e890b0c to
e4faa20
Compare
This comment has been minimized.
This comment has been minimized.
e4faa20 to
293714d
Compare
This comment has been minimized.
This comment has been minimized.
293714d to
2a66666
Compare
This comment has been minimized.
This comment has been minimized.
2a66666 to
a7cf7b3
Compare
This comment has been minimized.
This comment has been minimized.
a7cf7b3 to
a7b62c5
Compare
This comment has been minimized.
This comment has been minimized.
a7b62c5 to
13d375e
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| } | ||
|
|
||
| /// A type representing a pointer to a function pointer. | ||
| // FIXME: Make this a proper extern type. |
There was a problem hiding this comment.
What's holding us back from making this an extern type now?
There was a problem hiding this comment.
If I try I get:
error: foreign type has missing stability attribute
--> library/core/src/ops/function.rs:318:5
|
318 | pub type Code;
| ^^^^^^^^^^^^^
And if I try to put a stability marker on it I get this:
extern "C" {
error: `#[unstable]` attribute cannot be used on foreign types
--> library/core/src/ops/function.rs:318:5
|
318 | #[unstable(feature = "fn_static", issue = "148768")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: `#[unstable]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, extern crates, foreign statics, functions, impl blocks, macro defs, modules, statics, struct fields, trait aliases, traits, type aliases, type parameters, and use statements
There was a problem hiding this comment.
we should change our attribute handling to support stabiity attributes on foreign types. please either implement this or open a github issue for this
|
Reminder, once the PR becomes ready for a review, use |
This commit is an initial implementation of the `FnPtr` trait as described in the `fn_static` tracking issue, which consists of moving the internally unstable `core::marker::FnPtr` to `core::ops::FnPtr`, as well as changing the API. Because `NonNull` is used in the new `as_ptr` signature, it was also turned into a proper lang item.
13d375e to
5aa8f05
Compare
|
@rustbot ready |
|
☔ The latest upstream changes (presumably #157600) made this pull request unmergeable. Please resolve the merge conflicts. |
This commit is an initial implementation of the
FnPtrtrait as described in thefn_statictracking issue, which consists of moving the internally unstablecore::marker::FnPtrtocore::ops::FnPtr, as well as changing the API. BecauseNonNullis used in the newas_ptrsignature, it was also turned into a proper lang item.Part of
fn_static: #148768