about summary refs log tree commit diff
path: root/src/librustc_codegen_utils
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2019-02-03 12:59:37 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2019-03-15 13:25:10 +0200
commita54a41ce47c149fd6587182a4ab87a146844f939 (patch)
treef48533eece21012c999f971adfef58f4b056a48f /src/librustc_codegen_utils
parent8619edede1496a8d9c4131f9cb2079e71dccd5fb (diff)
downloadrust-a54a41ce47c149fd6587182a4ab87a146844f939.tar.gz
rust-a54a41ce47c149fd6587182a4ab87a146844f939.zip
rustc: provide DisambiguatedDefPathData in ty::print.
Diffstat (limited to 'src/librustc_codegen_utils')
-rw-r--r--src/librustc_codegen_utils/symbol_names.rs26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs
index 262ba8a1c74..0fa935199f9 100644
--- a/src/librustc_codegen_utils/symbol_names.rs
+++ b/src/librustc_codegen_utils/symbol_names.rs
@@ -90,7 +90,7 @@
 use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
 use rustc::hir::Node;
 use rustc::hir::CodegenFnAttrFlags;
-use rustc::hir::map::definitions::DefPathData;
+use rustc::hir::map::{DefPathData, DisambiguatedDefPathData};
 use rustc::ich::NodeIdHashingMode;
 use rustc::ty::print::{PrettyPrinter, Printer, Print};
 use rustc::ty::query::Providers;
@@ -492,11 +492,23 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'_, 'tcx> {
     fn path_append_impl(
         self,
         print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
+        _disambiguated_data: &DisambiguatedDefPathData,
         self_ty: Ty<'tcx>,
         trait_ref: Option<ty::TraitRef<'tcx>>,
     ) -> Result<Self::Path, Self::Error> {
         self.pretty_path_append_impl(
-            |cx| cx.path_append(print_prefix, ""),
+            |mut cx| {
+                cx = print_prefix(cx)?;
+
+                if cx.keep_within_component {
+                    // HACK(eddyb) print the path similarly to how `FmtPrinter` prints it.
+                    cx.write_str("::")?;
+                } else {
+                    cx.path.finalize_pending_component();
+                }
+
+                Ok(cx)
+            },
             self_ty,
             trait_ref,
         )
@@ -504,10 +516,16 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'_, 'tcx> {
     fn path_append(
         mut self,
         print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
-        text: &str,
+        disambiguated_data: &DisambiguatedDefPathData,
     ) -> Result<Self::Path, Self::Error> {
         self = print_prefix(self)?;
 
+        // Skip `::{{constructor}}` on tuple/unit structs.
+        match disambiguated_data.data {
+            DefPathData::StructCtor => return Ok(self),
+            _ => {}
+        }
+
         if self.keep_within_component {
             // HACK(eddyb) print the path similarly to how `FmtPrinter` prints it.
             self.write_str("::")?;
@@ -515,7 +533,7 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'_, 'tcx> {
             self.path.finalize_pending_component();
         }
 
-        self.write_str(text)?;
+        self.write_str(&disambiguated_data.data.as_interned_str().as_str())?;
         Ok(self)
     }
     fn path_generic_args(