mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Simplify some match statements on `DefPathDataName'
This commit is contained in:
parent
75130b06bf
commit
bb8e1764bb
@ -7,7 +7,7 @@ use crate::common::CodegenCx;
|
||||
use crate::llvm;
|
||||
use crate::llvm::debuginfo::DIScope;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::{DefPathData, DefPathDataName};
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
||||
pub fn mangled_name_of_instance<'a, 'tcx>(
|
||||
@ -30,12 +30,7 @@ pub fn item_namespace(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
|
||||
|
||||
let namespace_name = match def_key.disambiguated_data.data {
|
||||
DefPathData::CrateRoot => cx.tcx.crate_name(def_id.krate),
|
||||
data => match data.name() {
|
||||
DefPathDataName::Named(name) => name,
|
||||
DefPathDataName::Anon { namespace } => {
|
||||
Symbol::intern(&format!("{{{{{}}}}}", namespace))
|
||||
}
|
||||
},
|
||||
data => Symbol::intern(&data.to_string()),
|
||||
};
|
||||
let namespace_name = namespace_name.as_str();
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathDataName;
|
||||
use rustc_middle::ty::{self, subst::SubstsRef, Ty, TyCtxt};
|
||||
|
||||
use std::fmt::Write;
|
||||
@ -231,13 +230,7 @@ pub fn push_debuginfo_type_name<'tcx>(
|
||||
if qualified {
|
||||
output.push_str(&tcx.crate_name(def_id.krate).as_str());
|
||||
for path_element in tcx.def_path(def_id).data {
|
||||
output.push_str("::");
|
||||
match path_element.data.name() {
|
||||
DefPathDataName::Named(name) => output.push_str(&name.as_str()),
|
||||
DefPathDataName::Anon { namespace } => {
|
||||
write!(output, "{{{{{}}}}}", namespace).unwrap()
|
||||
}
|
||||
}
|
||||
write!(output, "::{}", path_element.data).unwrap();
|
||||
}
|
||||
} else {
|
||||
output.push_str(&tcx.item_name(def_id).as_str());
|
||||
|
@ -26,7 +26,7 @@ use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc_middle::lint::LintDiagnosticBuilder;
|
||||
use rustc_middle::middle::privacy::AccessLevels;
|
||||
use rustc_middle::middle::stability;
|
||||
@ -846,12 +846,7 @@ impl<'tcx> LateContext<'tcx> {
|
||||
return Ok(path);
|
||||
}
|
||||
|
||||
path.push(match disambiguated_data.data.name() {
|
||||
DefPathDataName::Named(name) => name,
|
||||
DefPathDataName::Anon { namespace } => {
|
||||
Symbol::intern(&format!("{{{{{}}}}}", namespace))
|
||||
}
|
||||
});
|
||||
path.push(Symbol::intern(&disambiguated_data.data.to_string()));
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user