aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/name.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-27 18:02:08 +0000
committerAleksey Kladov <[email protected]>2018-12-27 18:02:08 +0000
commit63f54d234f0d622d043dca8176f0715889a6ed48 (patch)
treef00675907234c81c0538c5a9178dad09e4169d63 /crates/ra_hir/src/name.rs
parenta9f55029b9db3bcd439d31c5007785299f7d4025 (diff)
dont leak Name details in testing
Diffstat (limited to 'crates/ra_hir/src/name.rs')
-rw-r--r--crates/ra_hir/src/name.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_hir/src/name.rs b/crates/ra_hir/src/name.rs
index cdad31be7..e4fc141a6 100644
--- a/crates/ra_hir/src/name.rs
+++ b/crates/ra_hir/src/name.rs
@@ -5,7 +5,7 @@ use ra_syntax::{ast, SmolStr};
5/// `Name` is a wrapper around string, which is used in hir for both references 5/// `Name` is a wrapper around string, which is used in hir for both references
6/// and declarations. In theory, names should also carry hygene info, but we are 6/// and declarations. In theory, names should also carry hygene info, but we are
7/// not there yet! 7/// not there yet!
8#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8#[derive(Clone, PartialEq, Eq, Hash)]
9pub struct Name { 9pub struct Name {
10 text: SmolStr, 10 text: SmolStr,
11} 11}
@@ -16,6 +16,12 @@ impl fmt::Display for Name {
16 } 16 }
17} 17}
18 18
19impl fmt::Debug for Name {
20 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21 fmt::Debug::fmt(&self.text, f)
22 }
23}
24
19impl Name { 25impl Name {
20 pub(crate) fn as_known_name(&self) -> Option<KnownName> { 26 pub(crate) fn as_known_name(&self) -> Option<KnownName> {
21 let name = match self.text.as_str() { 27 let name = match self.text.as_str() {
@@ -38,15 +44,9 @@ impl Name {
38 Some(name) 44 Some(name)
39 } 45 }
40 46
41 #[cfg(not(test))]
42 fn new(text: SmolStr) -> Name { 47 fn new(text: SmolStr) -> Name {
43 Name { text } 48 Name { text }
44 } 49 }
45
46 #[cfg(test)]
47 pub(crate) fn new(text: SmolStr) -> Name {
48 Name { text }
49 }
50} 50}
51 51
52pub(crate) trait AsName { 52pub(crate) trait AsName {