diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-04-24 14:10:52 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-05-25 10:07:02 +0200 |
| commit | b816ec1eb439c6cae2f4f99327b30a126e10540c (patch) | |
| tree | f3d39759f99947186f76081afd20973f41b8a81a | |
| parent | ecee75d114a648885cd490f3620a3e58cee64bf8 (diff) | |
| download | rust-b816ec1eb439c6cae2f4f99327b30a126e10540c.tar.gz rust-b816ec1eb439c6cae2f4f99327b30a126e10540c.zip | |
Print unevaluted constants as `_` or as their source representation
| -rw-r--r-- | src/librustc/ty/print/pretty.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 0f7bc95902d..54f76c98f3c 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -1545,10 +1545,19 @@ define_print_and_forward_display! { } if let ConstValue::Unevaluated(did, substs) = self.val { match cx.tcx().describe_def(did) { - | Some(Def::Static(_, _)) - | Some(Def::Const(_, false)) - | Some(Def::AssociatedConst(_)) => p!(write("{}", cx.tcx().def_path_str(did))), - _ => p!(write("_")), + | Some(Def::Static(_)) + | Some(Def::Const(_)) + | Some(Def::AssociatedConst(_)) => p!(print_value_path(did, substs)), + _ => if did.is_local() { + let span = cx.tcx().def_span(did); + if let Ok(snip) = cx.tcx().sess.source_map().span_to_snippet(span) { + p!(write("{}", snip)) + } else { + p!(write("_")) + } + } else { + p!(write("_")) + }, } return Ok(cx); } |
