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

Improve document of UnpinStruct #62

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions pin-project-internal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,27 @@ 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, unless `-Zallow-features`
// in RUSTFLAGS disallows unstable features.
Channel::Nightly | Channel::Dev if feature_allowed("proc_macro_def_site") => {
// 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");
}
_ => {}
Expand Down
17 changes: 13 additions & 4 deletions pin-project-internal/src/pin_project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,19 @@ impl Context {
// '__UnpinStruct' type must also be public. However, we take
// steps to ensure that the user can never actually reference
// this 'public' type. These steps are described below
/// A struct generated by pin-project to provide an appropriate
/// `Unpin` implementation, this type's `Unpin` implementation
/// uses exactly the same conditions as the original type's
/// `Unpin` implementation.
//
/// A struct generated by pin-project to correctly document the
/// automatically generated `Unpin` implementation.
///
/// This struct exists to correctly document the actual trait
/// implementation bounds of the `Unpin` implementation of the
/// original type. Note that users cannot access this struct,
/// even if it is public.
///
/// 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
#vis struct #struct_ident #full_generics #where_clause {
__pin_project_use_generics: #always_unpin_ident <(#(#type_params),*)>,

Expand Down