diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-12-18 21:14:02 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-12-24 07:59:21 +1100 |
| commit | d51db05d7ee1a12ee168f2d1ccc93ccc11b216c7 (patch) | |
| tree | 6a1bd10bfc900bacf504f9b5e5b7b64378d00e04 /compiler/rustc_session/src/errors.rs | |
| parent | ec9af0d6cb6386c7be6056a71366d275d5ca3e1e (diff) | |
| download | rust-d51db05d7ee1a12ee168f2d1ccc93ccc11b216c7.tar.gz rust-d51db05d7ee1a12ee168f2d1ccc93ccc11b216c7.zip | |
Remove `ParseSess` methods that duplicate `DiagCtxt` methods.
Also add missing `#[track_caller]` attributes to `DiagCtxt` methods as necessary to keep tests working.
Diffstat (limited to 'compiler/rustc_session/src/errors.rs')
| -rw-r--r-- | compiler/rustc_session/src/errors.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 9f7d918d98b..0f86773b73f 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -364,13 +364,14 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span: } let token::Lit { kind, symbol, suffix, .. } = lit; + let dcx = &sess.dcx; match err { // `LexerError` is an error, but it was already reported // by lexer, so here we don't report it the second time. LitError::LexerError => {} LitError::InvalidSuffix => { if let Some(suffix) = suffix { - sess.emit_err(InvalidLiteralSuffix { span, kind: kind.descr(), suffix }); + dcx.emit_err(InvalidLiteralSuffix { span, kind: kind.descr(), suffix }); } } LitError::InvalidIntSuffix => { @@ -378,11 +379,11 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span: let suf = suf.as_str(); if looks_like_width_suffix(&['i', 'u'], suf) { // If it looks like a width, try to be helpful. - sess.emit_err(InvalidIntLiteralWidth { span, width: suf[1..].into() }); + dcx.emit_err(InvalidIntLiteralWidth { span, width: suf[1..].into() }); } else if let Some(fixed) = fix_base_capitalisation(symbol.as_str(), suf) { - sess.emit_err(InvalidNumLiteralBasePrefix { span, fixed }); + dcx.emit_err(InvalidNumLiteralBasePrefix { span, fixed }); } else { - sess.emit_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() }); + dcx.emit_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() }); } } LitError::InvalidFloatSuffix => { @@ -390,16 +391,16 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span: let suf = suf.as_str(); if looks_like_width_suffix(&['f'], suf) { // If it looks like a width, try to be helpful. - sess.emit_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() }); + dcx.emit_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() }); } else { - sess.emit_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() }); + dcx.emit_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() }); } } LitError::NonDecimalFloat(base) => { match base { - 16 => sess.emit_err(HexadecimalFloatLiteralNotSupported { span }), - 8 => sess.emit_err(OctalFloatLiteralNotSupported { span }), - 2 => sess.emit_err(BinaryFloatLiteralNotSupported { span }), + 16 => dcx.emit_err(HexadecimalFloatLiteralNotSupported { span }), + 8 => dcx.emit_err(OctalFloatLiteralNotSupported { span }), + 2 => dcx.emit_err(BinaryFloatLiteralNotSupported { span }), _ => unreachable!(), }; } @@ -411,13 +412,13 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span: 16 => format!("{max:#x}"), _ => format!("{max}"), }; - sess.emit_err(IntLiteralTooLarge { span, limit }); + dcx.emit_err(IntLiteralTooLarge { span, limit }); } LitError::NulInCStr(range) => { let lo = BytePos(span.lo().0 + range.start as u32 + 2); let hi = BytePos(span.lo().0 + range.end as u32 + 2); let span = span.with_lo(lo).with_hi(hi); - sess.emit_err(NulInCStr { span }); + dcx.emit_err(NulInCStr { span }); } } } |
