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