diff options
author | Zac Pullar-Strecker <[email protected]> | 2020-07-31 03:12:44 +0100 |
---|---|---|
committer | Zac Pullar-Strecker <[email protected]> | 2020-07-31 03:12:44 +0100 |
commit | f05d7b41a719d848844b054a16477b29d0f063c6 (patch) | |
tree | 0a8a0946e8aef2ce64d4c13d0035ba41cce2daf3 /crates/ra_mbe | |
parent | 73ff610e41959e3e7c78a2b4b25b086883132956 (diff) | |
parent | 6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff) |
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Hasn't fixed tests yet.
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_expander/matcher.rs | 2 | ||||
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 2 | ||||
-rw-r--r-- | crates/ra_mbe/src/tests.rs | 18 |
5 files changed, 15 insertions, 14 deletions
diff --git a/crates/ra_mbe/Cargo.toml b/crates/ra_mbe/Cargo.toml index 4dec24914..a26746a19 100644 --- a/crates/ra_mbe/Cargo.toml +++ b/crates/ra_mbe/Cargo.toml | |||
@@ -3,6 +3,7 @@ edition = "2018" | |||
3 | name = "ra_mbe" | 3 | name = "ra_mbe" |
4 | version = "0.1.0" | 4 | version = "0.1.0" |
5 | authors = ["rust-analyzer developers"] | 5 | authors = ["rust-analyzer developers"] |
6 | license = "MIT OR Apache-2.0" | ||
6 | 7 | ||
7 | [lib] | 8 | [lib] |
8 | doctest = false | 9 | doctest = false |
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 9c450eaba..dec7ba22e 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -9,6 +9,9 @@ mod syntax_bridge; | |||
9 | mod tt_iter; | 9 | mod tt_iter; |
10 | mod subtree_source; | 10 | mod subtree_source; |
11 | 11 | ||
12 | #[cfg(test)] | ||
13 | mod tests; | ||
14 | |||
12 | pub use tt::{Delimiter, Punct}; | 15 | pub use tt::{Delimiter, Punct}; |
13 | 16 | ||
14 | use crate::{ | 17 | use crate::{ |
@@ -273,6 +276,3 @@ impl<T: Default> From<Result<T, ExpandError>> for ExpandResult<T> { | |||
273 | .map_or_else(|e| ExpandResult(Default::default(), Some(e)), |it| ExpandResult(it, None)) | 276 | .map_or_else(|e| ExpandResult(Default::default(), Some(e)), |it| ExpandResult(it, None)) |
274 | } | 277 | } |
275 | } | 278 | } |
276 | |||
277 | #[cfg(test)] | ||
278 | mod tests; | ||
diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs index 78f9efa1b..f9e515b81 100644 --- a/crates/ra_mbe/src/mbe_expander/matcher.rs +++ b/crates/ra_mbe/src/mbe_expander/matcher.rs | |||
@@ -260,7 +260,7 @@ impl<'a> TtIter<'a> { | |||
260 | | ('|', '=', None) | 260 | | ('|', '=', None) |
261 | | ('|', '|', None) => { | 261 | | ('|', '|', None) => { |
262 | let tt2 = self.next().unwrap().clone(); | 262 | let tt2 = self.next().unwrap().clone(); |
263 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt.clone(), tt2] }.into()) | 263 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into()) |
264 | } | 264 | } |
265 | _ => Ok(tt), | 265 | _ => Ok(tt), |
266 | } | 266 | } |
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index fc4133a67..5fc48507f 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -825,7 +825,7 @@ mod tests { | |||
825 | #[test] | 825 | #[test] |
826 | fn test_token_tree_multi_char_punct() { | 826 | fn test_token_tree_multi_char_punct() { |
827 | let source_file = ast::SourceFile::parse("struct Foo { a: x::Y }").ok().unwrap(); | 827 | let source_file = ast::SourceFile::parse("struct Foo { a: x::Y }").ok().unwrap(); |
828 | let struct_def = source_file.syntax().descendants().find_map(ast::StructDef::cast).unwrap(); | 828 | let struct_def = source_file.syntax().descendants().find_map(ast::Struct::cast).unwrap(); |
829 | let tt = ast_to_token_tree(&struct_def).unwrap().0; | 829 | let tt = ast_to_token_tree(&struct_def).unwrap().0; |
830 | token_tree_to_syntax_node(&tt, FragmentKind::Item).unwrap(); | 830 | token_tree_to_syntax_node(&tt, FragmentKind::Item).unwrap(); |
831 | } | 831 | } |
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index c43003fd6..707e84f42 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs | |||
@@ -258,7 +258,7 @@ fn test_expr_order() { | |||
258 | assert_eq_text!( | 258 | assert_eq_text!( |
259 | dump.trim(), | 259 | dump.trim(), |
260 | r#"[email protected] | 260 | r#"[email protected] |
261 | FN_DEF@0..15 | 261 | [email protected] |
262 | [email protected] "fn" | 262 | [email protected] "fn" |
263 | [email protected] | 263 | [email protected] |
264 | [email protected] "bar" | 264 | [email protected] "bar" |
@@ -490,13 +490,13 @@ fn test_expand_to_item_list() { | |||
490 | format!("{:#?}", tree).trim(), | 490 | format!("{:#?}", tree).trim(), |
491 | r#" | 491 | r#" |
492 | [email protected] | 492 | [email protected] |
493 | STRUCT_DEF@0..20 | 493 | [email protected] |
494 | [email protected] "struct" | 494 | [email protected] "struct" |
495 | [email protected] | 495 | [email protected] |
496 | [email protected] "Foo" | 496 | [email protected] "Foo" |
497 | RECORD_FIELD_DEF_[email protected] | 497 | [email protected] |
498 | [email protected] "{" | 498 | [email protected] "{" |
499 | RECORD_FIELD_DEF@10..19 | 499 | [email protected] |
500 | [email protected] | 500 | [email protected] |
501 | [email protected] "field" | 501 | [email protected] "field" |
502 | [email protected] ":" | 502 | [email protected] ":" |
@@ -506,13 +506,13 @@ [email protected] | |||
506 | [email protected] | 506 | [email protected] |
507 | [email protected] "u32" | 507 | [email protected] "u32" |
508 | [email protected] "}" | 508 | [email protected] "}" |
509 | STRUCT_DEF@20..40 | 509 | [email protected] |
510 | [email protected] "struct" | 510 | [email protected] "struct" |
511 | [email protected] | 511 | [email protected] |
512 | [email protected] "Bar" | 512 | [email protected] "Bar" |
513 | RECORD_FIELD_DEF_[email protected] | 513 | [email protected] |
514 | [email protected] "{" | 514 | [email protected] "{" |
515 | RECORD_FIELD_DEF@30..39 | 515 | [email protected] |
516 | [email protected] | 516 | [email protected] |
517 | [email protected] "field" | 517 | [email protected] "field" |
518 | [email protected] ":" | 518 | [email protected] ":" |
@@ -1467,7 +1467,7 @@ macro_rules! quick_error { | |||
1467 | buf [ ] | 1467 | buf [ ] |
1468 | queue [ ] | 1468 | queue [ ] |
1469 | ) => { | 1469 | ) => { |
1470 | quick_error!(ENUM_DEFINITION [enum $name $( #[$meta] )*] | 1470 | quick_error!(ENUMINITION [enum $name $( #[$meta] )*] |
1471 | body [] | 1471 | body [] |
1472 | queue [$( | 1472 | queue [$( |
1473 | $( #[$imeta] )* | 1473 | $( #[$imeta] )* |
@@ -1489,7 +1489,7 @@ quick_error ! (SORT [enum Wrapped # [derive (Debug)]] items [ | |||
1489 | "#, | 1489 | "#, |
1490 | ); | 1490 | ); |
1491 | 1491 | ||
1492 | assert_eq!(expanded.to_string(), "quick_error ! (ENUM_DEFINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;"); | 1492 | assert_eq!(expanded.to_string(), "quick_error ! (ENUMINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;"); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | #[test] | 1495 | #[test] |