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

fn-ptr docs were not updated for the change to trait impls #111182

Open
lcnr opened this issue May 4, 2023 · 4 comments
Open

fn-ptr docs were not updated for the change to trait impls #111182

lcnr opened this issue May 4, 2023 · 4 comments
Assignees
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented May 4, 2023

Location

https://doc.rust-lang.org/nightly/std/primitive.fn.html#trait-implementations-1

Summary

we now implement all of these traits for all function pointers. We should change the documentation to mention that.

we may also want to add a dummy impl for rustdoc for https://doc.rust-lang.org/nightly/std/marker/trait.FnPtr.html, similar to

// Fake impl that's only really used for docs.
#[cfg(doc)]
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(fake_variadic)]
/// This trait is implemented on function pointers with any number of arguments.
impl<Ret, T> Clone for fn(T) -> Ret {
fn clone(&self) -> Self {
loop {}
}
}

@lcnr lcnr added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. and removed A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels May 4, 2023
@mj10021
Copy link
Contributor

mj10021 commented May 5, 2023

@rustbot claim

@lcnr
Copy link
Contributor Author

lcnr commented May 5, 2023

the PR which added the trait was #108080

@mj10021
Copy link
Contributor

mj10021 commented May 11, 2023

Hi @lcnr ! Sorry it took me a bit to get to this after I claimed it. Just want to make sure I'm understanding correctly what the documentation should look like:

All function pointers implement FnPtr, which means they all implement:

ConstParamTy
Destruct
DiscriminantKind
FnPtr
PointerLike
StructuralEq
StructuralPartialEq
Tuple
Unsize
Copy
Send
Sized
Sync
Unpin

(pulled from the FnPtr docs), and so those traits should be included in the function pointer doc? And then would the dummy impl look something like this:

// Fake impl that's only really used for docs.
#[cfg(doc)]
#[unstable(feature = "fn_ptr_trait")]
#[doc(fake_variadic)]
/// This trait is implemented on function pointers with any number of arguments. 
impl<Ret, T> FnPtr for fn(T) -> Ret {
    fn addr(&self) -> *const () {
        // empty
    }
}

@lcnr
Copy link
Contributor Author

lcnr commented May 16, 2023

pretty much yeah.

not sure whether it makes sense to differentiate between traits implemented via FnPtr and traits implemented via builtin impls.

I personally don't think we should mention traits which are currently still unstable, that's something we can discuss further after you opened the PR

@jieyouxu jieyouxu added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants