Change:
When writing it will suggest and I think nothing should be suggested before it is validated. The statement to be suggested must be checked if it is true or not, if true it is suggested and if not it is not. The issue from: : The current output is: <!-- The following is not always necessary. --Ideally the output should look like: <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim
Oh dear, I didn't think of that while making the PR. A possible solution could be checking if the current token is for initializing an item? Like, struct/enum/macro, etc.
I wrote this solution, but I don't know if I can use it in rustc, it's currently building
I can't work on the problem unfortunately, whoever will assign it to him you can solve it this way The block
release-assignment
claim
Trying to add a method in token: And add a check: Any other better idea?
could be the keyword, as well. looks alright, ideally the repeated block could be prevented using a macro? I'm afraid that might slightly overengineer it, though.

Discussion:
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed}; use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; use rustc_span::source_map::Spanned; <del> use rustc_span::symbol::{kw, Ident}; </del> <ins> use rustc_span::symbol::{kw, sym, Ident}; </ins> use rustc_span::{Span, SpanSnippetError, DUMMY_SP}; use std::ops::{Deref, DerefMut};

let mut err = self.struct_span_err(self.token.span, &msg_exp); if let TokenKind::Ident(symbol, _) = &self.prev_token.kind { <del> if symbol.as_str() == "public" { err.span_suggestion_short( self.prev_token.span, "write `pub` instead of `public` to make the item public", "pub", appl, ); } </del> if ["def", "fun", "func", "function"].contains(&symbol.as_str()) { err.span_suggestion_short( self.prev_token.span,

} } <ins> // `pub` may be used for an item or `pub(crate)` if self.prev_token.is_ident_named(sym::public) && (self.token.can_begin_item() || self.token.kind == TokenKind::OpenDelim(Delimiter::Parenthesis)) { err.span_suggestion_short( self.prev_token.span, "write `pub` instead of `public` to make the item public", "pub", appl, ); } </ins> // Add suggestion for a missing closing angle bracket if '>' is included in expected_tokens // there are unclosed angle brackets if self.unmatched_angle_bracket_count > 0

ptr_offset_from_unsigned, pub_macro_rules, pub_restricted, <ins> public, </ins> pure, pushpop_unsafe, qreg,

<ins> // Checks what happens when `public` is used instead of the correct, `pub` // run-rustfix pub enum Test { //~^ ERROR expected one of `!` or `::`, found keyword `enum` //~^^ HELP write `pub` instead of `public` to make the item public A, B, } fn main() { } </ins>

<ins> // Checks what happens when `public` is used instead of the correct, `pub` // run-rustfix public enum Test { //~^ ERROR expected one of `!` or `::`, found keyword `enum` //~^^ HELP write `pub` instead of `public` to make the item public A, B, } fn main() { } </ins>

<ins> error: expected one of `!` or `::`, found keyword `enum` --> $DIR/public-instead-of-pub-1.rs:4:8 | LL | public enum Test { |        ^^^^ expected one of `!` or `::` | help: write `pub` instead of `public` to make the item public | LL | pub enum Test { | ~~~ error: aborting due to previous error </ins>

<ins> // Checks what happens when `public` is used instead of the correct, `pub` // Won't give help message for this case public let x = 1; //~^ ERROR expected one of `!` or `::`, found keyword `let` fn main() { } </ins>

<ins> error: expected one of `!` or `::`, found keyword `let` --> $DIR/public-instead-of-pub-2.rs:4:8 | LL | public let x = 1; |        ^^^ expected one of `!` or `::` error: aborting due to previous error </ins>