Skip to content

Commit

Permalink
Rollup merge of #82598 - GuillaumeGomez:rustdoc-rustc-pass, r=jyn514
Browse files Browse the repository at this point in the history
Check stability and feature attributes in rustdoc

Fixes #82588.

cc `@Nemo157` `@camelid`
r? `@jyn514`
  • Loading branch information
GuillaumeGomez authored Mar 1, 2021
2 parents b51272e + d20fd62 commit 5a82251
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub use crate::sys::windows_ext as windows;
pub mod linux;

#[cfg(doc)]
#[stable(feature = "wasi_ext_doc", since = "1.35.0")]
pub use crate::sys::wasi_ext as wasi;

// If we're not documenting libstd then we just expose the main modules as we otherwise would.
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ cfg_if::cfg_if! {
cfg_if::cfg_if! {
if #[cfg(target_os = "wasi")] {
// On WASI we'll document what's already available
#[stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "wasi_ext_doc", since = "1.35.0")]
pub use self::ext as wasi_ext;
} else if #[cfg(any(target_os = "hermit",
target_arch = "wasm32",
Expand All @@ -125,6 +125,7 @@ cfg_if::cfg_if! {
} else {
// On other platforms like Windows document the bare bones of WASI
#[path = "wasi/ext/mod.rs"]
#[stable(feature = "wasi_ext_doc", since = "1.35.0")]
pub mod wasi_ext;
}
}
1 change: 1 addition & 0 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ crate fn run_global_ctxt(
tcx.ensure().check_mod_attrs(module);
}
});
rustc_passes::stability::check_unused_or_stable_features(tcx);

let access_levels = tcx.privacy_access_levels(LOCAL_CRATE);
// Convert from a HirId set to a DefId set since we don't always have easy access
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern crate rustc_metadata;
extern crate rustc_middle;
extern crate rustc_mir;
extern crate rustc_parse;
extern crate rustc_passes;
extern crate rustc_resolve;
extern crate rustc_session;
extern crate rustc_span as rustc_span;
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/rustc-check-passes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![feature(box_syntax)]
#![feature(box_syntax)] //~ ERROR

pub fn foo() {}
9 changes: 9 additions & 0 deletions src/test/rustdoc-ui/rustc-check-passes.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0636]: the feature `box_syntax` has already been declared
--> $DIR/rustc-check-passes.rs:2:12
|
LL | #![feature(box_syntax)]
| ^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0636`.
2 changes: 2 additions & 0 deletions src/test/rustdoc/implementor-stable-version.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![stable(feature = "bar", since = "OLD 1.0")]
#![crate_name = "foo"]

#![feature(staged_api)]
Expand All @@ -8,6 +9,7 @@ pub trait Bar {}
#[stable(feature = "baz", since = "OLD 1.0")]
pub trait Baz {}

#[stable(feature = "baz", since = "OLD 1.0")]
pub struct Foo;

// @has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' 'NEW 2.0'
Expand Down

0 comments on commit 5a82251

Please sign in to comment.