-use crate::utils::paths::STRING;
-use crate::utils::{match_def_path, span_lint_and_help};
+use clippy_utils::diagnostics::span_lint_and_help;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
use rustc_hir::{Expr, ExprKind, PathSegment};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
-use rustc_span::{source_map::Spanned, Span};
+use rustc_span::{source_map::Spanned, symbol::sym, Span};
declare_clippy_lint! {
- /// **What it does:**
+ /// ### What it does
/// Checks for calls to `ends_with` with possible file extensions
/// and suggests to use a case-insensitive approach instead.
///
- /// **Why is this bad?**
+ /// ### Why is this bad?
/// `ends_with` is case-sensitive and may not detect files with a valid extension.
///
- /// **Known problems:** None.
- ///
- /// **Example:**
- ///
+ /// ### Example
/// ```rust
/// fn is_rust_file(filename: &str) -> bool {
/// filename.ends_with(".rs")
return Some(span);
},
ty::Adt(&ty::AdtDef { did, .. }, _) => {
- if match_def_path(ctx, did, &STRING) {
+ if ctx.tcx.is_diagnostic_item(sym::string_type, did) {
return Some(span);
}
},