duplicate icon indicating copy to clipboard operation
duplicate copied to clipboard

`duplicate` doesn't substitute in nested duplicate invocation

Open Emoun opened this issue 2 years ago • 0 comments

Situation:

Using duplicate_item, it is possible to substitute things in a nested (or lower) duplicate_item's invocation:


#[duplicate::duplicate_item(
	vals	[val; [41]; [42];];
)]
#[duplicate::duplicate_item(
	vals
)]
impl SomeType<val> for (){}

Here, vals substitutes into a valid invocation val; [41]; [42];. This is then used in the next duplicate_item as the invocation. This works fine and as expected, however, trying to do the same using duplicate doesn't work

Reproduction:

duplicate::duplicate!{
	[vals	[val; [41]; [42];];]
	duplicate!{
		[vals]
		impl SomeType<v2> for (){}
	}
}

Expected Behavior:

Expand to:

impl SomeType<41> for () {}
impl SomeType<42> for () {}

Actual Behavior:

Error is thrown:

error: Unexpected end of code. Expected substitution identifier or ';' instead.
  --> tests\tests.rs:16:1
   |
16 | / duplicate::duplicate!{
17 | |     [vals    [val; [41]; [42];];]
18 | |     duplicate!{
19 | |         [vals]
20 | |         impl SomeType<v2> for (){}
21 | |     }
22 | | }
   | |_^
   |
   = note: this error originates in the macro `duplicate::duplicate` (in Nightly builds, run with -Z macro-backtrace for more info)

Affected Versions:

0.4.1 and likely all since nested invocation was introduced.

Local Environment:

Miscellaneous:

Emoun avatar Jul 24 '22 14:07 Emoun