Skip to content

Commit

Permalink
Enable doc_cfg on nightly via build script
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelc authored and SergioBenitez committed Mar 19, 2021
1 parent 42b82c9 commit 4a93b9d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ edition = "2018"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
features = ["all"]
Expand Down Expand Up @@ -47,6 +46,9 @@ serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.0", features = ["full"] }
hyper = { version = "0.14", features = ["server", "http1", "stream", "tcp"] }

[build-dependencies]
version_check = "0.9"

[[example]]
name = "parse_async_read"
path = "examples/parse_async_read.rs"
Expand Down
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
if let Some(true) = version_check::is_feature_flaggable() {
println!("cargo:rustc-cfg=nightly");
}
}
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub enum Error {
/// Failed to decode the field data as `JSON` in
/// [`field.json()`](./struct.Field.html#method.json) method.
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
#[cfg_attr(nightly, doc(cfg(feature = "json")))]
#[display(fmt = "failed to decode field data as JSON: {}", _0)]
DecodeJson(serde_json::Error),
}
Expand Down
2 changes: 1 addition & 1 deletion src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl Field {
/// or it cannot be properly deserialized to target type `T`. For more
/// details please see [`serde_json::from_slice`](https://docs.serde.rs/serde_json/fn.from_slice.html);
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
#[cfg_attr(nightly, doc(cfg(feature = "json")))]
pub async fn json<T: DeserializeOwned>(self) -> crate::Result<T> {
serde_json::from_slice(&self.bytes().await?).map_err(crate::Error::DecodeJson)
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
trivial_casts,
unused_qualifications
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(nightly, feature(doc_cfg))]
#![doc(test(attr(deny(rust_2018_idioms, warnings))))]
#![doc(test(attr(allow(unused_extern_crates, unused_variables))))]

Expand Down
4 changes: 2 additions & 2 deletions src/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl Multipart {
///
/// [`AsyncRead`]: https://docs.rs/futures-io/0.3.7/futures_io/trait.AsyncRead.html
#[cfg(feature = "tokio-io")]
#[cfg_attr(docsrs, doc(cfg(feature = "tokio-io")))]
#[cfg_attr(nightly, doc(cfg(feature = "tokio-io")))]
pub fn with_reader<R, B>(reader: R, boundary: B) -> Multipart
where
R: AsyncRead + Unpin + Send + 'static,
Expand Down Expand Up @@ -177,7 +177,7 @@ impl Multipart {
///
/// [`AsyncRead`]: https://docs.rs/futures-io/0.3.7/futures_io/trait.AsyncRead.html
#[cfg(feature = "tokio-io")]
#[cfg_attr(docsrs, doc(cfg(feature = "tokio-io")))]
#[cfg_attr(nightly, doc(cfg(feature = "tokio-io")))]
pub fn with_reader_with_constraints<R, B>(reader: R, boundary: B, constraints: Constraints) -> Multipart
where
R: AsyncRead + Unpin + Send + 'static,
Expand Down

0 comments on commit 4a93b9d

Please sign in to comment.