Skip to content

Commit b97039e

Browse files
committed
added docs and example function
1 parent c5775a7 commit b97039e

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

library/core/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,11 @@
271271
#[allow(unused_extern_crates)]
272272
extern crate self as core;
273273

274+
#[allow(unused_imports)]
275+
use crate::marker::FnPtr;
274276
#[prelude_import]
275277
#[allow(unused)]
276278
use prelude::v1::*;
277-
278279
#[cfg(not(test))] // See #65860
279280
#[macro_use]
280281
mod macros;
@@ -440,5 +441,4 @@ pub mod simd {
440441
#[unstable(feature = "portable_simd", issue = "86656")]
441442
pub use crate::core_simd::simd::*;
442443
}
443-
444444
include!("primitive_docs.rs");

library/core/src/primitive_docs.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ mod prim_ref {}
15521552
/// * [`Clone`]
15531553
/// * [`Copy`]
15541554
/// * [`Send`]
1555+
/// * [`Sized`]
15551556
/// * [`Sync`]
15561557
/// * [`Unpin`]
15571558
/// * [`UnwindSafe`]
@@ -1591,3 +1592,18 @@ impl<Ret, T> Clone for fn(T) -> Ret {
15911592
impl<Ret, T> Copy for fn(T) -> Ret {
15921593
// empty
15931594
}
1595+
1596+
// Fake impl that's only really used for docs.
1597+
#[cfg(doc)]
1598+
#[unstable(
1599+
feature = "fn_ptr_trait",
1600+
issue = "none",
1601+
reason = "internal trait for implementing various traits for all function pointers"
1602+
)]
1603+
#[doc(fake_variadic)]
1604+
/// This trait is implemented on function pointers with any number of arguments.
1605+
impl<Ret, T> FnPtr for fn(T) -> Ret {
1606+
fn addr(self) -> *const () {
1607+
// empty
1608+
}
1609+
}

library/std/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@
347347
#![feature(core_panic)]
348348
#![feature(custom_test_frameworks)]
349349
#![feature(edition_panic)]
350+
#![feature(fn_ptr_trait)]
350351
#![feature(format_args_nl)]
351352
#![feature(get_many_mut)]
352353
#![feature(lazy_cell)]
@@ -376,10 +377,11 @@
376377

377378
// Explicitly import the prelude. The compiler uses this same unstable attribute
378379
// to import the prelude implicitly when building crates that depend on std.
380+
#[allow(unused_imports)]
381+
use crate::marker::FnPtr;
379382
#[prelude_import]
380383
#[allow(unused)]
381384
use prelude::rust_2021::*;
382-
383385
// Access to Bencher, etc.
384386
#[cfg(test)]
385387
extern crate test;

library/std/src/primitive_docs.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ mod prim_ref {}
15521552
/// * [`Clone`]
15531553
/// * [`Copy`]
15541554
/// * [`Send`]
1555+
/// * [`Sized`]
15551556
/// * [`Sync`]
15561557
/// * [`Unpin`]
15571558
/// * [`UnwindSafe`]
@@ -1591,3 +1592,18 @@ impl<Ret, T> Clone for fn(T) -> Ret {
15911592
impl<Ret, T> Copy for fn(T) -> Ret {
15921593
// empty
15931594
}
1595+
1596+
// Fake impl that's only really used for docs.
1597+
#[cfg(doc)]
1598+
#[unstable(
1599+
feature = "fn_ptr_trait",
1600+
issue = "none",
1601+
reason = "internal trait for implementing various traits for all function pointers"
1602+
)]
1603+
#[doc(fake_variadic)]
1604+
/// This trait is implemented on function pointers with any number of arguments.
1605+
impl<Ret, T> FnPtr for fn(T) -> Ret {
1606+
fn addr(self) -> *const () {
1607+
// empty
1608+
}
1609+
}

0 commit comments

Comments
 (0)