Skip to content

Commit

Permalink
Do not display UnpinStruct in the document by default
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Sep 4, 2019
1 parent 7da8926 commit 5acb8db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 41 deletions.
3 changes: 0 additions & 3 deletions pin-project-internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ lazy_static = { version = "1.3", optional = true }

[dev-dependencies]
pin-project = { version = "0.4.0-alpha.8", path = ".." }

[build-dependencies]
rustc_version = "0.2.3"
45 changes: 14 additions & 31 deletions pin-project-internal/build.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
// Based on https://stackoverflow.com/a/49250753/1290530

use std::env;

use rustc_version::{version_meta, Channel};

fn main() {
// Set cfg flags depending on release channel
match version_meta().unwrap().channel {
// Enable our feature on nightly, or when using a
// locally build rustc.
//
// This is intended to avoid the issue that cannot know the actual
// trait implementation bounds of the `Unpin` implementation from the
// document of generated code.
// See [taiki-e/pin-project#53] and [rust-lang/rust#63281] for more details.
//
// [taiki-e/pin-project#53]: https://github.com/taiki-e/pin-project/pull/53#issuecomment-525906867
// [rust-lang/rust#63281]: https://github.com/rust-lang/rust/issues/63281
//
// You can opt-out of this in one of the followg ways:
// * Use `--cfg pin_project_stable_docs` in RUSTFLAGS.
// ```toml
// # in Cargo.toml
// [package.metadata.docs.rs]
// rustdoc-args = ["--cfg", "pin_project_stable_docs"]
// ```
// * Use `-Zallow-features` in RUSTFLAGS to disallow unstable features.
Channel::Nightly | Channel::Dev
if feature_allowed("proc_macro_def_site") && !cfg!(pin_project_stable_docs) =>
{
println!("cargo:rustc-cfg=proc_macro_def_site");
}
_ => {}
// While this crate supports stable Rust, it currently requires
// nightly Rust in order for rustdoc to correctly document auto-generated
// `Unpin` impls. This does not affect the runtime functionality of this crate,
// nor does it affect the safety of the api provided by this crate.
//
// This is disabled by default and can be enabled using
// `--cfg pin_project_show_unpin_struct` in RUSTFLAGS.
//
// Refs:
// * https://github.com/taiki-e/pin-project/pull/53#issuecomment-525906867
// * https://github.com/taiki-e/pin-project/pull/70
// * https://github.com/rust-lang/rust/issues/63281
if cfg!(pin_project_show_unpin_struct) && feature_allowed("proc_macro_def_site") {
println!("cargo:rustc-cfg=proc_macro_def_site");
}
}

Expand Down
1 change: 0 additions & 1 deletion pin-project-internal/src/pin_project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ impl Context {
{
proc_macro::Span::def_site().into()
}

#[cfg(not(proc_macro_def_site))]
{
Span::call_site()
Expand Down
6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
//! * [`pinned_drop`] - An attribute for annotating a function that implements `Drop`.
//! * [`project`] - An attribute to support pattern matching.
//!
//! NOTE: While this crate supports stable Rust, it currently requires
//! nightly Rust in order for rustdoc to correctly document auto-generated
//! `Unpin` impls. This does not affect the runtime functionality of this crate,
//! nor does it affect the safety of the api provided by this crate.
//!
//!
//! ## Examples
//!
//! [`pin_project`] attribute creates a projection struct covering all the fields.
Expand Down

0 comments on commit 5acb8db

Please sign in to comment.