duplicate
duplicate copied to clipboard
Confusing error message when not using parametric substitution correctly
Situation:
When trying to use parametric substitution but forgetting to encapsulate the argument to a parametrized identifier in []
, the resulting error message is confusing.
Reproduction:
A simple example is to try and create a duplicate with and without &
:
#[duplicate(refs(T); [& T]; [T])]
fn from(x: refs(Bits<1, false>)) -> bool {
x.value == 1
}
Expected Behavior:
An error message pointing out that the argument to refs
is not encapsulated in []
.
Actual Behavior:
The error message:
message: Error substituting identifier with arguments: ()
Affected Versions:
Only tested on 0.3.0
Local Environment:
Using default features
Miscellaneous:
Implementing better error messages cannot commence before we have a test setup ready for testing the error messages.
Such a test setup should be very similar to our expand-tests using macrotest
. However, the difference is that the existing tests check that compilation succeeds while the tests needed here check that compilation fails with some error. This cannot be done using macrotest
.
trybuild
is available for this. However, as our experience has shown (eupn/macrotest#41, eupn/macrotest#43), trybuild
will need the ability to configure features at the least (see dtolnay/trybuild#108).