Use Symbol in Name

This commit is contained in:
Lukas Wirth 2024-07-12 15:57:54 +02:00
parent 843806b79f
commit 3fe815b0f3
75 changed files with 750 additions and 755 deletions

View file

@ -64,11 +64,7 @@ enum FieldOrTupleIdx {
impl FieldOrTupleIdx {
fn name(&self, db: &RootDatabase) -> String {
match *self {
FieldOrTupleIdx::Field(f) => f
.name(db)
.as_str()
.map(|s| s.to_owned())
.unwrap_or_else(|| format!(".{}", f.name(db).as_tuple_index().unwrap())),
FieldOrTupleIdx::Field(f) => f.name(db).as_str().to_owned(),
FieldOrTupleIdx::TupleIdx(i) => format!(".{i}"),
}
}
@ -189,14 +185,7 @@ pub(crate) fn view_memory_layout(
| Definition::SelfType(_) => "[ROOT]".to_owned(),
// def is an item
def => def
.name(db)
.map(|n| {
n.as_str()
.map(|s| s.to_owned())
.unwrap_or_else(|| format!(".{}", n.as_tuple_index().unwrap()))
})
.unwrap_or("[ROOT]".to_owned()),
def => def.name(db).map(|n| n.as_str().to_owned()).unwrap_or("[ROOT]".to_owned()),
};
let typename = ty.display(db).to_string();