From 313ce37757ec19510533fe06434b9a38c6a6b746 Mon Sep 17 00:00:00 2001 From: Pete LeVasseur Date: Thu, 24 Sep 2026 08:46:31 +0900 Subject: [PATCH 1/2] docs(macros): specify outline modules in procedural macro input Rust 1.99 stabilizes outline modules (`mod foo;`) in the input of attribute and derive procedural macros (rust-lang/rust#157857). The macro receives the module declaration as tokens; the module's source file is not loaded and its contents are not part of the input. --- src/changelog.rst | 5 +++++ src/macros.rst | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index b8585bc8..363f5129 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -38,6 +38,11 @@ Language changes in Rust 1.99.0 - `Stabilize '#[my_macro] mod foo;' `_ + New paragraphs: + + - :p:`fls_TFDKS0Nl3Rwh` + - :p:`fls_yJma4E9orknX` + - `Fix the 'overflowing_literals' lint with repeated negation `_ - Lints are outside the scope of the FLS diff --git a/src/macros.rst b/src/macros.rst index b5bcd3cd..53b318e0 100644 --- a/src/macros.rst +++ b/src/macros.rst @@ -420,6 +420,9 @@ The sole parameter of the :t:`macro implementation function` captures the :t:`token` stream produced from the related :s:`EnumDeclaration`, :s:`StructDeclaration`, or :s:`UnionDeclaration`. +:dp:`fls_TFDKS0Nl3Rwh` +The :t:`token` stream captured by the sole :t:`function parameter` of the :t:`macro implementation function` of a :t:`derive macro` excludes the contents of the :t:`source file` of any :t:`outline module`. The :t:`[source file]s` of such :t:`[outline module]s` are not loaded to produce this :t:`token` stream. + :dp:`fls_H5ipqqlH3pJh` A :t:`derive macro` adds all its declared :t:`[derive helper attribute]s` into the :t:`derive helper attribute` scope of the :t:`abstract data type` the @@ -497,6 +500,9 @@ The second :t:`function parameter` of the :t:`macro implementation function` captures the :t:`token` stream produced from the related :t:`item`, including all :t:`[outer attribute]s` that apply to that :t:`item`. +:dp:`fls_yJma4E9orknX` +The :t:`token` stream captured by the second :t:`function parameter` of the :t:`macro implementation function` of an :t:`attribute macro` excludes the contents of the :t:`source file` of any :t:`outline module`. The :t:`[source file]s` of such :t:`[outline module]s` are not loaded to produce this :t:`token` stream. + .. rubric:: Examples .. code-block:: rust @@ -599,6 +605,9 @@ See :p:`fls_4vjbkm4ceymk` for the declaration of #[output_and_return_item] fn attribute_macro_invoker() {} + #[output_and_return_item] + mod outline; + .. _fls_wjldgtio5o75: Macro Expansion From e5253947bcf6318c55de0b9beefa72fa0b3756ee Mon Sep 17 00:00:00 2001 From: Pete LeVasseur Date: Fri, 2 Oct 2026 10:47:28 +0900 Subject: [PATCH 2/2] docs(macros): scope outline module rules to the macro input Address review feedback on the outline module rules for derive and attribute macro input: - Drop "sole" from the derive rule; the parameter count is already stated by fls_npnze2cg8ae. - State which outline modules the rules cover: for a derive macro, those declared within the related abstract data type; for an attribute macro, the related item itself or a module declared within it. - Fold the no-loading statement into the same sentence instead of a second one. It is kept because excluding the source file contents from the token stream does not by itself say the file is left unloaded, and that is observable: an attribute macro that drops `mod absent;` compiles without the module file existing. --- src/macros.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/macros.rst b/src/macros.rst index 53b318e0..d6d2b794 100644 --- a/src/macros.rst +++ b/src/macros.rst @@ -421,7 +421,7 @@ the :t:`token` stream produced from the related :s:`EnumDeclaration`, :s:`StructDeclaration`, or :s:`UnionDeclaration`. :dp:`fls_TFDKS0Nl3Rwh` -The :t:`token` stream captured by the sole :t:`function parameter` of the :t:`macro implementation function` of a :t:`derive macro` excludes the contents of the :t:`source file` of any :t:`outline module`. The :t:`[source file]s` of such :t:`[outline module]s` are not loaded to produce this :t:`token` stream. +The :t:`token` stream captured by the :t:`function parameter` of the :t:`macro implementation function` of a :t:`derive macro` excludes the contents of the :t:`source file` of any :t:`outline module` declared within the related :t:`abstract data type`, and is produced without loading that :t:`source file`. :dp:`fls_H5ipqqlH3pJh` A :t:`derive macro` adds all its declared :t:`[derive helper attribute]s` into @@ -501,7 +501,7 @@ captures the :t:`token` stream produced from the related :t:`item`, including all :t:`[outer attribute]s` that apply to that :t:`item`. :dp:`fls_yJma4E9orknX` -The :t:`token` stream captured by the second :t:`function parameter` of the :t:`macro implementation function` of an :t:`attribute macro` excludes the contents of the :t:`source file` of any :t:`outline module`. The :t:`[source file]s` of such :t:`[outline module]s` are not loaded to produce this :t:`token` stream. +The :t:`token` stream captured by the second :t:`function parameter` of the :t:`macro implementation function` of an :t:`attribute macro` excludes the contents of the :t:`source file` of any :t:`outline module` that is, or is declared within, the related :t:`item`, and is produced without loading that :t:`source file`. .. rubric:: Examples