From 5f40fe96a42d3590b804264c029fb02d0a4b065c Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Tue, 11 Feb 2020 12:13:03 -0800 Subject: [PATCH] Clarify why you shouldn't override `Analysis::into_engine` --- src/librustc_mir/dataflow/generic/mod.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/librustc_mir/dataflow/generic/mod.rs b/src/librustc_mir/dataflow/generic/mod.rs index d961ba7fffa25..ea643042c5f86 100644 --- a/src/librustc_mir/dataflow/generic/mod.rs +++ b/src/librustc_mir/dataflow/generic/mod.rs @@ -172,10 +172,18 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> { return_place: &mir::Place<'tcx>, ); - /// Creates an `Engine` to find the fixpoint for this dataflow problem. + /// Calls the appropriate `Engine` constructor to find the fixpoint for this dataflow problem. /// - /// This is functionally equivalent to calling the appropriate `Engine` constructor. It should - /// not be overridden. Its purpose is to allow consumers of this API to use method-chaining. + /// You shouldn't need to override this outside this module, since the combination of the + /// default impl and the one for all `A: GenKillAnalysis` will do the right thing. + /// Its purpose is to enable method chaining like so: + /// + /// ```ignore(cross-crate-imports) + /// let results = MyAnalysis::new(tcx, body) + /// .into_engine(tcx, body, def_id) + /// .iterate_to_fixpoint() + /// .into_results_cursor(body); + /// ``` fn into_engine( self, tcx: TyCtxt<'tcx>,