Avoid some code duplication.

`print_binder` can call `wrap_binder`.
This commit is contained in:
Nicholas Nethercote
2025-08-04 08:16:32 +10:00
parent 2434d8cecf
commit cc62d55298

View File

@@ -2437,12 +2437,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
where where
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>, T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
{ {
let old_region_index = self.region_index; self.wrap_binder(value, WrapBinderMode::ForAll, |new_value, this| new_value.print(this))
let (new_value, _) = self.name_all_regions(value, WrapBinderMode::ForAll)?;
new_value.print(self)?;
self.region_index = old_region_index;
self.binder_depth -= 1;
Ok(())
} }
fn wrap_binder<T, C: FnOnce(&T, &mut Self) -> Result<(), PrintError>>( fn wrap_binder<T, C: FnOnce(&T, &mut Self) -> Result<(), PrintError>>(