|
1 | 1 | use std::cell::Cell; |
2 | 2 | use std::fmt::{self, Write as _}; |
3 | 3 | use std::iter; |
4 | | -use std::ops::{Deref, DerefMut}; |
| 4 | +use std::ops::{ControlFlow, Deref, DerefMut}; |
5 | 5 |
|
6 | 6 | use rustc_abi::{ExternAbi, Size}; |
7 | 7 | use rustc_apfloat::Float; |
@@ -784,6 +784,28 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { |
784 | 784 | }, |
785 | 785 | }, |
786 | 786 | ty::Adt(def, args) => self.print_def_path(def.did(), args)?, |
| 787 | + ty::Field(container, field_path) => { |
| 788 | + write!(self, "field_of!(")?; |
| 789 | + self.pretty_print_type(container)?; |
| 790 | + write!(self, ", ")?; |
| 791 | + field_path |
| 792 | + .walk(self.tcx(), container, |_, name, _, last| { |
| 793 | + match write!(self, "{name}") { |
| 794 | + Err(err) => ControlFlow::Break(Err(err)), |
| 795 | + Ok(()) => ControlFlow::Continue(()), |
| 796 | + }?; |
| 797 | + if !last { |
| 798 | + match write!(self, ".") { |
| 799 | + Err(err) => ControlFlow::Break(Err(err)), |
| 800 | + Ok(()) => ControlFlow::Continue(()), |
| 801 | + } |
| 802 | + } else { |
| 803 | + ControlFlow::Continue(()) |
| 804 | + } |
| 805 | + }) |
| 806 | + .unwrap_or(Ok(()))?; |
| 807 | + write!(self, ")")?; |
| 808 | + } |
787 | 809 | ty::Dynamic(data, r, repr) => { |
788 | 810 | let print_r = self.should_print_optional_region(r); |
789 | 811 | if print_r { |
|
0 commit comments