1
1
//! Code shared by trait and projection goals for candidate assembly.
2
2
3
3
use crate :: solve:: GoalSource ;
4
- use crate :: solve:: { inspect , EvalCtxt , SolverMode } ;
4
+ use crate :: solve:: { EvalCtxt , SolverMode } ;
5
5
use rustc_hir:: def_id:: DefId ;
6
6
use rustc_infer:: traits:: query:: NoSolution ;
7
7
use rustc_middle:: traits:: solve:: inspect:: ProbeKind ;
@@ -15,7 +15,6 @@ use rustc_middle::ty::{fast_reject, TypeFoldable};
15
15
use rustc_middle:: ty:: { ToPredicate , TypeVisitableExt } ;
16
16
use rustc_span:: { ErrorGuaranteed , DUMMY_SP } ;
17
17
use std:: fmt:: Debug ;
18
- use std:: mem;
19
18
20
19
pub ( super ) mod structural_traits;
21
20
@@ -791,17 +790,16 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
791
790
goal : Goal < ' tcx , G > ,
792
791
candidates : & mut Vec < Candidate < ' tcx > > ,
793
792
) {
794
- // HACK: We temporarily remove the `ProofTreeBuilder` to
795
- // avoid adding `Trait` candidates to the candidates used
796
- // to prove the current goal.
797
- let inspect = mem:: replace ( & mut self . inspect , inspect:: ProofTreeBuilder :: new_noop ( ) ) ;
798
-
799
793
let tcx = self . tcx ( ) ;
800
794
let trait_goal: Goal < ' tcx , ty:: TraitPredicate < ' tcx > > =
801
795
goal. with ( tcx, goal. predicate . trait_ref ( tcx) ) ;
802
- let mut trait_candidates_from_env = Vec :: new ( ) ;
803
- self . assemble_param_env_candidates ( trait_goal, & mut trait_candidates_from_env) ;
804
- self . assemble_alias_bound_candidates ( trait_goal, & mut trait_candidates_from_env) ;
796
+
797
+ let mut trait_candidates_from_env = vec ! [ ] ;
798
+ self . probe ( |_| ProbeKind :: ShadowedEnvProbing ) . enter ( |ecx| {
799
+ ecx. assemble_param_env_candidates ( trait_goal, & mut trait_candidates_from_env) ;
800
+ ecx. assemble_alias_bound_candidates ( trait_goal, & mut trait_candidates_from_env) ;
801
+ } ) ;
802
+
805
803
if !trait_candidates_from_env. is_empty ( ) {
806
804
let trait_env_result = self . merge_candidates ( trait_candidates_from_env) ;
807
805
match trait_env_result. unwrap ( ) . value . certainty {
@@ -830,7 +828,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
830
828
}
831
829
}
832
830
}
833
- self . inspect = inspect;
834
831
}
835
832
836
833
/// If there are multiple ways to prove a trait or projection goal, we have
0 commit comments