-define_print! {
- ('tcx) ty::Ty<'tcx>, (self, cx) {
- display {
- match self.sty {
- Bool => p!(write("bool")),
- Char => p!(write("char")),
- Int(t) => p!(write("{}", t.ty_to_string())),
- Uint(t) => p!(write("{}", t.ty_to_string())),
- Float(t) => p!(write("{}", t.ty_to_string())),
- RawPtr(ref tm) => {
- p!(write("*{} ", match tm.mutbl {
- hir::MutMutable => "mut",
- hir::MutImmutable => "const",
- }));
- p!(print(tm.ty))
+// FIXME(eddyb) move this to `ty::print`.
+impl<'gcx, 'tcx, P: PrettyPrinter> PrintCx<'_, 'gcx, 'tcx, P> {
+ pub fn pretty_print_type(
+ mut self,
+ ty: Ty<'tcx>,
+ ) -> Result<P::Type, P::Error> {
+ define_scoped_cx!(self);
+
+ match ty.sty {
+ ty::Bool => p!(write("bool")),
+ ty::Char => p!(write("char")),
+ ty::Int(t) => p!(write("{}", t.ty_to_string())),
+ ty::Uint(t) => p!(write("{}", t.ty_to_string())),
+ ty::Float(t) => p!(write("{}", t.ty_to_string())),
+ ty::RawPtr(ref tm) => {
+ p!(write("*{} ", match tm.mutbl {
+ hir::MutMutable => "mut",
+ hir::MutImmutable => "const",
+ }));
+ p!(print(tm.ty))
+ }
+ ty::Ref(r, ty, mutbl) => {
+ p!(write("&"));
+ if self.print_region_outputs_anything(r) {
+ p!(print_display(r), write(" "));