Skip to content

Commit 19041d9

Browse files
committed
dont use a query for lit_to_constant
1 parent 1b5fbe2 commit 19041d9

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

compiler/rustc_middle/src/query/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -962,10 +962,6 @@ rustc_queries! {
962962
desc { "converting literal to const" }
963963
}
964964

965-
query lit_to_constant(key: LitToConstInput<'tcx>) -> Result<mir::ConstantKind<'tcx>, LitToConstError> {
966-
desc { "converting literal to mir constant"}
967-
}
968-
969965
query check_match(key: DefId) {
970966
desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
971967
cache_on_disk_if { key.is_local() }

compiler/rustc_mir_build/src/build/expr/as_constant.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3131
this.as_constant(&this.thir[value])
3232
}
3333
ExprKind::Literal { lit, neg } => {
34-
let literal = match tcx.at(expr.span).lit_to_constant(LitToConstInput {
35-
lit: &lit.node,
36-
ty,
37-
neg,
38-
}) {
39-
Ok(c) => c,
40-
Err(LitToConstError::Reported) => ConstantKind::Ty(tcx.const_error(ty)),
41-
Err(LitToConstError::TypeError) => {
42-
bug!("encountered type error in `lit_to_constant")
43-
}
44-
};
34+
let literal =
35+
match lit_to_constant(tcx, LitToConstInput { lit: &lit.node, ty, neg }) {
36+
Ok(c) => c,
37+
Err(LitToConstError::Reported) => ConstantKind::Ty(tcx.const_error(ty)),
38+
Err(LitToConstError::TypeError) => {
39+
bug!("encountered type error in `lit_to_constant")
40+
}
41+
};
4542

4643
Constant { span, user_ty: None, literal: literal.into() }
4744
}

compiler/rustc_mir_build/src/build/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1078,5 +1078,4 @@ mod matches;
10781078
mod misc;
10791079
mod scope;
10801080

1081-
crate use expr::as_constant;
10821081
pub(crate) use expr::category::Category as ExprCategory;

compiler/rustc_mir_build/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use rustc_middle::ty::query::Providers;
2727
pub fn provide(providers: &mut Providers) {
2828
providers.check_match = thir::pattern::check_match;
2929
providers.lit_to_const = thir::constant::lit_to_const;
30-
providers.lit_to_constant = build::as_constant::lit_to_constant;
3130
providers.mir_built = build::mir_built;
3231
providers.thir_check_unsafety = check_unsafety::thir_check_unsafety;
3332
providers.thir_check_unsafety_for_const_arg = check_unsafety::thir_check_unsafety_for_const_arg;

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
442442
self.tcx.const_error(node.ty)
443443
}
444444
Err(LitToConstError::TypeError) => {
445-
bug!("encountered type error in lit_to_constant")
445+
bug!("encountered type error in lit_to_const")
446446
}
447447
};
448448

0 commit comments

Comments
 (0)