Skip to content

Initial implementation of FnPtr trait#156176

Open
carbotaniuman wants to merge 1 commit intorust-lang:mainfrom
carbotaniuman:fn-ptr-trait-impl
Open

Initial implementation of FnPtr trait#156176
carbotaniuman wants to merge 1 commit intorust-lang:mainfrom
carbotaniuman:fn-ptr-trait-impl

Conversation

@carbotaniuman
Copy link
Copy Markdown
Contributor

@carbotaniuman carbotaniuman commented May 5, 2026

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.

Part of fn_static: #148768

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.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

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

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels May 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

r? @nia-e

rustbot has assigned @nia-e.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, jhpratt, nia-e, scottmcm

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking bstr v1.12.1
error[E0433]: cannot find type `LangItem` in this scope
  --> src/tools/clippy/clippy_lints/src/methods/zst_offset.rs:14:54
   |
14 |         ty::Adt(_, args) if recv_ty.is_lang_item(cx, LangItem::NonNull) => args.type_at(0),
   |                                                      ^^^^^^^^ use of undeclared type `LangItem`
   |
help: consider importing one of these enums
   |
 1 + use crate::methods::hir::LangItem;
   |
 1 + use rustc_hir::LangItem;
   |

error[E0433]: cannot find type `LangItem` in this scope
   --> src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs:230:75
    |
230 |                 ty::Adt(adt_def, _) if cx.tcx.is_lang_item(adt_def.did(), LangItem::NonNull) => {
    |                                                                           ^^^^^^^^ use of undeclared type `LangItem`
    |
help: consider importing this enum
    |
  1 + use rustc_hir::LangItem;
    |

[RUSTC-TIMING] askama_parser test:false 4.110
    Checking termize v0.2.1
error[E0433]: cannot find type `LangItem` in this scope
   --> src/tools/clippy/clippy_lints/src/volatile_composites.rs:158:66
    |
158 |                     ty::Adt(_, args) if self_ty.is_lang_item(cx, LangItem::NonNull) => {
    |                                                                  ^^^^^^^^ use of undeclared type `LangItem`
    |
help: consider importing this enum
    |
  1 + use rustc_hir::LangItem;
    |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants