Skip to content

Commit

Permalink
Rollup merge of rust-lang#81969 - jonas-schievink:no-cfg-if, r=Mark-S…
Browse files Browse the repository at this point in the history
…imulacrum

Avoid `cfg_if` in `std::os`

rust-analyzer cannot currently load the `cfg_if` crate, which means that rust-analyzer is unable to see `std::os::{unix, windows, linux}` here. This works around that by avoiding `cfg_if`; the `#[cfg]` expressions are simple enough to reasonably write by hand.

Fixes rust-lang/rust-analyzer#6038
  • Loading branch information
JohnTitor authored Feb 21, 2021
2 parents 9fb1bd9 + 4bf910b commit fcbcf85
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,31 @@
#![stable(feature = "os", since = "1.0.0")]
#![allow(missing_docs, nonstandard_style, missing_debug_implementations)]

cfg_if::cfg_if! {
if #[cfg(doc)] {
// When documenting libstd we want to show unix/windows/linux modules as these are the "main
// modules" that are used across platforms, so all modules are enabled when `cfg(doc)` is set.
// This should help show platform-specific functionality in a hopefully cross-platform way in the
// documentation.

// When documenting libstd we want to show unix/windows/linux modules as
// these are the "main modules" that are used across platforms. This
// should help show platform-specific functionality in a hopefully
// cross-platform way in the documentation
#[cfg(doc)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::unix_ext as unix;

#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::unix_ext as unix;
#[cfg(doc)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::windows_ext as windows;

#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::windows_ext as windows;
#[cfg(not(doc))]
#[cfg(any(target_os = "redox", unix, target_os = "vxworks", target_os = "hermit"))]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::ext as unix;

#[doc(cfg(target_os = "linux"))]
pub mod linux;
} else {
#[cfg(not(doc))]
#[cfg(windows)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::ext as windows;

// If we're not documenting libstd then we just expose the main modules
// as we otherwise would.

#[cfg(any(target_os = "redox", unix, target_os = "vxworks", target_os = "hermit"))]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::ext as unix;

#[cfg(windows)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::ext as windows;

#[cfg(any(target_os = "linux", target_os = "l4re"))]
pub mod linux;

}
}
#[cfg(any(doc, target_os = "linux", target_os = "l4re"))]
pub mod linux;

#[cfg(target_os = "android")]
pub mod android;
Expand Down

0 comments on commit fcbcf85

Please sign in to comment.