fix(doctest): detect extern crate items in statement doctests
This partially reverts #91026, because rustdoc needs to detect the extern statements, even when they appear inside implicit `main()`. It does not entirely revert it, so the old bug is still fixed, by duplicating some of the logic from `parse_mod` instead of trying to use it directly. Fixes #91134
This commit is contained in:
parent
214ad2f5b5
commit
bff1645bdb
5 changed files with 38 additions and 8 deletions
3
src/test/rustdoc-ui/auxiliary/empty-fn.rs
Normal file
3
src/test/rustdoc-ui/auxiliary/empty-fn.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// no-prefer-dynamic
|
||||
#![crate_type = "lib"]
|
||||
pub fn empty() {}
|
||||
14
src/test/rustdoc-ui/issue-91134.rs
Normal file
14
src/test/rustdoc-ui/issue-91134.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// compile-flags: --test --crate-name=empty_fn --extern=empty_fn --test-args=--test-threads=1
|
||||
// aux-build:empty-fn.rs
|
||||
// check-pass
|
||||
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
|
||||
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
|
||||
// edition:2021
|
||||
|
||||
/// <https://github.com/rust-lang/rust/issues/91134>
|
||||
///
|
||||
/// ```
|
||||
/// extern crate empty_fn;
|
||||
/// empty_fn::empty();
|
||||
/// ```
|
||||
pub struct Something;
|
||||
6
src/test/rustdoc-ui/issue-91134.stdout
Normal file
6
src/test/rustdoc-ui/issue-91134.stdout
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
running 1 test
|
||||
test $DIR/issue-91134.rs - something (line 10) ... 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