The author lint was generating invalid code as shown on issue:
https://github.com/rust-lang-nursery/rust-clippy/issues/2442
I've changed the generated code to properly track cast
expressions.
Unfortunatelly, I've had to rewrite the `visit_decl` method, to
avoid that last if of the chain will be added. After looking at the code,
this last line was being added because of the `let x: char` part, but not
because of the `0x45df as char` expression.
It seems that let statements should not generate code on the author
lint, but I'm not sure that this is true or if I'm breaking
something on other code generation parts.
Finally, I've added a test for the author lint, but I'm not sure that
this needs to be added to the testsuite.
This makes it so that the `empty_line_after_outer_attribute` lint only
checks for newlines between the end of the attribute and the beginning
of the following item.
We need to check for the empty line count being bigger than 2 because
now the snippet of valid code contains only `\n` and splitting it
produces `["", ""]`
Invalid code will contain more than 2 empty strings.
Fix span so it no longer contains the whole train-wreck of code and only
points to the problem function (for the unwrap_or lint).
https://github.com/rust-lang-nursery/rust-clippy/issues/2422
Update ui test methods - it had several cases where the error message
span is now shorter
This fixes an incorrect suggestion from the `useless_attribute` lint
when using `cfg_attr`.
Additionally, it will not show a suggestion anymore, if the attribute
begins on a previous line, because it is much harder to construct the
span of multi-line `cfg_attr` attributes as they don't appear in the AST.
To fix it completely, one would have to parse upwards into the file,
and find the beginning of the `cfg_attr` attribute.
This makes sure that empty lines in lint examples are preserved.
It also fixes the documentation for the invalid_ref lint, which was not
shown because of an extra newline before the lint declaration.
Doc comments are syntactic sugar for #[doc] attributes, so this lint was
catching them, too.
This commit makes it so that doc comments are ignored in this lint.
I think, for normal attributes it makes sense to warn about following empty
lines, for doc comments, less. This way the user has some freedom over
the formatting.