Skip to content

Commit bb85316

Browse files
ollie27Mark-Simulacrum
authored andcommitted
Revert "Set test flag when rustdoc is running with --test option"
This reverts commit 8ed2292. It caused doctests in this repository to no longer be tested including all of the core crate.
1 parent ccfb34f commit bb85316

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/libcore/marker.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ impl<T: ?Sized> !Send for *mut T { }
7373
/// impl Foo for Impl { }
7474
/// impl Bar for Impl { }
7575
///
76-
/// let x: &Foo = &Impl; // OK
77-
/// // let y: &Bar = &Impl; // error: the trait `Bar` cannot
78-
/// // be made into an object
76+
/// let x: &dyn Foo = &Impl; // OK
77+
/// // let y: &dyn Bar = &Impl; // error: the trait `Bar` cannot
78+
/// // be made into an object
7979
/// ```
8080
///
8181
/// [trait object]: ../../book/ch17-02-trait-objects.html

src/libcore/mem.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
10711071
/// optimizations, potentially resulting in a larger size:
10721072
///
10731073
/// ```rust
1074-
/// # use std::mem::{MaybeUninit, size_of, align_of};
1074+
/// # use std::mem::{MaybeUninit, size_of};
10751075
/// assert_eq!(size_of::<Option<bool>>(), 1);
10761076
/// assert_eq!(size_of::<Option<MaybeUninit<bool>>>(), 2);
10771077
/// ```

src/libcore/raw.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
/// let value: i32 = 123;
5454
///
5555
/// // let the compiler make a trait object
56-
/// let object: &Foo = &value;
56+
/// let object: &dyn Foo = &value;
5757
///
5858
/// // look at the raw representation
5959
/// let raw_object: raw::TraitObject = unsafe { mem::transmute(object) };
@@ -65,7 +65,7 @@
6565
///
6666
/// // construct a new object, pointing to a different `i32`, being
6767
/// // careful to use the `i32` vtable from `object`
68-
/// let synthesized: &Foo = unsafe {
68+
/// let synthesized: &dyn Foo = unsafe {
6969
/// mem::transmute(raw::TraitObject {
7070
/// data: &other_value as *const _ as *mut (),
7171
/// vtable: raw_object.vtable,

src/librustdoc/config.rs

-3
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ impl Options {
351351
.unwrap_or_else(|| PathBuf::from("doc"));
352352
let mut cfgs = matches.opt_strs("cfg");
353353
cfgs.push("rustdoc".to_string());
354-
if should_test {
355-
cfgs.push("test".to_string());
356-
}
357354

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

src/test/rustdoc-ui/cfg-test.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
// compile-flags:--test
33
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
44

5+
// Crates like core have doctests gated on `cfg(not(test))` so we need to make
6+
// sure `cfg(test)` is not active when running `rustdoc --test`.
7+
58
/// this doctest will be ignored:
69
///
710
/// ```
811
/// assert!(false);
912
/// ```
10-
#[cfg(not(test))]
13+
#[cfg(test)]
1114
pub struct Foo;
1215

1316
/// this doctest will be tested:
1417
///
1518
/// ```
1619
/// assert!(true);
1720
/// ```
18-
#[cfg(test)]
21+
#[cfg(not(test))]
1922
pub struct Foo;

src/test/rustdoc-ui/cfg-test.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

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

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

0 commit comments

Comments
 (0)