Skip to content

Commit db652fc

Browse files
committed
Render unresolved anon consts like closures
1 parent 669bc77 commit db652fc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/librustc/ty/print/pretty.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::hir;
2-
use crate::hir::def::Namespace;
2+
use crate::hir::def::{Namespace, Def};
33
use crate::hir::map::{DefPathData, DisambiguatedDefPathData};
44
use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
55
use crate::middle::cstore::{ExternCrate, ExternCrateSource};
@@ -1540,9 +1540,15 @@ define_print_and_forward_display! {
15401540
&'tcx ty::Const<'tcx> {
15411541
let u8 = cx.tcx().types.u8;
15421542
match (self.val, &self.ty.sty) {
1543-
| (ConstValue::Unevaluated(..), _)
1544-
| (ConstValue::Infer(..), _)
1545-
=> p!(write("_: "), print(self.ty)),
1543+
(ConstValue::Unevaluated(did, substs), _) => {
1544+
match cx.tcx().describe_def(did) {
1545+
| Some(Def::Static(_, _))
1546+
| Some(Def::Const(_))
1547+
| Some(Def::AssociatedConst(_)) => p!(write("{}", cx.tcx().def_path_str(did))),
1548+
_ => p!(write("_")),
1549+
}
1550+
}
1551+
(ConstValue::Infer(..), _) => p!(write("_: "), print(self.ty)),
15461552
(ConstValue::Param(ParamConst { name, .. }), _) => p!(write("{}", name)),
15471553
(ConstValue::Scalar(Scalar::Bits { bits: 0, .. }), ty::Bool) => p!(write("false")),
15481554
(ConstValue::Scalar(Scalar::Bits { bits: 1, .. }), ty::Bool) => p!(write("true")),

0 commit comments

Comments
 (0)