Correctly handle line comments in attributes and generate extern crates
outside of wrapping function
This commit is contained in:
parent
6f7e8d441a
commit
123ea25542
7 changed files with 98 additions and 25 deletions
|
@ -6,7 +6,7 @@ successes:
|
|||
|
||||
---- $DIR/display-output.rs - foo (line 9) stdout ----
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/display-output.rs:11:5
|
||||
--> $DIR/display-output.rs:12:5
|
||||
|
|
||||
LL | let x = 12;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
@ -19,13 +19,13 @@ LL | #![warn(unused)]
|
|||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/display-output.rs:13:8
|
||||
--> $DIR/display-output.rs:14:8
|
||||
|
|
||||
LL | fn foo(x: &dyn std::fmt::Display) {}
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
||||
warning: function `foo` is never used
|
||||
--> $DIR/display-output.rs:13:4
|
||||
--> $DIR/display-output.rs:14:4
|
||||
|
|
||||
LL | fn foo(x: &dyn std::fmt::Display) {}
|
||||
| ^^^
|
||||
|
|
23
tests/rustdoc-ui/doctest/extern-crate.rs
Normal file
23
tests/rustdoc-ui/doctest/extern-crate.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
//@ check-pass
|
||||
//@ compile-flags:--test --test-args=--test-threads=1
|
||||
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
|
||||
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
|
||||
|
||||
// This test ensures that crate imports are placed outside of the `main` function
|
||||
// so they work all the time (even in 2015 edition).
|
||||
|
||||
/// ```rust
|
||||
/// #![feature(test)]
|
||||
///
|
||||
/// extern crate test;
|
||||
/// use test::Bencher;
|
||||
///
|
||||
/// #[bench]
|
||||
/// fn bench_xor_1000_ints(b: &mut Bencher) {
|
||||
/// b.iter(|| {
|
||||
/// (0..1000).fold(0, |old, new| old ^ new);
|
||||
/// });
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
pub fn foo() {}
|
6
tests/rustdoc-ui/doctest/extern-crate.stdout
Normal file
6
tests/rustdoc-ui/doctest/extern-crate.stdout
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
running 1 test
|
||||
test $DIR/extern-crate.rs - foo (line 9) ... ok
|
||||
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue