@@ -69,8 +69,7 @@ impl<'tcx> MirPass<'tcx> for PromoteTemps<'tcx> {
6969
7070 let ( temps, all_candidates) = collect_temps_and_candidates ( & ccx, & mut rpo) ;
7171
72- let promotable_candidates =
73- validate_candidates ( tcx, read_only_body, def_id, & temps, & all_candidates) ;
72+ let promotable_candidates = validate_candidates ( & ccx, & temps, & all_candidates) ;
7473
7574 let promoted = promote_candidates ( def_id, body, tcx, temps, promotable_candidates) ;
7675 self . promoted_fragments . set ( promoted) ;
@@ -267,7 +266,7 @@ pub fn collect_temps_and_candidates(
267266///
268267/// This wraps an `Item`, and has access to all fields of that `Item` via `Deref` coercion.
269268struct Validator < ' a , ' tcx > {
270- ccx : ConstCx < ' a , ' tcx > ,
269+ ccx : & ' a ConstCx < ' a , ' tcx > ,
271270 temps : & ' a IndexVec < Local , TempState > ,
272271
273272 /// Explicit promotion happens e.g. for constant arguments declared via
@@ -720,13 +719,11 @@ impl<'tcx> Validator<'_, 'tcx> {
720719
721720// FIXME(eddyb) remove the differences for promotability in `static`, `const`, `const fn`.
722721pub fn validate_candidates (
723- tcx : TyCtxt < ' tcx > ,
724- body : ReadOnlyBodyAndCache < ' _ , ' tcx > ,
725- def_id : DefId ,
722+ ccx : & ConstCx < ' _ , ' _ > ,
726723 temps : & IndexVec < Local , TempState > ,
727724 candidates : & [ Candidate ] ,
728725) -> Vec < Candidate > {
729- let mut validator = Validator { ccx : ConstCx :: new ( tcx , def_id , body ) , temps, explicit : false } ;
726+ let mut validator = Validator { ccx, temps, explicit : false } ;
730727
731728 candidates
732729 . iter ( )
@@ -740,9 +737,9 @@ pub fn validate_candidates(
740737 let is_promotable = validator. validate_candidate ( candidate) . is_ok ( ) ;
741738 match candidate {
742739 Candidate :: Argument { bb, index } if !is_promotable => {
743- let span = body[ bb] . terminator ( ) . source_info . span ;
740+ let span = ccx . body [ bb] . terminator ( ) . source_info . span ;
744741 let msg = format ! ( "argument {} is required to be a constant" , index + 1 ) ;
745- tcx. sess . span_err ( span, & msg) ;
742+ ccx . tcx . sess . span_err ( span, & msg) ;
746743 }
747744 _ => ( ) ,
748745 }
@@ -1155,7 +1152,7 @@ pub fn promote_candidates<'tcx>(
11551152/// Feature attribute should be suggested if `operand` can be promoted and the feature is not
11561153/// enabled.
11571154crate fn should_suggest_const_in_array_repeat_expressions_attribute < ' tcx > (
1158- ccx : ConstCx < ' _ , ' tcx > ,
1155+ ccx : & ConstCx < ' _ , ' tcx > ,
11591156 operand : & Operand < ' tcx > ,
11601157) -> bool {
11611158 let mut rpo = traversal:: reverse_postorder ( & ccx. body ) ;
0 commit comments