From 2205c19cca60c470d58492313cfde4b1b9cfbcfa Mon Sep 17 00:00:00 2001 From: gavinleroy Date: Fri, 19 Jan 2024 14:27:48 +0100 Subject: [PATCH] Specify usability of inspect_typeck in comment. --- compiler/rustc_hir_typeck/src/lib.rs | 2 ++ compiler/rustc_trait_selection/src/solve/fulfill.rs | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index f7d198c8bd47f..80467ca9381e3 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -155,6 +155,8 @@ fn diagnostic_only_typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::T /// Same as `typeck` but `inspect` is invoked on evaluation of each root obligation. /// Inspecting obligations only works with the new trait solver. +/// This function is *only to be used* by external tools, it should not be +/// called from within rustc. Note, this is not a query, and thus is not cached. pub fn inspect_typeck<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index ee07f453b9549..f08622816ec28 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -72,8 +72,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> { } fn collect_remaining_errors(&mut self, infcx: &InferCtxt<'tcx>) -> Vec> { - let errors = self - .obligations + self.obligations .drain(..) .map(|obligation| { let code = infcx.probe(|_| { @@ -102,9 +101,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> { root_obligation: obligation, } }) - .collect(); - - errors + .collect() } fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec> {