about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc/Cargo.toml4
-rw-r--r--compiler/rustc_codegen_llvm/src/type_of.rs5
-rw-r--r--compiler/rustc_codegen_ssa/src/mono_item.rs8
-rw-r--r--compiler/rustc_expand/src/expand.rs2
-rw-r--r--compiler/rustc_expand/src/proc_macro.rs41
-rw-r--r--compiler/rustc_interface/src/passes.rs1
-rw-r--r--compiler/rustc_interface/src/tests.rs1
-rw-r--r--compiler/rustc_lexer/Cargo.toml1
-rw-r--r--compiler/rustc_middle/src/mir/mono.rs37
-rw-r--r--compiler/rustc_middle/src/ty/print/mod.rs2
-rw-r--r--compiler/rustc_middle/src/ty/print/obsolete.rs251
-rw-r--r--compiler/rustc_mir/src/monomorphize/collector.rs24
-rw-r--r--compiler/rustc_mir/src/monomorphize/partitioning/mod.rs4
-rw-r--r--compiler/rustc_session/src/options.rs2
14 files changed, 55 insertions, 328 deletions
diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml
index 4340d50f845..cf011e63e02 100644
--- a/compiler/rustc/Cargo.toml
+++ b/compiler/rustc/Cargo.toml
@@ -4,10 +4,6 @@ name = "rustc-main"
 version = "0.0.0"
 edition = '2018'
 
-[[bin]]
-name = "rustc_binary"
-path = "src/main.rs"
-
 [dependencies]
 rustc_driver = { path = "../rustc_driver" }
 
diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs
index 40870c66475..60a4e362600 100644
--- a/compiler/rustc_codegen_llvm/src/type_of.rs
+++ b/compiler/rustc_codegen_llvm/src/type_of.rs
@@ -4,7 +4,6 @@ use crate::type_::Type;
 use rustc_codegen_ssa::traits::*;
 use rustc_middle::bug;
 use rustc_middle::ty::layout::{FnAbiExt, TyAndLayout};
-use rustc_middle::ty::print::obsolete::DefPathBasedNames;
 use rustc_middle::ty::{self, Ty, TypeFoldable};
 use rustc_target::abi::{Abi, AddressSpace, Align, FieldsShape};
 use rustc_target::abi::{Int, Pointer, F32, F64};
@@ -60,9 +59,7 @@ fn uncached_llvm_type<'a, 'tcx>(
         // ty::Dynamic(..) |
         ty::Foreign(..) |
         ty::Str => {
-            let mut name = String::with_capacity(32);
-            let printer = DefPathBasedNames::new(cx.tcx, true, true);
-            printer.push_type_name(layout.ty, &mut name, false);
+            let mut name = layout.ty.to_string();
             if let (&ty::Adt(def, _), &Variants::Single { index })
                  = (&layout.ty.kind, &layout.variants)
             {
diff --git a/compiler/rustc_codegen_ssa/src/mono_item.rs b/compiler/rustc_codegen_ssa/src/mono_item.rs
index fc65149937f..607b5459673 100644
--- a/compiler/rustc_codegen_ssa/src/mono_item.rs
+++ b/compiler/rustc_codegen_ssa/src/mono_item.rs
@@ -21,7 +21,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
     fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx) {
         debug!(
             "BEGIN IMPLEMENTING '{} ({})' in cgu {}",
-            self.to_string(cx.tcx(), true),
+            self,
             self.to_raw_string(),
             cx.codegen_unit().name()
         );
@@ -45,7 +45,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
 
         debug!(
             "END IMPLEMENTING '{} ({})' in cgu {}",
-            self.to_string(cx.tcx(), true),
+            self,
             self.to_raw_string(),
             cx.codegen_unit().name()
         );
@@ -59,7 +59,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
     ) {
         debug!(
             "BEGIN PREDEFINING '{} ({})' in cgu {}",
-            self.to_string(cx.tcx(), true),
+            self,
             self.to_raw_string(),
             cx.codegen_unit().name()
         );
@@ -80,7 +80,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
 
         debug!(
             "END PREDEFINING '{} ({})' in cgu {}",
-            self.to_string(cx.tcx(), true),
+            self,
             self.to_raw_string(),
             cx.codegen_unit().name()
         );
diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs
index 7a21caf255a..6243e9676de 100644
--- a/compiler/rustc_expand/src/expand.rs
+++ b/compiler/rustc_expand/src/expand.rs
@@ -1788,6 +1788,7 @@ pub struct ExpansionConfig<'feat> {
     pub should_test: bool, // If false, strip `#[test]` nodes
     pub keep_macs: bool,
     pub span_debug: bool, // If true, use verbose debugging for `proc_macro::Span`
+    pub proc_macro_backtrace: bool, // If true, show backtraces for proc-macro panics
 }
 
 impl<'feat> ExpansionConfig<'feat> {
@@ -1800,6 +1801,7 @@ impl<'feat> ExpansionConfig<'feat> {
             should_test: false,
             keep_macs: false,
             span_debug: false,
+            proc_macro_backtrace: false,
         }
     }
 
diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs
index 4e865c20d6f..94b3fcf2850 100644
--- a/compiler/rustc_expand/src/proc_macro.rs
+++ b/compiler/rustc_expand/src/proc_macro.rs
@@ -24,7 +24,7 @@ impl base::ProcMacro for BangProcMacro {
         input: TokenStream,
     ) -> Result<TokenStream, ErrorReported> {
         let server = proc_macro_server::Rustc::new(ecx);
-        self.client.run(&EXEC_STRATEGY, server, input).map_err(|e| {
+        self.client.run(&EXEC_STRATEGY, server, input, ecx.ecfg.proc_macro_backtrace).map_err(|e| {
             let mut err = ecx.struct_span_err(span, "proc macro panicked");
             if let Some(s) = e.as_str() {
                 err.help(&format!("message: {}", s));
@@ -48,14 +48,16 @@ impl base::AttrProcMacro for AttrProcMacro {
         annotated: TokenStream,
     ) -> Result<TokenStream, ErrorReported> {
         let server = proc_macro_server::Rustc::new(ecx);
-        self.client.run(&EXEC_STRATEGY, server, annotation, annotated).map_err(|e| {
-            let mut err = ecx.struct_span_err(span, "custom attribute panicked");
-            if let Some(s) = e.as_str() {
-                err.help(&format!("message: {}", s));
-            }
-            err.emit();
-            ErrorReported
-        })
+        self.client
+            .run(&EXEC_STRATEGY, server, annotation, annotated, ecx.ecfg.proc_macro_backtrace)
+            .map_err(|e| {
+                let mut err = ecx.struct_span_err(span, "custom attribute panicked");
+                if let Some(s) = e.as_str() {
+                    err.help(&format!("message: {}", s));
+                }
+                err.emit();
+                ErrorReported
+            })
     }
 }
 
@@ -111,17 +113,18 @@ impl MultiItemModifier for ProcMacroDerive {
         };
 
         let server = proc_macro_server::Rustc::new(ecx);
-        let stream = match self.client.run(&EXEC_STRATEGY, server, input) {
-            Ok(stream) => stream,
-            Err(e) => {
-                let mut err = ecx.struct_span_err(span, "proc-macro derive panicked");
-                if let Some(s) = e.as_str() {
-                    err.help(&format!("message: {}", s));
+        let stream =
+            match self.client.run(&EXEC_STRATEGY, server, input, ecx.ecfg.proc_macro_backtrace) {
+                Ok(stream) => stream,
+                Err(e) => {
+                    let mut err = ecx.struct_span_err(span, "proc-macro derive panicked");
+                    if let Some(s) = e.as_str() {
+                        err.help(&format!("message: {}", s));
+                    }
+                    err.emit();
+                    return ExpandResult::Ready(vec![]);
                 }
-                err.emit();
-                return ExpandResult::Ready(vec![]);
-            }
-        };
+            };
 
         let error_count_before = ecx.sess.parse_sess.span_diagnostic.err_count();
         let mut parser =
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs
index 403aea8b304..f33dcec8ba7 100644
--- a/compiler/rustc_interface/src/passes.rs
+++ b/compiler/rustc_interface/src/passes.rs
@@ -291,6 +291,7 @@ fn configure_and_expand_inner<'a>(
             trace_mac: sess.opts.debugging_opts.trace_macros,
             should_test: sess.opts.test,
             span_debug: sess.opts.debugging_opts.span_debug,
+            proc_macro_backtrace: sess.opts.debugging_opts.proc_macro_backtrace,
             ..rustc_expand::expand::ExpansionConfig::default(crate_name.to_string())
         };
 
diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs
index e94745519a4..cb906b3d911 100644
--- a/compiler/rustc_interface/src/tests.rs
+++ b/compiler/rustc_interface/src/tests.rs
@@ -502,6 +502,7 @@ fn test_debugging_options_tracking_hash() {
     untracked!(print_llvm_passes, true);
     untracked!(print_mono_items, Some(String::from("abc")));
     untracked!(print_type_sizes, true);
+    untracked!(proc_macro_backtrace, true);
     untracked!(query_dep_graph, true);
     untracked!(query_stats, true);
     untracked!(save_analysis, true);
diff --git a/compiler/rustc_lexer/Cargo.toml b/compiler/rustc_lexer/Cargo.toml
index 28b56f6fef4..390a21a501c 100644
--- a/compiler/rustc_lexer/Cargo.toml
+++ b/compiler/rustc_lexer/Cargo.toml
@@ -14,7 +14,6 @@ Rust lexer used by rustc. No stability guarantees are provided.
 # This will be used when publishing this crate as `rustc-ap-rustc_lexer`.
 [lib]
 doctest = false
-name = "rustc_lexer"
 
 # Note that this crate purposefully does not depend on other rustc crates
 [dependencies]
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs
index 0d5f6619df5..245e07d096e 100644
--- a/compiler/rustc_middle/src/mir/mono.rs
+++ b/compiler/rustc_middle/src/mir/mono.rs
@@ -1,6 +1,5 @@
 use crate::dep_graph::{DepConstructor, DepNode, WorkProduct, WorkProductId};
 use crate::ich::{NodeIdHashingMode, StableHashingContext};
-use crate::ty::print::obsolete::DefPathBasedNames;
 use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
 use rustc_attr::InlineAttr;
 use rustc_data_structures::base_n;
@@ -171,30 +170,6 @@ impl<'tcx> MonoItem<'tcx> {
         !tcx.subst_and_check_impossible_predicates((def_id, &substs))
     }
 
-    pub fn to_string(&self, tcx: TyCtxt<'tcx>, debug: bool) -> String {
-        return match *self {
-            MonoItem::Fn(instance) => to_string_internal(tcx, "fn ", instance, debug),
-            MonoItem::Static(def_id) => {
-                let instance = Instance::new(def_id, tcx.intern_substs(&[]));
-                to_string_internal(tcx, "static ", instance, debug)
-            }
-            MonoItem::GlobalAsm(..) => "global_asm".to_string(),
-        };
-
-        fn to_string_internal<'tcx>(
-            tcx: TyCtxt<'tcx>,
-            prefix: &str,
-            instance: Instance<'tcx>,
-            debug: bool,
-        ) -> String {
-            let mut result = String::with_capacity(32);
-            result.push_str(prefix);
-            let printer = DefPathBasedNames::new(tcx, false, false);
-            printer.push_instance_as_string(instance, &mut result, debug);
-            result
-        }
-    }
-
     pub fn local_span(&self, tcx: TyCtxt<'tcx>) -> Option<Span> {
         match *self {
             MonoItem::Fn(Instance { def, .. }) => {
@@ -229,6 +204,18 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for MonoItem<'tcx> {
     }
 }
 
+impl<'tcx> fmt::Display for MonoItem<'tcx> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match *self {
+            MonoItem::Fn(instance) => write!(f, "fn {}", instance),
+            MonoItem::Static(def_id) => {
+                write!(f, "static {}", Instance::new(def_id, InternalSubsts::empty()))
+            }
+            MonoItem::GlobalAsm(..) => write!(f, "global_asm"),
+        }
+    }
+}
+
 pub struct CodegenUnit<'tcx> {
     /// A name for this CGU. Incremental compilation requires that
     /// name be unique amongst **all** crates. Therefore, it should
diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs
index 6c8f23c139f..bfeef7892c3 100644
--- a/compiler/rustc_middle/src/ty/print/mod.rs
+++ b/compiler/rustc_middle/src/ty/print/mod.rs
@@ -9,8 +9,6 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
 mod pretty;
 pub use self::pretty::*;
 
-pub mod obsolete;
-
 // FIXME(eddyb) false positive, the lifetime parameters are used with `P:  Printer<...>`.
 #[allow(unused_lifetimes)]
 pub trait Print<'tcx, P> {
diff --git a/compiler/rustc_middle/src/ty/print/obsolete.rs b/compiler/rustc_middle/src/ty/print/obsolete.rs
deleted file mode 100644
index 2ea7cd2a6dc..00000000000
--- a/compiler/rustc_middle/src/ty/print/obsolete.rs
+++ /dev/null
@@ -1,251 +0,0 @@
-//! Allows for producing a unique string key for a mono item.
-//! These keys are used by the handwritten auto-tests, so they need to be
-//! predictable and human-readable.
-//!
-//! Note: A lot of this could looks very similar to what's already in `ty::print`.
-//! FIXME(eddyb) implement a custom `PrettyPrinter` for this.
-
-use crate::bug;
-use crate::ty::subst::SubstsRef;
-use crate::ty::{self, Const, Instance, Ty, TyCtxt};
-use rustc_hir as hir;
-use rustc_hir::def_id::DefId;
-use std::fmt::Write;
-use std::iter;
-
-/// Same as `unique_type_name()` but with the result pushed onto the given
-/// `output` parameter.
-pub struct DefPathBasedNames<'tcx> {
-    tcx: TyCtxt<'tcx>,
-    omit_disambiguators: bool,
-    omit_local_crate_name: bool,
-}
-
-impl DefPathBasedNames<'tcx> {
-    pub fn new(tcx: TyCtxt<'tcx>, omit_disambiguators: bool, omit_local_crate_name: bool) -> Self {
-        DefPathBasedNames { tcx, omit_disambiguators, omit_local_crate_name }
-    }
-
-    // Pushes the type name of the specified type to the provided string.
-    // If `debug` is true, printing normally unprintable types is allowed
-    // (e.g. `ty::GeneratorWitness`). This parameter should only be set when
-    // this method is being used for logging purposes (e.g. with `debug!` or `info!`)
-    // When being used for codegen purposes, `debug` should be set to `false`
-    // in order to catch unexpected types that should never end up in a type name.
-    pub fn push_type_name(&self, t: Ty<'tcx>, output: &mut String, debug: bool) {
-        match t.kind {
-            ty::Bool => output.push_str("bool"),
-            ty::Char => output.push_str("char"),
-            ty::Str => output.push_str("str"),
-            ty::Never => output.push_str("!"),
-            ty::Int(ty) => output.push_str(ty.name_str()),
-            ty::Uint(ty) => output.push_str(ty.name_str()),
-            ty::Float(ty) => output.push_str(ty.name_str()),
-            ty::Adt(adt_def, substs) => {
-                self.push_def_path(adt_def.did, output);
-                self.push_generic_params(substs, iter::empty(), output, debug);
-            }
-            ty::Tuple(component_types) => {
-                output.push('(');
-                for component_type in component_types {
-                    self.push_type_name(component_type.expect_ty(), output, debug);
-                    output.push_str(", ");
-                }
-                if !component_types.is_empty() {
-                    output.pop();
-                    output.pop();
-                }
-                output.push(')');
-            }
-            ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl }) => {
-                output.push('*');
-                match mutbl {
-                    hir::Mutability::Not => output.push_str("const "),
-                    hir::Mutability::Mut => output.push_str("mut "),
-                }
-
-                self.push_type_name(inner_type, output, debug);
-            }
-            ty::Ref(_, inner_type, mutbl) => {
-                output.push('&');
-                output.push_str(mutbl.prefix_str());
-
-                self.push_type_name(inner_type, output, debug);
-            }
-            ty::Array(inner_type, len) => {
-                output.push('[');
-                self.push_type_name(inner_type, output, debug);
-                let len = len.eval_usize(self.tcx, ty::ParamEnv::reveal_all());
-                write!(output, "; {}", len).unwrap();
-                output.push(']');
-            }
-            ty::Slice(inner_type) => {
-                output.push('[');
-                self.push_type_name(inner_type, output, debug);
-                output.push(']');
-            }
-            ty::Dynamic(ref trait_data, ..) => {
-                if let Some(principal) = trait_data.principal() {
-                    self.push_def_path(principal.def_id(), output);
-                    self.push_generic_params(
-                        principal.skip_binder().substs,
-                        trait_data.projection_bounds(),
-                        output,
-                        debug,
-                    );
-                } else {
-                    output.push_str("dyn '_");
-                }
-            }
-            ty::Foreign(did) => self.push_def_path(did, output),
-            ty::FnDef(..) | ty::FnPtr(_) => {
-                let sig = t.fn_sig(self.tcx);
-                output.push_str(sig.unsafety().prefix_str());
-
-                let abi = sig.abi();
-                if abi != ::rustc_target::spec::abi::Abi::Rust {
-                    output.push_str("extern \"");
-                    output.push_str(abi.name());
-                    output.push_str("\" ");
-                }
-
-                output.push_str("fn(");
-
-                let sig =
-                    self.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
-
-                if !sig.inputs().is_empty() {
-                    for &parameter_type in sig.inputs() {
-                        self.push_type_name(parameter_type, output, debug);
-                        output.push_str(", ");
-                    }
-                    output.pop();
-                    output.pop();
-                }
-
-                if sig.c_variadic {
-                    if !sig.inputs().is_empty() {
-                        output.push_str(", ...");
-                    } else {
-                        output.push_str("...");
-                    }
-                }
-
-                output.push(')');
-
-                if !sig.output().is_unit() {
-                    output.push_str(" -> ");
-                    self.push_type_name(sig.output(), output, debug);
-                }
-            }
-            ty::Generator(def_id, substs, _) | ty::Closure(def_id, substs) => {
-                self.push_def_path(def_id, output);
-                let generics = self.tcx.generics_of(self.tcx.closure_base_def_id(def_id));
-                let substs = substs.truncate_to(self.tcx, generics);
-                self.push_generic_params(substs, iter::empty(), output, debug);
-            }
-            ty::Param(_) => {
-                output.push_str(&t.to_string());
-            }
-            ty::Error(_)
-            | ty::Bound(..)
-            | ty::Infer(_)
-            | ty::Placeholder(..)
-            | ty::Projection(..)
-            | ty::GeneratorWitness(_)
-            | ty::Opaque(..) => {
-                if debug {
-                    output.push_str(&format!("`{:?}`", t));
-                } else {
-                    bug!(
-                        "DefPathBasedNames: trying to create type name for unexpected type: {:?}",
-                        t,
-                    );
-                }
-            }
-        }
-    }
-
-    // Pushes the the name of the specified const to the provided string.
-    // If `debug` is true, the unprintable types of constants will be printed with `fmt::Debug`
-    // (see `push_type_name` for more details).
-    pub fn push_const_name(&self, ct: &Const<'tcx>, output: &mut String, debug: bool) {
-        write!(output, "{}", ct).unwrap();
-        output.push_str(": ");
-        self.push_type_name(ct.ty, output, debug);
-    }
-
-    pub fn push_def_path(&self, def_id: DefId, output: &mut String) {
-        let def_path = self.tcx.def_path(def_id);
-
-        // some_crate::
-        if !(self.omit_local_crate_name && def_id.is_local()) {
-            output.push_str(&self.tcx.crate_name(def_path.krate).as_str());
-            output.push_str("::");
-        }
-
-        // foo::bar::ItemName::
-        for part in self.tcx.def_path(def_id).data {
-            if self.omit_disambiguators {
-                write!(output, "{}::", part.data.as_symbol()).unwrap();
-            } else {
-                write!(output, "{}[{}]::", part.data.as_symbol(), part.disambiguator).unwrap();
-            }
-        }
-
-        // remove final "::"
-        output.pop();
-        output.pop();
-    }
-
-    fn push_generic_params<I>(
-        &self,
-        substs: SubstsRef<'tcx>,
-        projections: I,
-        output: &mut String,
-        debug: bool,
-    ) where
-        I: Iterator<Item = ty::PolyExistentialProjection<'tcx>>,
-    {
-        let mut projections = projections.peekable();
-        if substs.non_erasable_generics().next().is_none() && projections.peek().is_none() {
-            return;
-        }
-
-        output.push('<');
-
-        for type_parameter in substs.types() {
-            self.push_type_name(type_parameter, output, debug);
-            output.push_str(", ");
-        }
-
-        for projection in projections {
-            let projection = projection.skip_binder();
-            let name = &self.tcx.associated_item(projection.item_def_id).ident.as_str();
-            output.push_str(name);
-            output.push_str("=");
-            self.push_type_name(projection.ty, output, debug);
-            output.push_str(", ");
-        }
-
-        for const_parameter in substs.consts() {
-            self.push_const_name(const_parameter, output, debug);
-            output.push_str(", ");
-        }
-
-        output.pop();
-        output.pop();
-
-        output.push('>');
-    }
-
-    pub fn push_instance_as_string(
-        &self,
-        instance: Instance<'tcx>,
-        output: &mut String,
-        debug: bool,
-    ) {
-        self.push_def_path(instance.def_id(), output);
-        self.push_generic_params(instance.substs, iter::empty(), output, debug);
-    }
-}
diff --git a/compiler/rustc_mir/src/monomorphize/collector.rs b/compiler/rustc_mir/src/monomorphize/collector.rs
index d379f4ef428..43cac8e5ee6 100644
--- a/compiler/rustc_mir/src/monomorphize/collector.rs
+++ b/compiler/rustc_mir/src/monomorphize/collector.rs
@@ -191,7 +191,6 @@ use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
 use rustc_middle::mir::visit::Visitor as MirVisitor;
 use rustc_middle::mir::{self, Local, Location};
 use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCast};
-use rustc_middle::ty::print::obsolete::DefPathBasedNames;
 use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts};
 use rustc_middle::ty::{self, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable};
 use rustc_session::config::EntryFnType;
@@ -348,7 +347,7 @@ fn collect_items_rec<'tcx>(
         // We've been here already, no need to search again.
         return;
     }
-    debug!("BEGIN collect_items_rec({})", starting_point.node.to_string(tcx, true));
+    debug!("BEGIN collect_items_rec({})", starting_point.node);
 
     let mut neighbors = Vec::new();
     let recursion_depth_reset;
@@ -397,7 +396,7 @@ fn collect_items_rec<'tcx>(
         recursion_depths.insert(def_id, depth);
     }
 
-    debug!("END collect_items_rec({})", starting_point.node.to_string(tcx, true));
+    debug!("END collect_items_rec({})", starting_point.node);
 }
 
 fn record_accesses<'a, 'tcx: 'a>(
@@ -992,7 +991,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
                         let def_id = self.tcx.hir().local_def_id(item.hir_id);
                         debug!(
                             "RootCollector: ADT drop-glue for {}",
-                            def_id_to_string(self.tcx, def_id)
+                            self.tcx.def_path_str(def_id.to_def_id())
                         );
 
                         let ty = Instance::new(def_id.to_def_id(), InternalSubsts::empty())
@@ -1004,14 +1003,14 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
             hir::ItemKind::GlobalAsm(..) => {
                 debug!(
                     "RootCollector: ItemKind::GlobalAsm({})",
-                    def_id_to_string(self.tcx, self.tcx.hir().local_def_id(item.hir_id))
+                    self.tcx.def_path_str(self.tcx.hir().local_def_id(item.hir_id).to_def_id())
                 );
                 self.output.push(dummy_spanned(MonoItem::GlobalAsm(item.hir_id)));
             }
             hir::ItemKind::Static(..) => {
-                let def_id = self.tcx.hir().local_def_id(item.hir_id);
-                debug!("RootCollector: ItemKind::Static({})", def_id_to_string(self.tcx, def_id));
-                self.output.push(dummy_spanned(MonoItem::Static(def_id.to_def_id())));
+                let def_id = self.tcx.hir().local_def_id(item.hir_id).to_def_id();
+                debug!("RootCollector: ItemKind::Static({})", self.tcx.def_path_str(def_id));
+                self.output.push(dummy_spanned(MonoItem::Static(def_id)));
             }
             hir::ItemKind::Const(..) => {
                 // const items only generate mono items if they are
@@ -1134,7 +1133,7 @@ fn create_mono_items_for_default_impls<'tcx>(
 
             debug!(
                 "create_mono_items_for_default_impls(item={})",
-                def_id_to_string(tcx, impl_def_id)
+                tcx.def_path_str(impl_def_id.to_def_id())
             );
 
             if let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) {
@@ -1218,13 +1217,6 @@ fn collect_neighbours<'tcx>(
     MirNeighborCollector { tcx, body: &body, output, instance }.visit_body(&body);
 }
 
-fn def_id_to_string(tcx: TyCtxt<'_>, def_id: LocalDefId) -> String {
-    let mut output = String::new();
-    let printer = DefPathBasedNames::new(tcx, false, false);
-    printer.push_def_path(def_id.to_def_id(), &mut output);
-    output
-}
-
 fn collect_const_value<'tcx>(
     tcx: TyCtxt<'tcx>,
     value: ConstValue<'tcx>,
diff --git a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs b/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs
index 9dfbd65e1b1..5747c016357 100644
--- a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs
+++ b/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs
@@ -246,7 +246,7 @@ where
 
                 debug!(
                     " - {} [{:?}] [{}] estimated size {}",
-                    mono_item.to_string(tcx, true),
+                    mono_item,
                     linkage,
                     symbol_hash,
                     mono_item.size_estimate(tcx)
@@ -374,7 +374,7 @@ fn collect_and_partition_mono_items<'tcx>(
         let mut item_keys: Vec<_> = items
             .iter()
             .map(|i| {
-                let mut output = i.to_string(tcx, false);
+                let mut output = i.to_string();
                 output.push_str(" @@");
                 let mut empty = Vec::new();
                 let cgus = item_to_cgus.get_mut(i).unwrap_or(&mut empty);
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index d05f1a3f34b..82330d9a533 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -967,6 +967,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         "print the result of the monomorphization collection pass"),
     print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
         "print layout information for each type encountered (default: no)"),
+    proc_macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
+         "show backtraces for panics during proc-macro execution (default: no)"),
     profile: bool = (false, parse_bool, [TRACKED],
         "insert profiling code (default: no)"),
     profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],