diff options
Diffstat (limited to 'compiler/rustc_ty_utils/src/consts.rs')
-rw-r--r-- | compiler/rustc_ty_utils/src/consts.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index b08a92570ed..1219bb40098 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -2,6 +2,7 @@ use rustc_errors::ErrorGuaranteed; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput}; +use rustc_middle::query::Providers; use rustc_middle::thir::visit; use rustc_middle::thir::visit::Visitor; use rustc_middle::ty::abstract_const::CastKind; @@ -115,9 +116,7 @@ fn recurse_build<'tcx>( let sp = node.span; match tcx.at(sp).lit_to_const(LitToConstInput { lit: &lit.node, ty: node.ty, neg }) { Ok(c) => c, - Err(LitToConstError::Reported(guar)) => { - tcx.const_error_with_guaranteed(node.ty, guar) - } + Err(LitToConstError::Reported(guar)) => tcx.const_error(node.ty, guar), Err(LitToConstError::TypeError) => { bug!("encountered type error in lit_to_const") } @@ -394,7 +393,7 @@ impl<'a, 'tcx> visit::Visitor<'a, 'tcx> for IsThirPolymorphic<'a, 'tcx> { pub fn thir_abstract_const( tcx: TyCtxt<'_>, def: LocalDefId, -) -> Result<Option<ty::Const<'_>>, ErrorGuaranteed> { +) -> Result<Option<ty::EarlyBinder<ty::Const<'_>>>, ErrorGuaranteed> { if !tcx.features().generic_const_exprs { return Ok(None); } @@ -420,9 +419,9 @@ pub fn thir_abstract_const( let root_span = body.exprs[body_id].span; - Some(recurse_build(tcx, body, body_id, root_span)).transpose() + Ok(Some(ty::EarlyBinder(recurse_build(tcx, body, body_id, root_span)?))) } -pub fn provide(providers: &mut ty::query::Providers) { - *providers = ty::query::Providers { destructure_const, thir_abstract_const, ..*providers }; +pub fn provide(providers: &mut Providers) { + *providers = Providers { destructure_const, thir_abstract_const, ..*providers }; } |