Rely on docs.rs to define --cfg=docsrs by default

This commit is contained in:
David Tolnay 2024-05-18 21:28:24 -07:00
parent 953009edfb
commit 81404f2f49
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
6 changed files with 7 additions and 8 deletions

View File

@ -45,7 +45,7 @@ members = ["demo", "flags", "gen/build", "gen/cmd", "gen/lib", "macro", "tests/f
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition"]
rustdoc-args = ["--generate-link-to-definition"]
[package.metadata.bazel]
additive_build_file_content = """

View File

@ -32,7 +32,6 @@ fn main() {
println!("cargo:rustc-check-cfg=cfg(compile_error_if_alloc)");
println!("cargo:rustc-check-cfg=cfg(compile_error_if_std)");
println!("cargo:rustc-check-cfg=cfg(cxx_experimental_no_alloc)");
println!("cargo:rustc-check-cfg=cfg(doc_cfg)");
println!("cargo:rustc-check-cfg=cfg(no_core_ffi_c_char)");
println!("cargo:rustc-check-cfg=cfg(skip_ui_tests)");
}

View File

@ -148,7 +148,7 @@ impl CxxString {
///
/// [replacement character]: https://doc.rust-lang.org/std/char/constant.REPLACEMENT_CHARACTER.html
#[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub fn to_string_lossy(&self) -> Cow<str> {
String::from_utf8_lossy(self.as_bytes())
}

View File

@ -4,7 +4,7 @@ use alloc::boxed::Box;
use core::fmt::{self, Display};
/// Exception thrown from an `extern "C++"` function.
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[derive(Debug)]
pub struct Exception {
pub(crate) what: Box<str>,
@ -17,7 +17,7 @@ impl Display for Exception {
}
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Exception {}
impl Exception {

View File

@ -217,7 +217,7 @@ impl_extern_type! {
f64 = "double"
#[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
String = "rust::String"
[Opaque]

View File

@ -365,7 +365,7 @@
#![no_std]
#![doc(html_root_url = "https://docs.rs/cxx/1.0.122")]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(
improper_ctypes,
improper_ctypes_definitions,
@ -477,7 +477,7 @@ mod weak_ptr;
pub use crate::cxx_vector::CxxVector;
#[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub use crate::exception::Exception;
pub use crate::extern_type::{kind, ExternType};
pub use crate::shared_ptr::SharedPtr;