diff options
| author | Ed Page <eopage@gmail.com> | 2025-07-09 15:35:52 -0500 |
|---|---|---|
| committer | Ed Page <eopage@gmail.com> | 2025-07-10 10:26:02 -0500 |
| commit | a11ee5614c052d6339c56c2673780468c96dbc16 (patch) | |
| tree | 74cfa963c52945636be85856b09255dec6c78530 /compiler/rustc_ast_pretty | |
| parent | df53b3dc04950d980bd28ec4b04f48cd0cd01237 (diff) | |
| download | rust-a11ee5614c052d6339c56c2673780468c96dbc16.tar.gz rust-a11ee5614c052d6339c56c2673780468c96dbc16.zip | |
fix: Include frontmatter in -Zunpretty output
In the implementation (#140035), this was left as an open question for the tracking issue (#136889). My assumption is that this should be carried over. Thankfully, either way, `-Zunpretty` is unstable and we can always change it even if we stabilize frontmatter.
Diffstat (limited to 'compiler/rustc_ast_pretty')
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 9d656253f72..def0cb74d29 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -120,7 +120,7 @@ fn gather_comments(sm: &SourceMap, path: FileName, src: String) -> Vec<Comment> pos += shebang_len; } - for token in rustc_lexer::tokenize(&text[pos..], rustc_lexer::FrontmatterAllowed::No) { + for token in rustc_lexer::tokenize(&text[pos..], rustc_lexer::FrontmatterAllowed::Yes) { let token_text = &text[pos..pos + token.len as usize]; match token.kind { rustc_lexer::TokenKind::Whitespace => { @@ -171,6 +171,14 @@ fn gather_comments(sm: &SourceMap, path: FileName, src: String) -> Vec<Comment> }) } } + rustc_lexer::TokenKind::Frontmatter { .. } => { + code_to_the_left = false; + comments.push(Comment { + style: CommentStyle::Isolated, + lines: vec![token_text.to_string()], + pos: start_bpos + BytePos(pos as u32), + }); + } _ => { code_to_the_left = true; } |
