1
Fork 0

dont use a query for lit_to_constant

This commit is contained in:
b-naber 2022-03-23 19:41:35 +01:00
parent 1b5fbe2076
commit 19041d995d
5 changed files with 9 additions and 18 deletions

View file

@ -31,17 +31,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this.as_constant(&this.thir[value])
}
ExprKind::Literal { lit, neg } => {
let literal = match tcx.at(expr.span).lit_to_constant(LitToConstInput {
lit: &lit.node,
ty,
neg,
}) {
Ok(c) => c,
Err(LitToConstError::Reported) => ConstantKind::Ty(tcx.const_error(ty)),
Err(LitToConstError::TypeError) => {
bug!("encountered type error in `lit_to_constant")
}
};
let literal =
match lit_to_constant(tcx, LitToConstInput { lit: &lit.node, ty, neg }) {
Ok(c) => c,
Err(LitToConstError::Reported) => ConstantKind::Ty(tcx.const_error(ty)),
Err(LitToConstError::TypeError) => {
bug!("encountered type error in `lit_to_constant")
}
};
Constant { span, user_ty: None, literal: literal.into() }
}