I am following this link Writing New lint . Although, author of this tutorial did't mentioned, but i have added following code at top of my
foo_functions.rs, otherwise my file is showing errors.
When i run cargo test in my directory c:\master_clippy, then i faced this error .
Whats going wrong ?
It seems like that guide might be outdated - in the latest version of Rust's AST,
ident.name is a
Symbol, not a string. I think you might need to change that to:
ident.as_str() == "foo"
Clippy relies quite heavily on the compiler's internals, so little breakages like this can happen quite easily. If this fixes your issue, I'd recommend submitting a pull request to update the guide
i have done as you said and also added
use syntax::source_map::symbol::Ident; but still facing problem
ident.name == Ident::from_str("foo")
| ^^^^^^^^^^^^^^^^^^^^^^ expected struct
syntax_pos::Symbol, found struct
note: expected type
I have updated my reply - to check the name alone, it seems like you need to call
as_str on the
Ident or the
Symbol. I can see several instances of this in the Clippy codebase.
If you try to do
ident == Ident::from_str("foo") as I originally suggested, it'll likely always fail, because the location data of the two
Ident instances will be different. Apologies for the misinformation!
thanks its works for me but with little changes
ident.name.as_str() == "foo" Because you forget to mention
ident.name.as_str() rather than
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.