Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Preprocess bracketed paste inside of attribute args #60

Merged
merged 2 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,12 @@ fn expand(input: TokenStream, contains_paste: &mut bool) -> Result<TokenStream>
*contains_paste = true;
} else {
let mut group_contains_paste = false;
let nested = match delimiter {
Delimiter::Bracket if lookbehind == Lookbehind::Pound => {
expand_attr(content, span, &mut group_contains_paste)?
}
Delimiter::Bracket if lookbehind == Lookbehind::PoundBang => {
expand_attr(content, span, &mut group_contains_paste)?
}
_ => expand(content, &mut group_contains_paste)?,
};
let mut nested = expand(content, &mut group_contains_paste)?;
if delimiter == Delimiter::Bracket
&& (lookbehind == Lookbehind::Pound || lookbehind == Lookbehind::PoundBang)
{
nested = expand_attr(nested, span, &mut group_contains_paste)?
}
let group = if group_contains_paste {
let mut group = Group::new(delimiter, nested);
group.set_span(span);
Expand Down
4 changes: 4 additions & 0 deletions tests/test_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ fn test_attr() {

#[::paste_test_suite::paste_test(k = "val" "ue")]
struct C;

#[paste_test(k = "va" [<l u>] e)]
struct D;
}

let _ = A;
let _ = B;
let _ = C;
let _ = D;
}

#[test]
Expand Down