Skip to content

Commit f69a88b

Browse files
committed
updated p! macro to accept literals
1 parent d103fe1 commit f69a88b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,13 @@ pub trait PrettyPrinter<'tcx>:
646646
ty::Generator(did, substs, movability) => {
647647
p!(write("["));
648648
match movability {
649+
<<<<<<< HEAD
649650
hir::Movability::Movable => {}
650651
hir::Movability::Static => p!("static "),
652+
=======
653+
hir::Movability::Movable => p!("[generator"),
654+
hir::Movability::Static => p!("[static generator"),
655+
>>>>>>> 4bc0ae233aa... updated p! macro to accept literals
651656
}
652657

653658
if !self.tcx().sess.verbose() {
@@ -686,6 +691,7 @@ pub trait PrettyPrinter<'tcx>:
686691
p!(in_binder(&types));
687692
}
688693
ty::Closure(did, substs) => {
694+
<<<<<<< HEAD
689695
p!(write("["));
690696
if !self.tcx().sess.verbose() {
691697
p!(write("closure"));
@@ -697,6 +703,33 @@ pub trait PrettyPrinter<'tcx>:
697703
} else {
698704
let span = self.tcx().hir().span(hir_id);
699705
p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
706+
=======
707+
p!("[closure");
708+
709+
// FIXME(eddyb) should use `def_span`.
710+
if let Some(did) = did.as_local() {
711+
let hir_id = self.tcx().hir().local_def_id_to_hir_id(did);
712+
if self.tcx().sess.opts.debugging_opts.span_free_formats {
713+
p!("@", print_def_path(did.to_def_id(), substs));
714+
} else {
715+
let span = self.tcx().hir().span(hir_id);
716+
p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
717+
}
718+
719+
if substs.as_closure().is_valid() {
720+
let upvar_tys = substs.as_closure().upvar_tys();
721+
let mut sep = " ";
722+
for (&var_id, upvar_ty) in self
723+
.tcx()
724+
.upvars_mentioned(did)
725+
.as_ref()
726+
.iter()
727+
.flat_map(|v| v.keys())
728+
.zip(upvar_tys)
729+
{
730+
p!(write("{}{}:", sep, self.tcx().hir().name(var_id)), print(upvar_ty));
731+
sep = ", ";
732+
>>>>>>> 4bc0ae233aa... updated p! macro to accept literals
700733
}
701734
} else {
702735
p!(write("@{}", self.tcx().def_path_str(did)));
@@ -723,7 +756,17 @@ pub trait PrettyPrinter<'tcx>:
723756
}
724757
}
725758
}
759+
<<<<<<< HEAD
726760
p!("]");
761+
=======
762+
763+
if self.tcx().sess.verbose() && substs.as_closure().is_valid() {
764+
p!(" closure_kind_ty=", print(substs.as_closure().kind_ty()));
765+
p!(" closure_sig_as_fn_ptr_ty=", print(substs.as_closure().sig_as_fn_ptr_ty()));
766+
}
767+
768+
p!("]")
769+
>>>>>>> 4bc0ae233aa... updated p! macro to accept literals
727770
}
728771
ty::Array(ty, sz) => {
729772
p!("[", print(ty), "; ");

0 commit comments

Comments
 (0)