Skip to content

Commit 149106f

Browse files
committed
Auto merge of #61199 - ollie27:rustdoc_cfg_test, r=QuietMisdreavus
Revert "Set test flag when rustdoc is running with --test option" Reverts #59940. It caused doctests in this repository to no longer be tested including all of the core crate.
2 parents 8ebd67e + c77024c commit 149106f

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-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/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
510510
/// A simple example:
511511
///
512512
/// ```
513+
/// #![feature(mem_take)]
514+
///
513515
/// use std::mem;
514516
///
515517
/// let mut v: Vec<i32> = vec![1, 2];
@@ -540,7 +542,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
540542
/// `self`, allowing it to be returned:
541543
///
542544
/// ```
543-
/// # #![allow(dead_code)]
545+
/// #![feature(mem_take)]
546+
///
544547
/// use std::mem;
545548
///
546549
/// # struct Buffer<T> { buf: Vec<T> }

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)