Skip to content

Commit 5f40fe9

Browse files
Clarify why you shouldn't override Analysis::into_engine
1 parent 3ac920f commit 5f40fe9

File tree

1 file changed

+11
-3
lines changed
  • src/librustc_mir/dataflow/generic

1 file changed

+11
-3
lines changed

src/librustc_mir/dataflow/generic/mod.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,18 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
172172
return_place: &mir::Place<'tcx>,
173173
);
174174

175-
/// Creates an `Engine` to find the fixpoint for this dataflow problem.
175+
/// Calls the appropriate `Engine` constructor to find the fixpoint for this dataflow problem.
176176
///
177-
/// This is functionally equivalent to calling the appropriate `Engine` constructor. It should
178-
/// not be overridden. Its purpose is to allow consumers of this API to use method-chaining.
177+
/// You shouldn't need to override this outside this module, since the combination of the
178+
/// default impl and the one for all `A: GenKillAnalysis` will do the right thing.
179+
/// Its purpose is to enable method chaining like so:
180+
///
181+
/// ```ignore(cross-crate-imports)
182+
/// let results = MyAnalysis::new(tcx, body)
183+
/// .into_engine(tcx, body, def_id)
184+
/// .iterate_to_fixpoint()
185+
/// .into_results_cursor(body);
186+
/// ```
179187
fn into_engine(
180188
self,
181189
tcx: TyCtxt<'tcx>,

0 commit comments

Comments
 (0)