dont use a query for lit_to_constant
This commit is contained in:
parent
1b5fbe2076
commit
19041d995d
5 changed files with 9 additions and 18 deletions
|
@ -962,10 +962,6 @@ rustc_queries! {
|
||||||
desc { "converting literal to const" }
|
desc { "converting literal to const" }
|
||||||
}
|
}
|
||||||
|
|
||||||
query lit_to_constant(key: LitToConstInput<'tcx>) -> Result<mir::ConstantKind<'tcx>, LitToConstError> {
|
|
||||||
desc { "converting literal to mir constant"}
|
|
||||||
}
|
|
||||||
|
|
||||||
query check_match(key: DefId) {
|
query check_match(key: DefId) {
|
||||||
desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
|
desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
|
||||||
cache_on_disk_if { key.is_local() }
|
cache_on_disk_if { key.is_local() }
|
||||||
|
|
|
@ -31,11 +31,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
this.as_constant(&this.thir[value])
|
this.as_constant(&this.thir[value])
|
||||||
}
|
}
|
||||||
ExprKind::Literal { lit, neg } => {
|
ExprKind::Literal { lit, neg } => {
|
||||||
let literal = match tcx.at(expr.span).lit_to_constant(LitToConstInput {
|
let literal =
|
||||||
lit: &lit.node,
|
match lit_to_constant(tcx, LitToConstInput { lit: &lit.node, ty, neg }) {
|
||||||
ty,
|
|
||||||
neg,
|
|
||||||
}) {
|
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(LitToConstError::Reported) => ConstantKind::Ty(tcx.const_error(ty)),
|
Err(LitToConstError::Reported) => ConstantKind::Ty(tcx.const_error(ty)),
|
||||||
Err(LitToConstError::TypeError) => {
|
Err(LitToConstError::TypeError) => {
|
||||||
|
|
|
@ -1078,5 +1078,4 @@ mod matches;
|
||||||
mod misc;
|
mod misc;
|
||||||
mod scope;
|
mod scope;
|
||||||
|
|
||||||
crate use expr::as_constant;
|
|
||||||
pub(crate) use expr::category::Category as ExprCategory;
|
pub(crate) use expr::category::Category as ExprCategory;
|
||||||
|
|
|
@ -27,7 +27,6 @@ use rustc_middle::ty::query::Providers;
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
providers.check_match = thir::pattern::check_match;
|
providers.check_match = thir::pattern::check_match;
|
||||||
providers.lit_to_const = thir::constant::lit_to_const;
|
providers.lit_to_const = thir::constant::lit_to_const;
|
||||||
providers.lit_to_constant = build::as_constant::lit_to_constant;
|
|
||||||
providers.mir_built = build::mir_built;
|
providers.mir_built = build::mir_built;
|
||||||
providers.thir_check_unsafety = check_unsafety::thir_check_unsafety;
|
providers.thir_check_unsafety = check_unsafety::thir_check_unsafety;
|
||||||
providers.thir_check_unsafety_for_const_arg = check_unsafety::thir_check_unsafety_for_const_arg;
|
providers.thir_check_unsafety_for_const_arg = check_unsafety::thir_check_unsafety_for_const_arg;
|
||||||
|
|
|
@ -442,7 +442,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
||||||
self.tcx.const_error(node.ty)
|
self.tcx.const_error(node.ty)
|
||||||
}
|
}
|
||||||
Err(LitToConstError::TypeError) => {
|
Err(LitToConstError::TypeError) => {
|
||||||
bug!("encountered type error in lit_to_constant")
|
bug!("encountered type error in lit_to_const")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue