diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-07 00:32:56 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-07 00:32:56 +0000 |
commit | f0b7c02f16f717744e7edc79a405db14110393cf (patch) | |
tree | c0aaf8373aa42ce3b4037fad2f42efba07680f53 /crates/proc_macro_srv/src/tests/utils.rs | |
parent | 07a54f7ae451451292e3282f1e7defb4391b766f (diff) | |
parent | aea974939064b0f7b83de371a93ee4190c80e544 (diff) |
Merge #7892
7892: Fix TokenStream::from_str for input consisting of a single group with delimiter r=edwin0cheng a=kevinmehall
TokenStream holds a `tt::Subtree` but assumes its `delimiter` is always `None`. In particular, the iterator implementation iterates over the inner `token_trees` and ignores the `delimiter`.
However, `TokenStream::from_str` violated this assumption when the input consists of a single group by producing a Subtree with an outer delimiter, which was ignored as seen by a procedural macro.
`tt::Subtree` is just `pub delimiter: Option<Delimiter>, pub token_trees: Vec<TokenTree>`, so a Subtree that is statically guaranteed not to have a delimiter is just `Vec<TokenTree>`.
Fixes #7810
Fixes #7875
Co-authored-by: Kevin Mehall <[email protected]>
Diffstat (limited to 'crates/proc_macro_srv/src/tests/utils.rs')
-rw-r--r-- | crates/proc_macro_srv/src/tests/utils.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/proc_macro_srv/src/tests/utils.rs b/crates/proc_macro_srv/src/tests/utils.rs index 22813052d..0484c3af4 100644 --- a/crates/proc_macro_srv/src/tests/utils.rs +++ b/crates/proc_macro_srv/src/tests/utils.rs | |||
@@ -52,7 +52,7 @@ pub fn assert_expand( | |||
52 | let expander = dylib::Expander::new(&path).unwrap(); | 52 | let expander = dylib::Expander::new(&path).unwrap(); |
53 | let fixture = parse_string(ra_fixture).unwrap(); | 53 | let fixture = parse_string(ra_fixture).unwrap(); |
54 | 54 | ||
55 | let res = expander.expand(macro_name, &fixture.subtree, None).unwrap(); | 55 | let res = expander.expand(macro_name, &fixture.into_subtree(), None).unwrap(); |
56 | assert_eq_text!(&expect.trim(), &format!("{:?}", res)); | 56 | assert_eq_text!(&expect.trim(), &format!("{:?}", res)); |
57 | } | 57 | } |
58 | 58 | ||