From b76caa1a08cd46f3123dba13568f4a3ab85c11cb Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 13 Sep 2023 15:15:00 +0000 Subject: [PATCH] Expose try_destructure_mir_constant_for_diagnostics directly to clippy Otherwise clippy tries to use the query in ways that incremental caching will inevitably cause problems with. --- compiler/rustc_const_eval/src/const_eval/mod.rs | 2 +- src/tools/clippy/clippy_utils/src/consts.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/mod.rs b/compiler/rustc_const_eval/src/const_eval/mod.rs index ef31155215a1b..854104622f133 100644 --- a/compiler/rustc_const_eval/src/const_eval/mod.rs +++ b/compiler/rustc_const_eval/src/const_eval/mod.rs @@ -85,7 +85,7 @@ pub(crate) fn eval_to_valtree<'tcx>( } #[instrument(skip(tcx), level = "debug")] -pub(crate) fn try_destructure_mir_constant_for_diagnostics<'tcx>( +pub fn try_destructure_mir_constant_for_diagnostics<'tcx>( tcx: TyCtxt<'tcx>, val: ConstValue<'tcx>, ty: Ty<'tcx>, diff --git a/src/tools/clippy/clippy_utils/src/consts.rs b/src/tools/clippy/clippy_utils/src/consts.rs index adeb673b6b9dc..6d57af3250cfb 100644 --- a/src/tools/clippy/clippy_utils/src/consts.rs +++ b/src/tools/clippy/clippy_utils/src/consts.rs @@ -724,7 +724,7 @@ fn field_of_struct<'tcx>( field: &Ident, ) -> Option> { if let mir::ConstantKind::Val(result, ty) = result - && let Some(dc) = lcx.tcx.try_destructure_mir_constant_for_diagnostics((result, ty)) + && let Some(dc) = rustc_const_eval::const_eval::try_destructure_mir_constant_for_diagnostics(lcx.tcx, result, ty) && let Some(dc_variant) = dc.variant && let Some(variant) = adt_def.variants().get(dc_variant) && let Some(field_idx) = variant.fields.iter().position(|el| el.name == field.name)