diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-07-27 09:39:28 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-07-27 09:41:49 +1000 |
| commit | 53379a7b65055fc272db1178f68c9cef9b4aa3bc (patch) | |
| tree | ffccd4edcbfeb0acd93c59e8903f0ae66e08c34c | |
| parent | 8771282d4e7a5c4569e49d1f878fb3ba90a974d0 (diff) | |
| download | rust-53379a7b65055fc272db1178f68c9cef9b4aa3bc.tar.gz rust-53379a7b65055fc272db1178f68c9cef9b4aa3bc.zip | |
Simplify the `ttdelim_span` test.
The existing code is a very complex and inefficient way to the get the span of the last token.
| -rw-r--r-- | compiler/rustc_expand/src/parse/tests.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs index 8b37728b60f..f891850963e 100644 --- a/compiler/rustc_expand/src/parse/tests.rs +++ b/compiler/rustc_expand/src/parse/tests.rs @@ -294,9 +294,7 @@ fn ttdelim_span() { .unwrap(); let ast::ExprKind::MacCall(mac) = &expr.kind else { panic!("not a macro") }; - let tts: Vec<_> = mac.args.tokens.clone().into_trees().collect(); - - let span = tts.iter().rev().next().unwrap().span(); + let span = mac.args.tokens.trees().last().unwrap().span(); match sess.source_map().span_to_snippet(span) { Ok(s) => assert_eq!(&s[..], "{ body }"), |
