diff options
| author | bors <bors@rust-lang.org> | 2025-06-16 18:20:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-06-16 18:20:05 +0000 |
| commit | 45acf54eea118ed27927282b5e0bfdcd80b7987c (patch) | |
| tree | e876174d258caa3d3ab3233f3e6a0697b9601157 /compiler/rustc_parse/src/parser | |
| parent | 3bc767e1a215c4bf8f099b32e84edb85780591b1 (diff) | |
| parent | b1ba2cdf41da538fa2195ff439cc6b82723b9474 (diff) | |
| download | rust-45acf54eea118ed27927282b5e0bfdcd80b7987c.tar.gz rust-45acf54eea118ed27927282b5e0bfdcd80b7987c.zip | |
Auto merge of #142589 - Kobzol:rollup-j90fk2j, r=Kobzol
Rollup of 8 pull requests Successful merges: - rust-lang/rust#139340 (Fix RISC-V C function ABI when passing/returning structs containing floats) - rust-lang/rust#142341 (Don't suggest converting `///` to `//` when expecting `,`) - rust-lang/rust#142414 (ignore `run-make` tests that need `std` on targets without `std`) - rust-lang/rust#142498 (Port `#[rustc_as_ptr]` to the new attribute system) - rust-lang/rust#142554 (Fix `PathSource` lifetimes.) - rust-lang/rust#142562 (Update the `backtrace` submodule) - rust-lang/rust#142565 (Test naked asm for wasm32-unknown-unknown) - rust-lang/rust#142573 (`fn candidate_is_applicable` to method) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 215202c4bd5..a64bb424117 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -686,23 +686,34 @@ impl<'a> Parser<'a> { } if let token::DocComment(kind, style, _) = self.token.kind { - // We have something like `expr //!val` where the user likely meant `expr // !val` - let pos = self.token.span.lo() + BytePos(2); - let span = self.token.span.with_lo(pos).with_hi(pos); - err.span_suggestion_verbose( - span, - format!( - "add a space before {} to write a regular comment", - match (kind, style) { - (token::CommentKind::Line, ast::AttrStyle::Inner) => "`!`", - (token::CommentKind::Block, ast::AttrStyle::Inner) => "`!`", - (token::CommentKind::Line, ast::AttrStyle::Outer) => "the last `/`", - (token::CommentKind::Block, ast::AttrStyle::Outer) => "the last `*`", - }, - ), - " ".to_string(), - Applicability::MachineApplicable, - ); + // This is to avoid suggesting converting a doc comment to a regular comment + // when missing a comma before the doc comment in lists (#142311): + // + // ``` + // enum Foo{ + // A /// xxxxxxx + // B, + // } + // ``` + if !expected.contains(&TokenType::Comma) { + // We have something like `expr //!val` where the user likely meant `expr // !val` + let pos = self.token.span.lo() + BytePos(2); + let span = self.token.span.with_lo(pos).with_hi(pos); + err.span_suggestion_verbose( + span, + format!( + "add a space before {} to write a regular comment", + match (kind, style) { + (token::CommentKind::Line, ast::AttrStyle::Inner) => "`!`", + (token::CommentKind::Block, ast::AttrStyle::Inner) => "`!`", + (token::CommentKind::Line, ast::AttrStyle::Outer) => "the last `/`", + (token::CommentKind::Block, ast::AttrStyle::Outer) => "the last `*`", + }, + ), + " ".to_string(), + Applicability::MaybeIncorrect, + ); + } } let sp = if self.token == token::Eof { |
