aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r--crates/ra_mbe/src/lib.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index be9ea3ebb..ea2104b1c 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -99,13 +99,31 @@ pub(crate) struct Subtree {
99 pub(crate) token_trees: Vec<TokenTree>, 99 pub(crate) token_trees: Vec<TokenTree>,
100} 100}
101 101
102#[derive(Clone, Debug, PartialEq, Eq)] 102#[derive(Clone, Debug, Eq)]
103pub(crate) enum Separator { 103pub(crate) enum Separator {
104 Literal(tt::Literal), 104 Literal(tt::Literal),
105 Ident(tt::Ident), 105 Ident(tt::Ident),
106 Puncts(SmallVec<[tt::Punct; 3]>), 106 Puncts(SmallVec<[tt::Punct; 3]>),
107} 107}
108 108
109// Note that when we compare a Separator, we just care about its textual value.
110impl PartialEq for crate::Separator {
111 fn eq(&self, other: &crate::Separator) -> bool {
112 use crate::Separator::*;
113
114 match (self, other) {
115 (Ident(ref a), Ident(ref b)) => a.text == b.text,
116 (Literal(ref a), Literal(ref b)) => a.text == b.text,
117 (Puncts(ref a), Puncts(ref b)) if a.len() == b.len() => {
118 let a_iter = a.iter().map(|a| a.char);
119 let b_iter = b.iter().map(|b| b.char);
120 a_iter.eq(b_iter)
121 }
122 _ => false,
123 }
124 }
125}
126
109#[derive(Clone, Debug, PartialEq, Eq)] 127#[derive(Clone, Debug, PartialEq, Eq)]
110pub(crate) struct Repeat { 128pub(crate) struct Repeat {
111 pub(crate) subtree: Subtree, 129 pub(crate) subtree: Subtree,
@@ -1270,6 +1288,6 @@ cfg_if ! {
1270 } 1288 }
1271 } 1289 }
1272"#, 1290"#,
1273 "__cfg_if_items ! {() ; (() (mod libunwind ; pub use libunwind :: * ;)) ,}"); 1291 "__cfg_if_items ! {() ; ((target_env = \"msvc\") ()) , ((all (target_arch = \"wasm32\" , not (target_os = \"emscripten\"))) ()) , (() (mod libunwind ; pub use libunwind :: * ;)) ,}");
1274 } 1292 }
1275} 1293}