Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
23 lines
771 B
Rust
23 lines
771 B
Rust
use clippy_utils::diagnostics::span_lint_and_help;
|
|
use clippy_utils::is_trait_method;
|
|
use rustc_hir as hir;
|
|
use rustc_lint::LateContext;
|
|
use rustc_span::{sym, Span};
|
|
|
|
use super::INSPECT_FOR_EACH;
|
|
|
|
/// lint use of `inspect().for_each()` for `Iterators`
|
|
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, inspect_span: Span) {
|
|
if is_trait_method(cx, expr, sym::Iterator) {
|
|
let msg = "called `inspect(..).for_each(..)` on an `Iterator`";
|
|
let hint = "move the code from `inspect(..)` to `for_each(..)` and remove the `inspect(..)`";
|
|
span_lint_and_help(
|
|
cx,
|
|
INSPECT_FOR_EACH,
|
|
inspect_span.with_hi(expr.span.hi()),
|
|
msg,
|
|
None,
|
|
hint,
|
|
);
|
|
}
|
|
}
|