Expand description
This module handles checking if the span given is from a proc-macro or not.
Proc-macros are capable of setting the span of every token they output to a few possible spans. This includes spans we can detect easily as coming from a proc-macro (e.g. the call site or the def site), and spans we canβt easily detect as such (e.g. the span of any token passed into the proc macro). This capability means proc-macros are capable of generating code with a span that looks like it was written by the user, but which should not be linted by clippy as it was generated by an external macro.
That brings us to this module. The current approach is to determine a small bit of text which
must exist at both the start and the end of an item (e.g. an expression or a path) assuming the
code was written, and check if the span contains that text. Note this will only work correctly
if the span is not from a macro_rules
based macro.
Macros§
- impl_
with_ πsearch_ pat
Enums§
- The search pattern to look for. Used by
span_matches_pat
Traits§
Functions§
- attr_
search_ πpat - expr_
search_ πpat Get the search patterns to use for the given expression - field_
def_ πsearch_ pat - fn_
header_ πsearch_ pat - fn_
kind_ πpat - ident_
search_ πpat - impl_
item_ πsearch_ pat - Checks if the item likely came from a proc-macro.
- Checks if the span actually refers to an if expression
- Checks if the span actually refers to a match expression
- item_
search_ πpat - lit_
search_ πpat Get the search patterns to use for the given literal - path_
search_ πpat - qpath_
search_ πpat Get the search patterns to use for the given path - span_
matches_ πpat Checks if the start and the end of the spanβs text matches the patterns. This will return false if the span crosses multiple files or if source is not available. - ty_
search_ πpat - variant_
search_ πpat