1
Fork 0

i am free

This commit is contained in:
Boxy 2023-01-18 04:45:35 +00:00
parent a2a50f96f3
commit 1171fe5c45
7 changed files with 18 additions and 15 deletions

View file

@ -1290,15 +1290,18 @@ pub trait PrettyPrinter<'tcx>:
p!(print_value_path(def.did, substs))
}
DefKind::AnonConst => {
if def.is_local() {
let span = self.tcx().def_span(def.did);
if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) {
p!(write("{}", snip))
} else {
p!(print_value_path(def.did, substs))
}
if def.is_local()
&& let span = self.tcx().def_span(def.did)
&& let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span)
{
p!(write("{}", snip))
} else {
p!(print_value_path(def.did, substs))
// Do not call `print_value_path` as if a parent of this anon const is an impl it will
// attempt to print out the impl trait ref i.e. `<T as Trait>::{constant#0}`. This would
// cause printing to enter an infinite recursion if the anon const is in the self type i.e.
// `impl<T: Default> Default for [T; 32 - 1 - 1 - 1] {`
// where we would try to print `<[T; /* print `constant#0` again */] as Default>::{constant#0}`
p!(write("{}::{}", self.tcx().crate_name(def.did.krate), self.tcx().def_path(def.did).to_string_no_crate_verbose()))
}
}
defkind => bug!("`{:?}` has unexpcted defkind {:?}", ct, defkind),