Skip to content

Commit cc8a3e8

Browse files
bors[bot]taiki-e
andauthoredSep 3, 2019
Merge #62
62: Improve document of UnpinStruct r=Aaron1011 a=taiki-e Improve document and add a way to opt-out mentioned in #53 (comment). The reason for needing support for ways other than `-Zallow-features` is that it also affects the use of other dependency unstable features. Related: #54 #56 (comment) Generated document: <img width="1001" alt="struct-1" src="https://user-images.githubusercontent.com/43724913/64136451-95494280-ce2c-11e9-81ce-6a02c315332f.png"> <img width="1015" alt="struct-2" src="https://user-images.githubusercontent.com/43724913/64136462-a6924f00-ce2c-11e9-9d1c-3cdca2d9b158.png"> Ways to opt-out of this: https://github.com/taiki-e/pin-project/blob/5f7c6e35c2a9f3dfbc01a63e6206875d1bfb986b/pin-project-internal/build.rs#L21-L28 Co-authored-by: Taiki Endo <te316e89@gmail.com>
2 parents fa58920 + 5f7c6e3 commit cc8a3e8

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed
 

‎pin-project-internal/build.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,27 @@ fn main() {
88
// Set cfg flags depending on release channel
99
match version_meta().unwrap().channel {
1010
// Enable our feature on nightly, or when using a
11-
// locally build rustc, unless `-Zallow-features`
12-
// in RUSTFLAGS disallows unstable features.
13-
Channel::Nightly | Channel::Dev if feature_allowed("proc_macro_def_site") => {
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+
{
1432
println!("cargo:rustc-cfg=proc_macro_def_site");
1533
}
1634
_ => {}

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

+13-4
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,19 @@ impl Context {
233233
// '__UnpinStruct' type must also be public. However, we take
234234
// steps to ensure that the user can never actually reference
235235
// this 'public' type. These steps are described below
236-
/// A struct generated by pin-project to provide an appropriate
237-
/// `Unpin` implementation, this type's `Unpin` implementation
238-
/// uses exactly the same conditions as the original type's
239-
/// `Unpin` implementation.
236+
//
237+
/// A struct generated by pin-project to correctly document the
238+
/// automatically generated `Unpin` implementation.
239+
///
240+
/// This struct exists to correctly document the actual trait
241+
/// implementation bounds of the `Unpin` implementation of the
242+
/// original type. Note that users cannot access this struct,
243+
/// even if it is public.
244+
///
245+
/// See [taiki-e/pin-project#53] and [rust-lang/rust#63281] for more details.
246+
///
247+
/// [taiki-e/pin-project#53]: https://github.com/taiki-e/pin-project/pull/53#issuecomment-525906867
248+
/// [rust-lang/rust#63281]: https://github.com/rust-lang/rust/issues/63281
240249
#vis struct #struct_ident #full_generics #where_clause {
241250
__pin_project_use_generics: #always_unpin_ident <(#(#type_params),*)>,
242251

0 commit comments

Comments
 (0)
Please sign in to comment.