Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/name.rs')
-rw-r--r--crates/hir-expand/src/name.rs48
1 files changed, 0 insertions, 48 deletions
diff --git a/crates/hir-expand/src/name.rs b/crates/hir-expand/src/name.rs
index 18b0793f10..87c663eec8 100644
--- a/crates/hir-expand/src/name.rs
+++ b/crates/hir-expand/src/name.rs
@@ -14,10 +14,6 @@ use syntax::{ast, SmolStr, SyntaxKind};
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Name(Repr);
-/// `EscapedName` will add a prefix "r#" to the wrapped `Name` when it is a raw identifier
-#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
-pub struct EscapedName<'a>(&'a Name);
-
/// Wrapper of `Name` to print the name without "r#" even when it is a raw identifier.
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UnescapedName<'a>(&'a Name);
@@ -42,21 +38,6 @@ fn is_raw_identifier(name: &str) -> bool {
is_keyword && !matches!(name, "self" | "crate" | "super" | "Self")
}
-impl<'a> fmt::Display for EscapedName<'a> {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match &self.0 .0 {
- Repr::Text(text) => {
- if is_raw_identifier(text) {
- write!(f, "r#{}", &text)
- } else {
- fmt::Display::fmt(&text, f)
- }
- }
- Repr::TupleField(idx) => fmt::Display::fmt(&idx, f),
- }
- }
-}
-
impl<'a> fmt::Display for UnescapedName<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 .0 {
@@ -86,31 +67,6 @@ impl<'a> UnescapedName<'a> {
}
}
-impl<'a> EscapedName<'a> {
- pub fn is_escaped(&self) -> bool {
- match &self.0 .0 {
- Repr::Text(it) => is_raw_identifier(&it),
- Repr::TupleField(_) => false,
- }
- }
-
- /// Returns the textual representation of this name as a [`SmolStr`].
- /// Prefer using this over [`ToString::to_string`] if possible as this conversion is cheaper in
- /// the general case.
- pub fn to_smol_str(&self) -> SmolStr {
- match &self.0 .0 {
- Repr::Text(it) => {
- if is_raw_identifier(&it) {
- SmolStr::from_iter(["r#", &it])
- } else {
- it.clone()
- }
- }
- Repr::TupleField(it) => SmolStr::new(&it.to_string()),
- }
- }
-}
-
impl Name {
/// Note: this is private to make creating name from random string hard.
/// Hopefully, this should allow us to integrate hygiene cleaner in the
@@ -181,10 +137,6 @@ impl Name {
}
}
- pub fn escaped(&self) -> EscapedName<'_> {
- EscapedName(self)
- }
-
pub fn unescaped(&self) -> UnescapedName<'_> {
UnescapedName(self)
}