You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make the std API inventory scanner respect nested comments and character literals #993
The API inventory generator uses regular expressions that stop a block comment at its first */ and do not recognize character literals. Valid source can therefore publish declarations that are still inside a comment or crash documentation generation on a public character constant.
Starting point: declarations. This is distinct from the contributor-owned Rust formatting helper PR #969; do not change that helper.
Reproduction
Audited canonical master 540728c2eb6cc12f5c69c3fb3fdb96e07ba059a4 on Linux amd64 with a checkout-built Wave 0.0.1-alpha-dev, matching checkout std, Rust 1.89.0 and LLVM 21.1.8. The compiler accepts this source with wavec check:
/* outer /* inner */
pub fun ghost() {}
*/
pub const C: char = '{';
pub fun real() {}
fun main() {}
Call the real Python scanner on its pieces:
fromtools.document_stdimportdeclarationsprint(list(declarations('/* outer /* inner */\npub fun ghost() {}\n*/\npub fun real() {}\n')))
print(list(declarations("pub const C: char = '{';\npub fun real() {}\n")))
The first returns both ghost and real, although ghost is commented out. The second raises ValueError: unterminated public const declaration because the character literal's brace changes scanner nesting.
Scope
Make this small declaration scanner lexically aware of supported nested block comments, strings, escaped character literals and delimiters. Preserve original declaration line numbers, target attributes, signatures and private-import exclusions. No compiler/frontend redesign or repository-wide reformat is required.
Completion criteria
Commented public-looking text never appears as API.
Character literals containing braces, semicolons, quotes and escapes do not change declaration boundaries.
Focused Python fixtures cover nested comments and source-line preservation; the real generated inventory stays deterministic and --check passes after regeneration.
The scanner now keeps nested comments out of the API list and skips quoted characters when looking for declaration boundaries
Added tests for escaped chars and source lines too
Activity
hiyouwhatsapp commentedon Oct 26, 2026
I put up #1053 for this
The scanner now keeps nested comments out of the API list and skips quoted characters when looking for declaration boundaries
Added tests for escaped chars and source lines too
fix(std): handle nested comments and quoted literals in API inventory
fix(std): handle nested comments and quoted literals in API inventory (…