From 63522835f768862163248ea9942ccb959eadf318 Mon Sep 17 00:00:00 2001 From: gavinleroy Date: Thu, 18 Jan 2024 11:24:28 +0100 Subject: [PATCH] Remove unstable flag --- compiler/rustc_hir_typeck/src/lib.rs | 2 ++ compiler/rustc_infer/src/infer/mod.rs | 1 + compiler/rustc_session/src/options.rs | 3 -- .../src/solve/fulfill.rs | 4 +-- tests/ui/traits/track_trait_obligations.rs | 32 ------------------- 5 files changed, 5 insertions(+), 37 deletions(-) delete mode 100644 tests/ui/traits/track_trait_obligations.rs diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 81f5e505f76c3..f7d198c8bd47f 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -153,6 +153,8 @@ fn diagnostic_only_typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::T typeck_with_fallback(tcx, def_id, fallback, None) } +/// Same as `typeck` but `inspect` is invoked on evaluation of each root obligation. +/// Inspecting obligations only works with the new trait solver. pub fn inspect_typeck<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index f5d03ad1cccc3..39c41a93c3bd1 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1730,6 +1730,7 @@ impl<'tcx> InferCtxt<'tcx> { } } + /// Attach a callback to be invoked on each root obligation evaluated in the new trait solver. pub fn attach_obligation_inspector(&self, inspector: ObligationInspector<'tcx>) { debug_assert!( self.obligation_inspector.get().is_none(), diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index f14e288beb6b4..f4bf79f93f287 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1914,9 +1914,6 @@ written to standard error output)"), "for every macro invocation, print its name and arguments (default: no)"), track_diagnostics: bool = (false, parse_bool, [UNTRACKED], "tracks where in rustc a diagnostic was emitted"), - track_trait_obligations: bool = (false, parse_bool, [TRACKED], - "tracks evaluated obligations while trait solving, option is only \ - valid when -Z next-solver=globally (default: no)"), // Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved // alongside query results and changes to translation options can affect diagnostics - so // translation options should be tracked. diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index df4f14350fb62..ee07f453b9549 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -44,7 +44,7 @@ impl<'tcx> FulfillmentCtxt<'tcx> { FulfillmentCtxt { obligations: Vec::new(), usable_in_snapshot: infcx.num_open_snapshots() } } - fn track_evaluated_obligation( + fn inspect_evaluated_obligation( &self, infcx: &InferCtxt<'tcx>, obligation: &PredicateObligation<'tcx>, @@ -119,7 +119,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> { for obligation in mem::take(&mut self.obligations) { let goal = obligation.clone().into(); let result = infcx.evaluate_root_goal(goal, GenerateProofTree::IfEnabled).0; - self.track_evaluated_obligation(infcx, &obligation, &result); + self.inspect_evaluated_obligation(infcx, &obligation, &result); let (changed, certainty, nested_goals) = match result { Ok(result) => result, Err(NoSolution) => { diff --git a/tests/ui/traits/track_trait_obligations.rs b/tests/ui/traits/track_trait_obligations.rs deleted file mode 100644 index 92add912fe0c2..0000000000000 --- a/tests/ui/traits/track_trait_obligations.rs +++ /dev/null @@ -1,32 +0,0 @@ -// compile-flags: -Ztrack-trait-obligations -// run-pass - -// Just making sure this flag is accepted and doesn't crash the compiler -use traits::IntoString; - -fn does_impl_into_string(_: T) {} - -fn main() { - let v = vec![(0, 1), (2, 3)]; - - does_impl_into_string(v); -} - -mod traits { - pub trait IntoString { - fn to_string(&self) -> String; - } - - impl IntoString for (i32, i32) { - fn to_string(&self) -> String { - format!("({}, {})", self.0, self.1) - } - } - - impl IntoString for Vec { - fn to_string(&self) -> String { - let s = self.iter().map(|v| v.to_string()).collect::>().join(", "); - format!("[{s}]") - } - } -}