-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
rust-lang/cargo
#12221Labels
A-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
This a minimal example. Standard compilation resolve file!()
macro as relative project path but doc-test compilation emit follow error:
error: couldn't read "/home/mdamico/temp/doc_test_file_bug/src/..//home/mdamico/temp/doc_test_file_bug/src/lib.rs.bis.rs": No such file or directory (os error 2)
--> /home/mdamico/temp/doc_test_file_bug/src/lib.rs:1:1
|
1 | include!(concat!("../", file!(), ".bis.rs"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This behavior involve just include!()
macro because when used in function or assignment works like as expected
///
/// ```
/// assert_eq!("src/lib.rs", file!())
/// ```
/// ```
/// assert_eq!("src/lib.rs", doc_test_file_bug::path())
/// ```
pub fn path() -> &'static str {
file!()
}
///
/// ```
/// assert_eq!("src/lib.rs", doc_test_file_bug::f)
/// ```
pub static f: &'static str = file!();
Doc-tests doc_test_file_bug
running 3 tests
test src/lib.rs - path (line 6) ... ok
test src/lib.rs - f (line 14) ... ok
test src/lib.rs - path (line 2) ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Now I should disable doc-test to use file!()
for including some auto-generated code.
Metadata
Metadata
Assignees
Labels
A-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.