adjust how closure/generator types and rvalues are printed
This commit is contained in:
parent
e4a361a48a
commit
c4ec12f4b7
191 changed files with 477 additions and 477 deletions
|
@ -1616,7 +1616,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
// | expected `()`, found closure
|
||||
// |
|
||||
// = note: expected unit type `()`
|
||||
// found closure `[closure@$DIR/issue-20862.rs:2:5: 2:14 x:_]`
|
||||
// found closure `{closure@$DIR/issue-20862.rs:2:5: 2:14 x:_}`
|
||||
//
|
||||
// Also ignore opaque `Future`s that come from async fns.
|
||||
if !self.ignore_span.overlaps(span)
|
||||
|
|
|
@ -990,11 +990,11 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||
AggregateKind::Closure(def_id, args) => ty::tls::with(|tcx| {
|
||||
let name = if tcx.sess.opts.unstable_opts.span_free_formats {
|
||||
let args = tcx.lift(args).unwrap();
|
||||
format!("[closure@{}]", tcx.def_path_str_with_args(def_id, args),)
|
||||
format!("{{closure@{}}}", tcx.def_path_str_with_args(def_id, args),)
|
||||
} else {
|
||||
let span = tcx.def_span(def_id);
|
||||
format!(
|
||||
"[closure@{}]",
|
||||
"{{closure@{}}}",
|
||||
tcx.sess.source_map().span_to_diagnostic_string(span)
|
||||
)
|
||||
};
|
||||
|
@ -1018,7 +1018,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||
}),
|
||||
|
||||
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
|
||||
let name = format!("[generator@{:?}]", tcx.def_span(def_id));
|
||||
let name = format!("{{generator@{:?}}}", tcx.def_span(def_id));
|
||||
let mut struct_fmt = fmt.debug_struct(&name);
|
||||
|
||||
// FIXME(project-rfc-2229#48): This should be a list of capture names/places
|
||||
|
|
|
@ -795,7 +795,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
}
|
||||
ty::Str => p!("str"),
|
||||
ty::Generator(did, args, movability) => {
|
||||
p!(write("["));
|
||||
p!(write("{{"));
|
||||
let generator_kind = self.tcx().generator_kind(did).unwrap();
|
||||
let should_print_movability =
|
||||
self.should_print_verbose() || generator_kind == hir::GeneratorKind::Gen;
|
||||
|
@ -836,13 +836,13 @@ pub trait PrettyPrinter<'tcx>:
|
|||
}
|
||||
}
|
||||
|
||||
p!("]")
|
||||
p!("}}")
|
||||
}
|
||||
ty::GeneratorWitness(types) => {
|
||||
p!(in_binder(&types));
|
||||
}
|
||||
ty::GeneratorWitnessMIR(did, args) => {
|
||||
p!(write("["));
|
||||
p!(write("{{"));
|
||||
if !self.tcx().sess.verbose() {
|
||||
p!("generator witness");
|
||||
// FIXME(eddyb) should use `def_span`.
|
||||
|
@ -861,10 +861,10 @@ pub trait PrettyPrinter<'tcx>:
|
|||
p!(print_def_path(did, args));
|
||||
}
|
||||
|
||||
p!("]")
|
||||
p!("}}")
|
||||
}
|
||||
ty::Closure(did, args) => {
|
||||
p!(write("["));
|
||||
p!(write("{{"));
|
||||
if !self.should_print_verbose() {
|
||||
p!(write("closure"));
|
||||
// FIXME(eddyb) should use `def_span`.
|
||||
|
@ -904,7 +904,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
p!(")");
|
||||
}
|
||||
}
|
||||
p!("]");
|
||||
p!("}}");
|
||||
}
|
||||
ty::Array(ty, sz) => p!("[", print(ty), "; ", print(sz), "]"),
|
||||
ty::Slice(ty) => p!("[", print(ty), "]"),
|
||||
|
@ -1061,7 +1061,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
}
|
||||
|
||||
for (assoc_item_def_id, term) in assoc_items {
|
||||
// Skip printing `<[generator@] as Generator<_>>::Return` from async blocks,
|
||||
// Skip printing `<{generator@} as Generator<_>>::Return` from async blocks,
|
||||
// unless we can find out what generator return type it comes from.
|
||||
let term = if let Some(ty) = term.skip_binder().ty()
|
||||
&& let ty::Alias(ty::Projection, proj) = ty.kind()
|
||||
|
|
|
@ -2550,7 +2550,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
|
||||
/// Checks whether a type recursively contains any closure
|
||||
///
|
||||
/// Example: `Option<[closure@file.rs:4:20]>` returns true
|
||||
/// Example: `Option<{closure@file.rs:4:20}>` returns true
|
||||
pub fn contains_closure(self) -> bool {
|
||||
struct ContainsClosureVisitor;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue