dont use a query for lit_to_constant
This commit is contained in:
@@ -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() }
|
||||
}
|
||||
|
||||
@@ -1078,5 +1078,4 @@ mod matches;
|
||||
mod misc;
|
||||
mod scope;
|
||||
|
||||
crate use expr::as_constant;
|
||||
pub(crate) use expr::category::Category as ExprCategory;
|
||||
|
||||
Reference in New Issue
Block a user