about summary refs log tree commit diff
path: root/src/librustdoc/doctest/make.rs
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-04-27 00:12:32 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-04-27 00:12:32 +0200
commitaa69e3a0cb8f1b2e086709a038baad6f39249150 (patch)
treebfbaf5ecca7b915d247cb2c6996b1fb52e665c08 /src/librustdoc/doctest/make.rs
parent3ef98a55ef95b058e55897f1b213dd965839e3ed (diff)
downloadrust-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.rs5
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() {