Simplify the ttdelim_span test.

The existing code is a very complex and inefficient way to the get the
span of the last token.
This commit is contained in:
Nicholas Nethercote 2023-07-27 09:39:28 +10:00
parent 8771282d4e
commit 53379a7b65

View File

@ -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 }"),