-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler 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
Code
///
/// #!/usr/bin/env cargo
///
/// println!("hello");
///
pub struct Foo;Current output
---- $DIR/failed-doctest-shebang.rs - Foo (line 6) stdout ----
error: macro expansion ignores `{` and any tokens following
--> $SRC_DIR/std/src/macros.rs:LL:COL
|
::: $DIR/failed-doctest-shebang.rs:9:1
|
LL | println!("hello");
| ----------------- caused by the macro expansion here
|
= note: the usage of `println!` is likely invalid in item context
error[E0601]: `main` function not found in crate `rust_out`
--> $DIR/failed-doctest-shebang.rs:9:19
|
LL | println!("hello");
| ^ consider adding a `main` function to `$DIR/failed-doctest-shebang.rs`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0601`.
Couldn't compile the test.
failures:
$DIR/failed-doctest-shebang.rs - Foo (line 6)
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIMEDesired output
to include:
= note: the token sequence `#!` here looks like the start of a shebang interpreter directive but it is not
= help: if you meant this to be a shebang interpreter directive, move it to the very start of the file
See also #137619.Rationale and extra context
See #137249
Other cases
Potential variants:
- With `main`
- With and without merging
Potentially frontmatterRust Version
rustc 1.92.0-nightly (4068bafed 2025-10-20)Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler 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.
Type
Projects
Status
No status