mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Alloc hir::Lit
in an arena to remove the destructor from Expr
This allows allocating `Expr`s into a dropless arena, which is useful for using length prefixed thing slices in HIR, since these can only be allocated in the dropless arena and not in a typed arena. This is something I'm working on.
This commit is contained in:
parent
d61570ceb6
commit
8f53926232
@ -41,7 +41,7 @@ fn extract_bool_lit(e: &Expr<'_>) -> Option<bool> {
|
||||
}) = e.kind
|
||||
&& !e.span.from_expansion()
|
||||
{
|
||||
Some(b)
|
||||
Some(*b)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ fn eq_pattern_length<'tcx>(cx: &LateContext<'tcx>, pattern: &Expr<'_>, expr: &'t
|
||||
..
|
||||
}) = expr.kind
|
||||
{
|
||||
constant_length(cx, pattern).map_or(false, |length| length == n)
|
||||
constant_length(cx, pattern).map_or(false, |length| length == *n)
|
||||
} else {
|
||||
len_arg(cx, expr).map_or(false, |arg| eq_expr_value(cx, pattern, arg))
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ fn find_bool_lit(ex: &ExprKind<'_>) -> Option<bool> {
|
||||
node: LitKind::Bool(b), ..
|
||||
}) = exp.kind
|
||||
{
|
||||
Some(b)
|
||||
Some(*b)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ fn get_open_options(cx: &LateContext<'_>, argument: &Expr<'_>, options: &mut Vec
|
||||
..
|
||||
} = *span
|
||||
{
|
||||
if lit { Argument::True } else { Argument::False }
|
||||
if *lit { Argument::True } else { Argument::False }
|
||||
} else {
|
||||
// The function is called with a literal which is not a boolean literal.
|
||||
// This is theoretically possible, but not very likely.
|
||||
|
@ -430,7 +430,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
||||
kind!("Unary(UnOp::{op:?}, {inner})");
|
||||
self.expr(inner);
|
||||
},
|
||||
ExprKind::Lit(ref lit) => {
|
||||
ExprKind::Lit(lit) => {
|
||||
bind!(self, lit);
|
||||
kind!("Lit(ref {lit})");
|
||||
self.lit(lit);
|
||||
|
Loading…
Reference in New Issue
Block a user