File tree 6 files changed +15
-12
lines changed
6 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -73,9 +73,9 @@ impl<T: ?Sized> !Send for *mut T { }
73
73
/// impl Foo for Impl { }
74
74
/// impl Bar for Impl { }
75
75
///
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
79
79
/// ```
80
80
///
81
81
/// [trait object]: ../../book/ch17-02-trait-objects.html
Original file line number Diff line number Diff line change @@ -510,6 +510,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
510
510
/// A simple example:
511
511
///
512
512
/// ```
513
+ /// #![feature(mem_take)]
514
+ ///
513
515
/// use std::mem;
514
516
///
515
517
/// let mut v: Vec<i32> = vec![1, 2];
@@ -540,7 +542,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
540
542
/// `self`, allowing it to be returned:
541
543
///
542
544
/// ```
543
- /// # #![allow(dead_code)]
545
+ /// #![feature(mem_take)]
546
+ ///
544
547
/// use std::mem;
545
548
///
546
549
/// # struct Buffer<T> { buf: Vec<T> }
Original file line number Diff line number Diff line change 53
53
/// let value: i32 = 123;
54
54
///
55
55
/// // let the compiler make a trait object
56
- /// let object: &Foo = &value;
56
+ /// let object: &dyn Foo = &value;
57
57
///
58
58
/// // look at the raw representation
59
59
/// let raw_object: raw::TraitObject = unsafe { mem::transmute(object) };
65
65
///
66
66
/// // construct a new object, pointing to a different `i32`, being
67
67
/// // careful to use the `i32` vtable from `object`
68
- /// let synthesized: &Foo = unsafe {
68
+ /// let synthesized: &dyn Foo = unsafe {
69
69
/// mem::transmute(raw::TraitObject {
70
70
/// data: &other_value as *const _ as *mut (),
71
71
/// vtable: raw_object.vtable,
Original file line number Diff line number Diff line change @@ -351,9 +351,6 @@ impl Options {
351
351
. unwrap_or_else ( || PathBuf :: from ( "doc" ) ) ;
352
352
let mut cfgs = matches. opt_strs ( "cfg" ) ;
353
353
cfgs. push ( "rustdoc" . to_string ( ) ) ;
354
- if should_test {
355
- cfgs. push ( "test" . to_string ( ) ) ;
356
- }
357
354
358
355
let extension_css = matches. opt_str ( "e" ) . map ( |s| PathBuf :: from ( & s) ) ;
359
356
Original file line number Diff line number Diff line change 2
2
// compile-flags:--test
3
3
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
4
4
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
+
5
8
/// this doctest will be ignored:
6
9
///
7
10
/// ```
8
11
/// assert!(false);
9
12
/// ```
10
- #[ cfg( not ( test) ) ]
13
+ #[ cfg( test) ]
11
14
pub struct Foo ;
12
15
13
16
/// this doctest will be tested:
14
17
///
15
18
/// ```
16
19
/// assert!(true);
17
20
/// ```
18
- #[ cfg( test) ]
21
+ #[ cfg( not ( test) ) ]
19
22
pub struct Foo ;
Original file line number Diff line number Diff line change 1
1
2
2
running 1 test
3
- test $DIR/cfg-test.rs - Foo (line 15 ) ... ok
3
+ test $DIR/cfg-test.rs - Foo (line 18 ) ... ok
4
4
5
5
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
6
6
You can’t perform that action at this time.
0 commit comments