diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-03-07 15:20:14 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-03-27 11:18:43 +0100 |
| commit | 123ea25542ba00e92bf6d19084cad6e7a24453f0 (patch) | |
| tree | 1c28cb09189c8abc45e7e934a15f85e59175f43d /tests/rustdoc-ui/doctest/extern-crate.rs | |
| parent | 6f7e8d441a81ed89e14ad5ce53dcbe52ab0af64c (diff) | |
| download | rust-123ea25542ba00e92bf6d19084cad6e7a24453f0.tar.gz rust-123ea25542ba00e92bf6d19084cad6e7a24453f0.zip | |
Correctly handle line comments in attributes and generate extern crates
outside of wrapping function
Diffstat (limited to 'tests/rustdoc-ui/doctest/extern-crate.rs')
| -rw-r--r-- | tests/rustdoc-ui/doctest/extern-crate.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/doctest/extern-crate.rs b/tests/rustdoc-ui/doctest/extern-crate.rs new file mode 100644 index 00000000000..0415d33bb72 --- /dev/null +++ b/tests/rustdoc-ui/doctest/extern-crate.rs @@ -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() {} |
