Skip to content

Revert "Set test flag when rustdoc is running with --test option" #61199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
@@ -73,9 +73,9 @@ impl<T: ?Sized> !Send for *mut T { }
/// impl Foo for Impl { }
/// impl Bar for Impl { }
///
/// let x: &Foo = &Impl; // OK
/// // let y: &Bar = &Impl; // error: the trait `Bar` cannot
/// // be made into an object
/// let x: &dyn Foo = &Impl; // OK
/// // let y: &dyn Bar = &Impl; // error: the trait `Bar` cannot
/// // be made into an object
/// ```
///
/// [trait object]: ../../book/ch17-02-trait-objects.html
5 changes: 4 additions & 1 deletion src/libcore/mem/mod.rs
Original file line number Diff line number Diff line change
@@ -510,6 +510,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
/// A simple example:
///
/// ```
/// #![feature(mem_take)]
///
/// use std::mem;
///
/// let mut v: Vec<i32> = vec![1, 2];
@@ -540,7 +542,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
/// `self`, allowing it to be returned:
///
/// ```
/// # #![allow(dead_code)]
/// #![feature(mem_take)]
///
/// use std::mem;
///
/// # struct Buffer<T> { buf: Vec<T> }
4 changes: 2 additions & 2 deletions src/libcore/raw.rs
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@
/// let value: i32 = 123;
///
/// // let the compiler make a trait object
/// let object: &Foo = &value;
/// let object: &dyn Foo = &value;
///
/// // look at the raw representation
/// let raw_object: raw::TraitObject = unsafe { mem::transmute(object) };
@@ -65,7 +65,7 @@
///
/// // construct a new object, pointing to a different `i32`, being
/// // careful to use the `i32` vtable from `object`
/// let synthesized: &Foo = unsafe {
/// let synthesized: &dyn Foo = unsafe {
/// mem::transmute(raw::TraitObject {
/// data: &other_value as *const _ as *mut (),
/// vtable: raw_object.vtable,
3 changes: 0 additions & 3 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
@@ -351,9 +351,6 @@ impl Options {
.unwrap_or_else(|| PathBuf::from("doc"));
let mut cfgs = matches.opt_strs("cfg");
cfgs.push("rustdoc".to_string());
if should_test {
cfgs.push("test".to_string());
}

let extension_css = matches.opt_str("e").map(|s| PathBuf::from(&s));

7 changes: 5 additions & 2 deletions src/test/rustdoc-ui/cfg-test.rs
Original file line number Diff line number Diff line change
@@ -2,18 +2,21 @@
// compile-flags:--test
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"

// Crates like core have doctests gated on `cfg(not(test))` so we need to make
// sure `cfg(test)` is not active when running `rustdoc --test`.

/// this doctest will be ignored:
///
/// ```
/// assert!(false);
/// ```
#[cfg(not(test))]
#[cfg(test)]
pub struct Foo;

/// this doctest will be tested:
///
/// ```
/// assert!(true);
/// ```
#[cfg(test)]
#[cfg(not(test))]
pub struct Foo;
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/cfg-test.stdout
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

running 1 test
test $DIR/cfg-test.rs - Foo (line 15) ... ok
test $DIR/cfg-test.rs - Foo (line 18) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out