Skip to content

Commit 4314adc

Browse files
committed
Auto merge of #141875 - nnethercote:ByteSymbol, r=<try>
Introduce `ByteSymbol` It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings.
2 parents 8f21a5c + 900a994 commit 4314adc

File tree

45 files changed

+312
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+312
-198
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_data_structures::tagged_ptr::Tag;
3232
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
3333
pub use rustc_span::AttrId;
3434
use rustc_span::source_map::{Spanned, respan};
35-
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
35+
use rustc_span::{ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
3636
use thin_vec::{ThinVec, thin_vec};
3737

3838
pub use crate::format::*;
@@ -1807,7 +1807,8 @@ pub enum ExprKind {
18071807
/// Bytes included via `include_bytes!`
18081808
/// Added for optimization purposes to avoid the need to escape
18091809
/// large binary blobs - should always behave like [`ExprKind::Lit`]
1810-
/// with a `ByteStr` literal.
1810+
/// with a `ByteStr` literal. Not stored as a `ByteSymbol` because
1811+
/// there is no point; these byte strings are very likely to be unique.
18111812
IncludedBytes(Arc<[u8]>),
18121813

18131814
/// A `format_args!()` expression.
@@ -2066,7 +2067,7 @@ impl YieldKind {
20662067
}
20672068

20682069
/// A literal in a meta item.
2069-
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
2070+
#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic)]
20702071
pub struct MetaItemLit {
20712072
/// The original literal as written in the source code.
20722073
pub symbol: Symbol,
@@ -2129,16 +2130,16 @@ pub enum LitFloatType {
21292130
/// deciding the `LitKind`. This means that float literals like `1f32` are
21302131
/// classified by this type as `Float`. This is different to `token::LitKind`
21312132
/// which does *not* consider the suffix.
2132-
#[derive(Clone, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable_Generic)]
2133+
#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable_Generic)]
21332134
pub enum LitKind {
21342135
/// A string literal (`"foo"`). The symbol is unescaped, and so may differ
21352136
/// from the original token's symbol.
21362137
Str(Symbol, StrStyle),
21372138
/// A byte string (`b"foo"`). Not stored as a symbol because it might be
21382139
/// non-utf8, and symbols only allow utf8 strings.
2139-
ByteStr(Arc<[u8]>, StrStyle),
2140+
ByteStr(ByteSymbol, StrStyle),
21402141
/// A C String (`c"foo"`). Guaranteed to only have `\0` at the end.
2141-
CStr(Arc<[u8]>, StrStyle),
2142+
CStr(ByteSymbol, StrStyle),
21422143
/// A byte char (`b'f'`).
21432144
Byte(u8),
21442145
/// A character literal (`'a'`).

compiler/rustc_ast/src/util/literal.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{ascii, fmt, str};
55
use rustc_literal_escaper::{
66
MixedUnit, unescape_byte, unescape_byte_str, unescape_c_str, unescape_char, unescape_str,
77
};
8-
use rustc_span::{Span, Symbol, kw, sym};
8+
use rustc_span::{ByteSymbol, Span, Symbol, kw, sym};
99
use tracing::debug;
1010

1111
use crate::ast::{self, LitKind, MetaItemLit, StrStyle};
@@ -116,13 +116,13 @@ impl LitKind {
116116
assert!(!err.is_fatal(), "failed to unescape string literal")
117117
}
118118
});
119-
LitKind::ByteStr(buf.into(), StrStyle::Cooked)
119+
LitKind::ByteStr(ByteSymbol::intern(&buf), StrStyle::Cooked)
120120
}
121121
token::ByteStrRaw(n) => {
122122
// Raw strings have no escapes so we can convert the symbol
123123
// directly to a `Arc<u8>`.
124124
let buf = symbol.as_str().to_owned().into_bytes();
125-
LitKind::ByteStr(buf.into(), StrStyle::Raw(n))
125+
LitKind::ByteStr(ByteSymbol::intern(&buf), StrStyle::Raw(n))
126126
}
127127
token::CStr => {
128128
let s = symbol.as_str();
@@ -137,15 +137,15 @@ impl LitKind {
137137
}
138138
});
139139
buf.push(0);
140-
LitKind::CStr(buf.into(), StrStyle::Cooked)
140+
LitKind::CStr(ByteSymbol::intern(&buf), StrStyle::Cooked)
141141
}
142142
token::CStrRaw(n) => {
143143
// Raw strings have no escapes so we can convert the symbol
144144
// directly to a `Arc<u8>` after appending the terminating NUL
145145
// char.
146146
let mut buf = symbol.as_str().to_owned().into_bytes();
147147
buf.push(0);
148-
LitKind::CStr(buf.into(), StrStyle::Raw(n))
148+
LitKind::CStr(ByteSymbol::intern(&buf), StrStyle::Raw(n))
149149
}
150150
token::Err(guar) => LitKind::Err(guar),
151151
})
@@ -167,12 +167,12 @@ impl fmt::Display for LitKind {
167167
delim = "#".repeat(n as usize),
168168
string = sym
169169
)?,
170-
LitKind::ByteStr(ref bytes, StrStyle::Cooked) => {
171-
write!(f, "b\"{}\"", escape_byte_str_symbol(bytes))?
170+
LitKind::ByteStr(ref byte_sym, StrStyle::Cooked) => {
171+
write!(f, "b\"{}\"", escape_byte_str_symbol(byte_sym.as_byte_str()))?
172172
}
173-
LitKind::ByteStr(ref bytes, StrStyle::Raw(n)) => {
173+
LitKind::ByteStr(ref byte_sym, StrStyle::Raw(n)) => {
174174
// Unwrap because raw byte string literals can only contain ASCII.
175-
let symbol = str::from_utf8(bytes).unwrap();
175+
let symbol = str::from_utf8(byte_sym.as_byte_str()).unwrap();
176176
write!(
177177
f,
178178
"br{delim}\"{string}\"{delim}",
@@ -181,11 +181,11 @@ impl fmt::Display for LitKind {
181181
)?;
182182
}
183183
LitKind::CStr(ref bytes, StrStyle::Cooked) => {
184-
write!(f, "c\"{}\"", escape_byte_str_symbol(bytes))?
184+
write!(f, "c\"{}\"", escape_byte_str_symbol(bytes.as_byte_str()))?
185185
}
186186
LitKind::CStr(ref bytes, StrStyle::Raw(n)) => {
187187
// This can only be valid UTF-8.
188-
let symbol = str::from_utf8(bytes).unwrap();
188+
let symbol = str::from_utf8(bytes.as_byte_str()).unwrap();
189189
write!(f, "cr{delim}\"{symbol}\"{delim}", delim = "#".repeat(n as usize),)?;
190190
}
191191
LitKind::Int(n, ty) => {

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_middle::span_bug;
1313
use rustc_middle::ty::TyCtxt;
1414
use rustc_session::errors::report_lit_error;
1515
use rustc_span::source_map::{Spanned, respan};
16-
use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
16+
use rustc_span::{ByteSymbol, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
1717
use thin_vec::{ThinVec, thin_vec};
1818
use visit::{Visitor, walk_expr};
1919

@@ -145,10 +145,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
145145
}
146146
ExprKind::Lit(token_lit) => hir::ExprKind::Lit(self.lower_lit(token_lit, e.span)),
147147
ExprKind::IncludedBytes(bytes) => {
148-
let lit = self.arena.alloc(respan(
148+
let lit = respan(
149149
self.lower_span(e.span),
150-
LitKind::ByteStr(Arc::clone(bytes), StrStyle::Cooked),
151-
));
150+
LitKind::ByteStr(ByteSymbol::intern(&bytes), StrStyle::Cooked),
151+
);
152152
hir::ExprKind::Lit(lit)
153153
}
154154
ExprKind::Cast(expr, ty) => {
@@ -421,19 +421,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
421421
})
422422
}
423423

424-
pub(crate) fn lower_lit(
425-
&mut self,
426-
token_lit: &token::Lit,
427-
span: Span,
428-
) -> &'hir Spanned<LitKind> {
424+
pub(crate) fn lower_lit(&mut self, token_lit: &token::Lit, span: Span) -> hir::Lit {
429425
let lit_kind = match LitKind::from_token_lit(*token_lit) {
430426
Ok(lit_kind) => lit_kind,
431427
Err(err) => {
432428
let guar = report_lit_error(&self.tcx.sess.psess, err, *token_lit, span);
433429
LitKind::Err(guar)
434430
}
435431
};
436-
self.arena.alloc(respan(self.lower_span(span), lit_kind))
432+
respan(self.lower_span(span), lit_kind)
437433
}
438434

439435
fn lower_unop(&mut self, u: UnOp) -> hir::UnOp {
@@ -2141,10 +2137,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
21412137
}
21422138

21432139
fn expr_uint(&mut self, sp: Span, ty: ast::UintTy, value: u128) -> hir::Expr<'hir> {
2144-
let lit = self.arena.alloc(hir::Lit {
2140+
let lit = hir::Lit {
21452141
span: sp,
21462142
node: ast::LitKind::Int(value.into(), ast::LitIntType::Unsigned(ty)),
2147-
});
2143+
};
21482144
self.expr(sp, hir::ExprKind::Lit(lit))
21492145
}
21502146

@@ -2161,9 +2157,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21612157
}
21622158

21632159
pub(super) fn expr_str(&mut self, sp: Span, value: Symbol) -> hir::Expr<'hir> {
2164-
let lit = self
2165-
.arena
2166-
.alloc(hir::Lit { span: sp, node: ast::LitKind::Str(value, ast::StrStyle::Cooked) });
2160+
let lit = hir::Lit { span: sp, node: ast::LitKind::Str(value, ast::StrStyle::Cooked) };
21672161
self.expr(sp, hir::ExprKind::Lit(lit))
21682162
}
21692163

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::def::{DefKind, Res};
77
use rustc_hir::{self as hir, LangItem};
88
use rustc_middle::span_bug;
99
use rustc_span::source_map::{Spanned, respan};
10-
use rustc_span::{DesugaringKind, Ident, Span};
10+
use rustc_span::{ByteSymbol, DesugaringKind, Ident, Span};
1111

1212
use super::errors::{
1313
ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,
@@ -390,19 +390,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
390390
allow_paths: bool,
391391
) -> &'hir hir::PatExpr<'hir> {
392392
let span = self.lower_span(expr.span);
393-
let err = |guar| hir::PatExprKind::Lit {
394-
lit: self.arena.alloc(respan(span, LitKind::Err(guar))),
395-
negated: false,
396-
};
393+
let err =
394+
|guar| hir::PatExprKind::Lit { lit: respan(span, LitKind::Err(guar)), negated: false };
397395
let kind = match &expr.kind {
398396
ExprKind::Lit(lit) => {
399397
hir::PatExprKind::Lit { lit: self.lower_lit(lit, span), negated: false }
400398
}
401399
ExprKind::ConstBlock(c) => hir::PatExprKind::ConstBlock(self.lower_const_block(c)),
402400
ExprKind::IncludedBytes(bytes) => hir::PatExprKind::Lit {
403-
lit: self
404-
.arena
405-
.alloc(respan(span, LitKind::ByteStr(Arc::clone(bytes), StrStyle::Cooked))),
401+
lit: respan(span, LitKind::ByteStr(ByteSymbol::intern(bytes), StrStyle::Cooked)),
406402
negated: false,
407403
},
408404
ExprKind::Err(guar) => err(*guar),

compiler/rustc_builtin_macros/src/concat_bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ pub(crate) fn expand_concat_bytes(
177177
Ok(LitKind::Byte(val)) => {
178178
accumulator.push(val);
179179
}
180-
Ok(LitKind::ByteStr(ref bytes, _)) => {
181-
accumulator.extend_from_slice(bytes);
180+
Ok(LitKind::ByteStr(ref byte_sym, _)) => {
181+
accumulator.extend_from_slice(byte_sym.as_byte_str());
182182
}
183183
_ => {
184184
guar.get_or_insert_with(|| invalid_type_err(cx, token_lit, e.span, false));

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl CodegenResults {
310310
// `emit_raw_bytes` is used to make sure that the version representation does not depend on
311311
// Encoder's inner representation of `u32`.
312312
encoder.emit_raw_bytes(&RLINK_VERSION.to_be_bytes());
313-
encoder.emit_str(sess.cfg_version);
313+
encoder.emit_byte_str(sess.cfg_version.as_bytes());
314314
Encodable::encode(codegen_results, &mut encoder);
315315
Encodable::encode(metadata, &mut encoder);
316316
Encodable::encode(outputs, &mut encoder);

compiler/rustc_hir/src/arena.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ macro_rules! arena_types {
88
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
99
[] attribute: rustc_hir::Attribute,
1010
[] owner_info: rustc_hir::OwnerInfo<'tcx>,
11-
[] lit: rustc_hir::Lit,
1211
[] macro_def: rustc_ast::MacroDef,
1312
]);
1413
)

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ pub struct PatExpr<'hir> {
18071807
#[derive(Debug, Clone, Copy, HashStable_Generic)]
18081808
pub enum PatExprKind<'hir> {
18091809
Lit {
1810-
lit: &'hir Lit,
1810+
lit: Lit,
18111811
// FIXME: move this into `Lit` and handle negated literal expressions
18121812
// once instead of matching on unop neg expressions everywhere.
18131813
negated: bool,
@@ -2734,7 +2734,7 @@ pub enum ExprKind<'hir> {
27342734
/// A unary operation (e.g., `!x`, `*x`).
27352735
Unary(UnOp, &'hir Expr<'hir>),
27362736
/// A literal (e.g., `1`, `"foo"`).
2737-
Lit(&'hir Lit),
2737+
Lit(Lit),
27382738
/// A cast (e.g., `foo as f64`).
27392739
Cast(&'hir Expr<'hir>, &'hir Ty<'hir>),
27402740
/// A type ascription (e.g., `x: Foo`). See RFC 3307.

compiler/rustc_hir/src/intravisit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub trait Visitor<'v>: Sized {
347347
fn visit_pat_expr(&mut self, expr: &'v PatExpr<'v>) -> Self::Result {
348348
walk_pat_expr(self, expr)
349349
}
350-
fn visit_lit(&mut self, _hir_id: HirId, _lit: &'v Lit, _negated: bool) -> Self::Result {
350+
fn visit_lit(&mut self, _hir_id: HirId, _lit: Lit, _negated: bool) -> Self::Result {
351351
Self::Result::output()
352352
}
353353
fn visit_anon_const(&mut self, c: &'v AnonConst) -> Self::Result {
@@ -786,7 +786,7 @@ pub fn walk_pat_expr<'v, V: Visitor<'v>>(visitor: &mut V, expr: &'v PatExpr<'v>)
786786
let PatExpr { hir_id, span, kind } = expr;
787787
try_visit!(visitor.visit_id(*hir_id));
788788
match kind {
789-
PatExprKind::Lit { lit, negated } => visitor.visit_lit(*hir_id, lit, *negated),
789+
PatExprKind::Lit { lit, negated } => visitor.visit_lit(*hir_id, *lit, *negated),
790790
PatExprKind::ConstBlock(c) => visitor.visit_inline_const(c),
791791
PatExprKind::Path(qpath) => visitor.visit_qpath(qpath, *hir_id, *span),
792792
}

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,9 +2364,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23642364
};
23652365

23662366
let lit_input = match expr.kind {
2367-
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }),
2367+
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: lit.node, ty, neg: false }),
23682368
hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind {
2369-
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: true }),
2369+
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: lit.node, ty, neg: true }),
23702370
_ => None,
23712371
},
23722372
_ => None,

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ impl<'a> State<'a> {
14801480
self.print_expr_addr_of(k, m, expr);
14811481
}
14821482
hir::ExprKind::Lit(lit) => {
1483-
self.print_literal(lit);
1483+
self.print_literal(&lit);
14841484
}
14851485
hir::ExprKind::Cast(expr, ty) => {
14861486
self.print_expr_cond_paren(expr, self.precedence(expr) < ExprPrecedence::Cast);

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16341634
ast::LitKind::ByteStr(ref v, _) => Ty::new_imm_ref(
16351635
tcx,
16361636
tcx.lifetimes.re_static,
1637-
Ty::new_array(tcx, tcx.types.u8, v.len() as u64),
1637+
Ty::new_array(tcx, tcx.types.u8, v.as_byte_str().len() as u64),
16381638
),
16391639
ast::LitKind::Byte(_) => tcx.types.u8,
16401640
ast::LitKind::Char(_) => tcx.types.char,

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16241624
node: rustc_ast::LitKind::Int(lit, rustc_ast::LitIntType::Unsuffixed),
16251625
span,
16261626
}) => {
1627-
let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(*span) else {
1627+
let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) else {
16281628
return false;
16291629
};
16301630
if !(snippet.starts_with("0x") || snippet.starts_with("0X")) {
@@ -1683,7 +1683,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16831683

16841684
// We have satisfied all requirements to provide a suggestion. Emit it.
16851685
err.span_suggestion(
1686-
*span,
1686+
span,
16871687
format!("if you meant to create a null pointer, use `{null_path_str}()`"),
16881688
null_path_str + "()",
16891689
Applicability::MachineApplicable,

compiler/rustc_lint/src/invalid_from_utf8.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ impl<'tcx> LateLintPass<'tcx> for InvalidFromUtf8 {
108108
}
109109
match init.kind {
110110
ExprKind::Lit(Spanned { node: lit, .. }) => {
111-
if let LitKind::ByteStr(bytes, _) = &lit
112-
&& let Err(utf8_error) = std::str::from_utf8(bytes)
111+
if let LitKind::ByteStr(byte_sym, _) = &lit
112+
&& let Err(utf8_error) = std::str::from_utf8(byte_sym.as_byte_str())
113113
{
114114
lint(init.span, utf8_error);
115115
}

compiler/rustc_lint/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
152152
hir_visit::walk_pat(self, p);
153153
}
154154

155-
fn visit_lit(&mut self, hir_id: HirId, lit: &'tcx hir::Lit, negated: bool) {
155+
fn visit_lit(&mut self, hir_id: HirId, lit: hir::Lit, negated: bool) {
156156
lint_callback!(self, check_lit, hir_id, lit, negated);
157157
}
158158

compiler/rustc_lint/src/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ macro_rules! late_lint_methods {
2323
fn check_stmt(a: &'tcx rustc_hir::Stmt<'tcx>);
2424
fn check_arm(a: &'tcx rustc_hir::Arm<'tcx>);
2525
fn check_pat(a: &'tcx rustc_hir::Pat<'tcx>);
26-
fn check_lit(hir_id: rustc_hir::HirId, a: &'tcx rustc_hir::Lit, negated: bool);
26+
fn check_lit(hir_id: rustc_hir::HirId, a: rustc_hir::Lit, negated: bool);
2727
fn check_expr(a: &'tcx rustc_hir::Expr<'tcx>);
2828
fn check_expr_post(a: &'tcx rustc_hir::Expr<'tcx>);
2929
fn check_ty(a: &'tcx rustc_hir::Ty<'tcx, rustc_hir::AmbigArg>);

compiler/rustc_lint/src/types.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -547,18 +547,12 @@ fn lint_fn_pointer<'tcx>(
547547
}
548548

549549
impl<'tcx> LateLintPass<'tcx> for TypeLimits {
550-
fn check_lit(
551-
&mut self,
552-
cx: &LateContext<'tcx>,
553-
hir_id: HirId,
554-
lit: &'tcx hir::Lit,
555-
negated: bool,
556-
) {
550+
fn check_lit(&mut self, cx: &LateContext<'tcx>, hir_id: HirId, lit: hir::Lit, negated: bool) {
557551
if negated {
558552
self.negated_expr_id = Some(hir_id);
559553
self.negated_expr_span = Some(lit.span);
560554
}
561-
lint_literal(cx, self, hir_id, lit.span, lit, negated);
555+
lint_literal(cx, self, hir_id, lit.span, &lit, negated);
562556
}
563557

564558
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) {

0 commit comments

Comments
 (0)