Skip to content

Commit 02eaecc

Browse files
committed
avoid an unnecessary &str to String conversion
1 parent 97f0c58 commit 02eaecc

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

compiler/rustc_session/src/errors.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ pub enum UnleashedFeatureHelp {
197197

198198
#[derive(Diagnostic)]
199199
#[diag(session_invalid_literal_suffix)]
200-
pub(crate) struct InvalidLiteralSuffix {
200+
pub(crate) struct InvalidLiteralSuffix<'a> {
201201
#[primary_span]
202202
#[label]
203203
pub span: Span,
204204
// FIXME(#100717)
205-
pub kind: String,
205+
pub kind: &'a str,
206206
pub suffix: Symbol,
207207
}
208208

@@ -311,11 +311,7 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span:
311311
LitError::LexerError => {}
312312
LitError::InvalidSuffix => {
313313
if let Some(suffix) = suffix {
314-
sess.emit_err(InvalidLiteralSuffix {
315-
span,
316-
kind: format!("{}", kind.descr()),
317-
suffix,
318-
});
314+
sess.emit_err(InvalidLiteralSuffix { span, kind: kind.descr(), suffix });
319315
}
320316
}
321317
LitError::InvalidIntSuffix => {

0 commit comments

Comments
 (0)