Skip to content

Commit 5acb8db

Browse files
committed
Do not display UnpinStruct in the document by default
1 parent 7da8926 commit 5acb8db

File tree

4 files changed

+14
-41
lines changed

4 files changed

+14
-41
lines changed

pin-project-internal/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,3 @@ lazy_static = { version = "1.3", optional = true }
3535

3636
[dev-dependencies]
3737
pin-project = { version = "0.4.0-alpha.8", path = ".." }
38-
39-
[build-dependencies]
40-
rustc_version = "0.2.3"

pin-project-internal/build.rs

+14-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,20 @@
1-
// Based on https://stackoverflow.com/a/49250753/1290530
2-
31
use std::env;
42

5-
use rustc_version::{version_meta, Channel};
6-
73
fn main() {
8-
// Set cfg flags depending on release channel
9-
match version_meta().unwrap().channel {
10-
// Enable our feature on nightly, or when using a
11-
// locally build rustc.
12-
//
13-
// This is intended to avoid the issue that cannot know the actual
14-
// trait implementation bounds of the `Unpin` implementation from the
15-
// document of generated code.
16-
// See [taiki-e/pin-project#53] and [rust-lang/rust#63281] for more details.
17-
//
18-
// [taiki-e/pin-project#53]: https://github.com/taiki-e/pin-project/pull/53#issuecomment-525906867
19-
// [rust-lang/rust#63281]: https://github.com/rust-lang/rust/issues/63281
20-
//
21-
// You can opt-out of this in one of the followg ways:
22-
// * Use `--cfg pin_project_stable_docs` in RUSTFLAGS.
23-
// ```toml
24-
// # in Cargo.toml
25-
// [package.metadata.docs.rs]
26-
// rustdoc-args = ["--cfg", "pin_project_stable_docs"]
27-
// ```
28-
// * Use `-Zallow-features` in RUSTFLAGS to disallow unstable features.
29-
Channel::Nightly | Channel::Dev
30-
if feature_allowed("proc_macro_def_site") && !cfg!(pin_project_stable_docs) =>
31-
{
32-
println!("cargo:rustc-cfg=proc_macro_def_site");
33-
}
34-
_ => {}
4+
// While this crate supports stable Rust, it currently requires
5+
// nightly Rust in order for rustdoc to correctly document auto-generated
6+
// `Unpin` impls. This does not affect the runtime functionality of this crate,
7+
// nor does it affect the safety of the api provided by this crate.
8+
//
9+
// This is disabled by default and can be enabled using
10+
// `--cfg pin_project_show_unpin_struct` in RUSTFLAGS.
11+
//
12+
// Refs:
13+
// * https://github.com/taiki-e/pin-project/pull/53#issuecomment-525906867
14+
// * https://github.com/taiki-e/pin-project/pull/70
15+
// * https://github.com/rust-lang/rust/issues/63281
16+
if cfg!(pin_project_show_unpin_struct) && feature_allowed("proc_macro_def_site") {
17+
println!("cargo:rustc-cfg=proc_macro_def_site");
3518
}
3619
}
3720

pin-project-internal/src/pin_project/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ impl Context {
192192
{
193193
proc_macro::Span::def_site().into()
194194
}
195-
196195
#[cfg(not(proc_macro_def_site))]
197196
{
198197
Span::call_site()

src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
//! * [`pinned_drop`] - An attribute for annotating a function that implements `Drop`.
77
//! * [`project`] - An attribute to support pattern matching.
88
//!
9-
//! NOTE: While this crate supports stable Rust, it currently requires
10-
//! nightly Rust in order for rustdoc to correctly document auto-generated
11-
//! `Unpin` impls. This does not affect the runtime functionality of this crate,
12-
//! nor does it affect the safety of the api provided by this crate.
13-
//!
14-
//!
159
//! ## Examples
1610
//!
1711
//! [`pin_project`] attribute creates a projection struct covering all the fields.

0 commit comments

Comments
 (0)