about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2016-04-26 16:27:10 +0200
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2016-04-26 16:27:10 +0200
commit6343f261f4aeacdd292bf07998ef5faf6e90d57b (patch)
tree086bb7c2a2b1af4d22df26d8085911935ed5555e /src/libsyntax
parentcfae4dea875ddcc5f23481106a149ea15b6be1e5 (diff)
downloadrust-6343f261f4aeacdd292bf07998ef5faf6e90d57b.tar.gz
rust-6343f261f4aeacdd292bf07998ef5faf6e90d57b.zip
allow InternedString to be compared to &str directly
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/attr.rs6
-rw-r--r--src/libsyntax/parse/token.rs22
2 files changed, 25 insertions, 3 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index dd414c463c7..8761ca37178 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -333,11 +333,11 @@ pub enum InlineAttr {
 pub fn find_inline_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> InlineAttr {
     attrs.iter().fold(InlineAttr::None, |ia,attr| {
         match attr.node.value.node {
-            MetaItemKind::Word(ref n) if *n == "inline" => {
+            MetaItemKind::Word(ref n) if n == "inline" => {
                 mark_used(attr);
                 InlineAttr::Hint
             }
-            MetaItemKind::List(ref n, ref items) if *n == "inline" => {
+            MetaItemKind::List(ref n, ref items) if n == "inline" => {
                 mark_used(attr);
                 if items.len() != 1 {
                     diagnostic.map(|d|{ d.span_err(attr.span, "expected one argument"); });
@@ -711,7 +711,7 @@ pub fn require_unique_names(diagnostic: &Handler, metas: &[P<MetaItem>]) {
 pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr> {
     let mut acc = Vec::new();
     match attr.node.value.node {
-        ast::MetaItemKind::List(ref s, ref items) if *s == "repr" => {
+        ast::MetaItemKind::List(ref s, ref items) if s == "repr" => {
             mark_used(attr);
             for item in items {
                 match item.node {
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index fcb6c3539db..47de32ed7d0 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -566,6 +566,28 @@ impl<'a> PartialEq<InternedString> for &'a str {
     }
 }
 
+impl PartialEq<str> for InternedString {
+    #[inline(always)]
+    fn eq(&self, other: &str) -> bool {
+        PartialEq::eq(&self.string[..], other)
+    }
+    #[inline(always)]
+    fn ne(&self, other: &str) -> bool {
+        PartialEq::ne(&self.string[..], other)
+    }
+}
+
+impl PartialEq<InternedString> for str {
+    #[inline(always)]
+    fn eq(&self, other: &InternedString) -> bool {
+        PartialEq::eq(self, &other.string[..])
+    }
+    #[inline(always)]
+    fn ne(&self, other: &InternedString) -> bool {
+        PartialEq::ne(self, &other.string[..])
+    }
+}
+
 impl Decodable for InternedString {
     fn decode<D: Decoder>(d: &mut D) -> Result<InternedString, D::Error> {
         Ok(intern(d.read_str()?.as_ref()).as_str())