Disambiguate call to parse in fails_with
Hi there,
I thought I'd mention an issue I had using pest fails_with with other libraries that derive functions with the same signature. This is following a discussion on another thread for a library that depends on pest.
Suppose you want to test a parser type (from the fails_with example):
fails_with! {
parser: AbcParser,
input: "abcdf",
rule: Rule::a,
positives: vec![Rule::c],
negatives: vec![],
pos: 4
};
where AbcParser is present in a single file that implements the parse function with #[derive(Parser)]. Suppose then in the same file you use a library that additionally implements another trait Y, also with a parse function for the AbcParser (which would be common in a parser file). From this point onwards fails_with would fail to build&run as we run into a situation where AbcParser implements parse for both the pest::Parser trait and the other trait Y and the fails_with macro cannot disambiguate which call to parse to use. We run into the following situation:
I have a type A and two traits X and Y,
Both X and Y have trait functions f and are provided by external authors (one of them is pest)
A is constructed and tested by implementing both X and Y with externally provided macros from X and Y
To use this In code we can disambiguate calls to f by the types <A as X>, however if I want to test this using the fails_with test macro provided by the authors of trait X (pest) I get error E0034 which says I need to disambiguate the call to f.
So far I have not found a way to disambiguate which f (or in this case parse) to call the use of parse is from an external crate. In this particular case I have a type AbcParser which implements a parse function for pest, and a parse function for pest_consume, when I call fails_with the test fails to build. I suppose this is a case of patches welcome! :)
I hope this is useful