You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected to see this happen:
The duplicate_item attribute should substitute cfg_filter for all(), meaning my_function should be available use. (see duplicate's documentation).
Instead, this happened:
error[E0425]: cannot find function `my_function` in this scope
--> src\main.rs:13:2
|
13 | my_function()
| ^^^^^^^^^^^ not found in this scope
The rust reference states that attributes are expanded in descending order, meaning duplicate_item should be expanded first (which should allow it to affect the cfg attribute). However this doesn't seem to be the case. A current workaround is to put the cfg( part in duplicate_item as well, which stops that attribute from expanding prematurely:
cfg and cfg_attr are currently the only case in which attributes are not expanded in left-to-right order, but we cannot change it due to backward compatibility.
One more workaround is to make a custom proc macro my_in_order_cfg that will expand to regular cfg.
It will expand in-order in this case.
I tried this code:
I expected to see this happen:
The
duplicate_item
attribute should substitutecfg_filter
forall()
, meaningmy_function
should be available use. (seeduplicate
's documentation).Instead, this happened:
The rust reference states that attributes are expanded in descending order, meaning
duplicate_item
should be expanded first (which should allow it to affect thecfg
attribute). However this doesn't seem to be the case. A current workaround is to put thecfg(
part induplicate_item
as well, which stops that attribute from expanding prematurely:However, my reading of the reference makes me believe this shouldn't be needed.
See also Emoun/duplicate#56 for the original use case. I have simplified it here to highlight the problem.
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: