gstreamer: Move attributes on macro-calls like cfg_if inside the macro

Attributes don't do anything when applied to macro invocations:

    warning: unused attribute `doc`
       --> gstreamer/src/lib.rs:146:29
        |
    146 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
        |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_attributes)]` on by default
    note: the built-in attribute `doc` will be ignored, since it's applied to the macro invocation `cfg_if::cfg_if`
       --> gstreamer/src/lib.rs:147:1
        |
    147 | cfg_if::cfg_if! {
        | ^^^^^^^^^^^^^^

And, on line 294-295:

    warning: unused attribute `doc`
       --> gstreamer/src/lib.rs:294:33
        |
    294 |     #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
        |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
    note: the built-in attribute `doc` will be ignored, since it's applied to the macro invocation `cfg_if::cfg_if`
       --> gstreamer/src/lib.rs:295:5
        |
    295 |     cfg_if::cfg_if! {
        |     ^^^^^^^^^^^^^^

Fortunately these two `cfg_if`'s for the Unix and Windows bus already
apply unnecessary trickery that duplicates the `mod`s and `use`s in
order to get documenation for both no matter the target platform; we can
capitalize on that by removing the `cfg_if` altogether and instead
applying the `cfg` and `doc(cfg())` attributes directly.
This commit is contained in:
Marijn Suijten 2021-08-29 11:16:58 +02:00
parent 782d84bede
commit 12887f1931

View file

@ -141,20 +141,13 @@ pub use element_factory_list_type::*;
mod tracer; mod tracer;
// OS dependent Bus extensions (also import the other plateform mod for doc) // OS dependent Bus extensions (also import the other platform mod for doc)
#[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg(any(all(unix, feature = "v1_14"), feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
cfg_if::cfg_if! { mod bus_unix;
if #[cfg(unix)] { #[cfg(any(all(windows, feature = "v1_14"), feature = "dox"))]
mod bus_unix; #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
#[cfg(feature = "dox")] mod bus_windows;
mod bus_windows;
} else {
mod bus_windows;
#[cfg(feature = "dox")]
mod bus_unix;
}
}
mod child_proxy; mod child_proxy;
#[macro_use] #[macro_use]
@ -290,19 +283,12 @@ pub mod prelude {
pub use crate::meta::MetaAPI; pub use crate::meta::MetaAPI;
// OS dependent Bus extensions (also import the other platform trait for doc) // OS dependent Bus extensions (also import the other platform trait for doc)
#[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg(any(all(unix, feature = "v1_14"), feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
cfg_if::cfg_if! { pub use crate::bus_unix::UnixBusExtManual;
if #[cfg(unix)] { #[cfg(any(all(windows, feature = "v1_14"), feature = "dox"))]
pub use crate::bus_unix::UnixBusExtManual; #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
#[cfg(feature = "dox")] pub use crate::bus_windows::WindowsBusExtManual;
pub use crate::bus_windows::WindowsBusExtManual;
} else {
pub use crate::bus_windows::WindowsBusExtManual;
#[cfg(feature = "dox")]
pub use crate::bus_unix::UnixBusExtManual;
}
}
pub use crate::bin::GstBinExtManual; pub use crate::bin::GstBinExtManual;
pub use crate::buffer_pool::BufferPoolExtManual; pub use crate::buffer_pool::BufferPoolExtManual;