- cx.struct_span_lint(NON_SNAKE_CASE, ident.span, fluent::lint_non_snake_case, |lint| {
- let sc = NonSnakeCase::to_snake_case(name);
- // We cannot provide meaningful suggestions
- // if the characters are in the category of "Uppercase Letter".
- if name != sc {
- // We have a valid span in almost all cases, but we don't have one when linting a crate
- // name provided via the command line.
- if !ident.span.is_dummy() {
- let sc_ident = Ident::from_str_and_span(&sc, ident.span);
- let (message, suggestion) = if sc_ident.is_reserved() {
- // We shouldn't suggest a reserved identifier to fix non-snake-case identifiers.
- // Instead, recommend renaming the identifier entirely or, if permitted,
- // escaping it to create a raw identifier.
- if sc_ident.name.can_be_raw() {
- (fluent::rename_or_convert_suggestion, sc_ident.to_string())
- } else {
- lint.note(fluent::cannot_convert_note);
- (fluent::rename_suggestion, String::new())
+ let span = ident.span;
+ let sc = NonSnakeCase::to_snake_case(name);
+ // We cannot provide meaningful suggestions
+ // if the characters are in the category of "Uppercase Letter".
+ let sub = if name != sc {
+ // We have a valid span in almost all cases, but we don't have one when linting a crate
+ // name provided via the command line.
+ if !span.is_dummy() {
+ let sc_ident = Ident::from_str_and_span(&sc, span);
+ if sc_ident.is_reserved() {
+ // We shouldn't suggest a reserved identifier to fix non-snake-case identifiers.
+ // Instead, recommend renaming the identifier entirely or, if permitted,
+ // escaping it to create a raw identifier.
+ if sc_ident.name.can_be_raw() {
+ NonSnakeCaseDiagSub::RenameOrConvertSuggestion {
+ span,
+ suggestion: sc_ident,