diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-04-27 00:12:32 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-04-27 00:12:32 +0200 |
| commit | aa69e3a0cb8f1b2e086709a038baad6f39249150 (patch) | |
| tree | bfbaf5ecca7b915d247cb2c6996b1fb52e665c08 /src/librustdoc/doctest/make.rs | |
| parent | 3ef98a55ef95b058e55897f1b213dd965839e3ed (diff) | |
| download | rust-aa69e3a0cb8f1b2e086709a038baad6f39249150.tar.gz rust-aa69e3a0cb8f1b2e086709a038baad6f39249150.zip | |
Fix bad handling of macros if there is already a `main` function
Diffstat (limited to 'src/librustdoc/doctest/make.rs')
| -rw-r--r-- | src/librustdoc/doctest/make.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index e41a06aff30..4194abc8d57 100644 --- a/src/librustdoc/doctest/make.rs +++ b/src/librustdoc/doctest/make.rs @@ -424,7 +424,10 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn // We assume that the macro calls will expand to item(s) even though they could // expand to statements and expressions. And the simple fact that we're trying // to retrieve a `main` function inside it is a terrible idea. - StmtKind::MacCall(ref mac_call) if !info.has_main_fn => { + StmtKind::MacCall(ref mac_call) => { + if info.has_main_fn { + continue; + } let mut iter = mac_call.mac.args.tokens.iter(); while let Some(token) = iter.next() { |
