Skip to content

Commit

Permalink
avoid an unnecessary &str to String conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
TaKO8Ki committed Nov 30, 2022
1 parent 97f0c58 commit 02eaecc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions compiler/rustc_session/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ pub enum UnleashedFeatureHelp {

#[derive(Diagnostic)]
#[diag(session_invalid_literal_suffix)]
pub(crate) struct InvalidLiteralSuffix {
pub(crate) struct InvalidLiteralSuffix<'a> {
#[primary_span]
#[label]
pub span: Span,
// FIXME(#100717)
pub kind: String,
pub kind: &'a str,
pub suffix: Symbol,
}

Expand Down Expand Up @@ -311,11 +311,7 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span:
LitError::LexerError => {}
LitError::InvalidSuffix => {
if let Some(suffix) = suffix {
sess.emit_err(InvalidLiteralSuffix {
span,
kind: format!("{}", kind.descr()),
suffix,
});
sess.emit_err(InvalidLiteralSuffix { span, kind: kind.descr(), suffix });
}
}
LitError::InvalidIntSuffix => {
Expand Down

0 comments on commit 02eaecc

Please sign in to comment.