@@ -51,6 +51,29 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
5151 ) -> At < ' a , ' tcx > {
5252 At { infcx : self , cause, param_env }
5353 }
54+
55+ /// Forks the inference context, creating a new inference context with the same inference
56+ /// variables in the same state. This can be used to "branch off" many tests from the same
57+ /// common state. Used in coherence.
58+ pub fn fork ( & self ) -> Self {
59+ Self {
60+ tcx : self . tcx . clone ( ) ,
61+ defining_use_anchor : self . defining_use_anchor . clone ( ) ,
62+ reveal_defining_opaque_types : self . reveal_defining_opaque_types ,
63+ in_progress_typeck_results : self . in_progress_typeck_results . clone ( ) ,
64+ inner : self . inner . clone ( ) ,
65+ skip_leak_check : self . skip_leak_check . clone ( ) ,
66+ lexical_region_resolutions : self . lexical_region_resolutions . clone ( ) ,
67+ selection_cache : self . selection_cache . clone ( ) ,
68+ evaluation_cache : self . evaluation_cache . clone ( ) ,
69+ reported_trait_errors : self . reported_trait_errors . clone ( ) ,
70+ reported_closure_mismatch : self . reported_closure_mismatch . clone ( ) ,
71+ tainted_by_errors_flag : self . tainted_by_errors_flag . clone ( ) ,
72+ err_count_on_creation : self . err_count_on_creation ,
73+ in_snapshot : self . in_snapshot . clone ( ) ,
74+ universe : self . universe . clone ( ) ,
75+ }
76+ }
5477}
5578
5679pub trait ToTrace < ' tcx > : Relate < ' tcx > + Copy {
0 commit comments