Skip to content

Commit a2d8955

Browse files
committed
Remove QPath::LangItem
1 parent e2b3508 commit a2d8955

File tree

14 files changed

+10
-51
lines changed

14 files changed

+10
-51
lines changed

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ fn get_item_name(item: &Item<'_>) -> Option<String> {
550550
// This case doesn't exist in the clippy tests codebase.
551551
None
552552
},
553-
QPath::LangItem(_, _) => None,
554553
}
555554
} else {
556555
// Impls for anything that isn't a named type can be skipped.

clippy_lints/src/incompatible_msrv.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::msrvs::Msrv;
44
use clippy_utils::{is_in_const_context, is_in_test};
55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_hir::def::DefKind;
7-
use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, HirId, QPath, RustcVersion, StabilityLevel, StableSince};
7+
use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, HirId, RustcVersion, StabilityLevel, StableSince};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_middle::ty::TyCtxt;
1010
use rustc_session::impl_lint_pass;
@@ -193,10 +193,7 @@ impl<'tcx> LateLintPass<'tcx> for IncompatibleMsrv {
193193
self.emit_lint_if_under_msrv(cx, method_did, expr.hir_id, span);
194194
}
195195
},
196-
// Desugaring into function calls by the compiler will use `QPath::LangItem` variants. Those should
197-
// not be linted as they will not be generated in older compilers if the function is not available,
198-
// and the compiler is allowed to call unstable functions.
199-
ExprKind::Path(qpath @ (QPath::Resolved(..) | QPath::TypeRelative(..))) => {
196+
ExprKind::Path(qpath) => {
200197
if let Some(path_def_id) = cx.qpath_res(&qpath, expr.hir_id).opt_def_id() {
201198
self.emit_lint_if_under_msrv(cx, path_def_id, expr.hir_id, expr.span);
202199
}
@@ -206,7 +203,7 @@ impl<'tcx> LateLintPass<'tcx> for IncompatibleMsrv {
206203
}
207204

208205
fn check_ty(&mut self, cx: &LateContext<'tcx>, hir_ty: &'tcx hir::Ty<'tcx, AmbigArg>) {
209-
if let hir::TyKind::Path(qpath @ (QPath::Resolved(..) | QPath::TypeRelative(..))) = hir_ty.kind
206+
if let hir::TyKind::Path(qpath) = hir_ty.kind
210207
&& let Some(ty_def_id) = cx.qpath_res(&qpath, hir_ty.hir_id).opt_def_id()
211208
// `CStr` and `CString` have been moved around but have been available since Rust 1.0.0
212209
&& !matches!(cx.tcx.get_diagnostic_name(ty_def_id), Some(sym::cstr_type | sym::cstring_type))

clippy_lints/src/methods/unnecessary_fallible_conversions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ pub(super) fn check_function(cx: &LateContext<'_>, expr: &Expr<'_>, callee: &Exp
181181
QPath::TypeRelative(_, seg) => Some(SpansKind::Fn {
182182
fn_span: seg.ident.span,
183183
}),
184-
QPath::LangItem(_, _) => unreachable!("`TryFrom` and `TryInto` are not lang items"),
185184
};
186185

187186
check(

clippy_lints/src/redundant_type_annotations.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ fn extract_fn_ty<'tcx>(
9797
// let a: String = String::new();
9898
// let a: String = String::get_string();
9999
hir::QPath::TypeRelative(..) => func_hir_id_to_func_ty(cx, call.hir_id),
100-
hir::QPath::LangItem(..) => None,
101100
}
102101
}
103102

clippy_lints/src/types/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ impl Types {
655655
}
656656
}
657657
},
658-
QPath::LangItem(..) => {},
659658
}
660659
},
661660
TyKind::Path(ref qpath) => {

clippy_lints/src/unconditional_recursion.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ fn get_hir_ty_def_id<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: rustc_hir::Ty<'tcx>) -> Op
106106
_ => None,
107107
}
108108
},
109-
QPath::LangItem(..) => None,
110109
}
111110
}
112111

@@ -291,7 +290,6 @@ fn is_default_method_on_current_ty<'tcx>(tcx: TyCtxt<'tcx>, qpath: QPath<'tcx>,
291290
}
292291
get_hir_ty_def_id(tcx, *ty) == Some(implemented_ty_id)
293292
},
294-
QPath::LangItem(..) => false,
295293
}
296294
}
297295

clippy_lints/src/unnecessary_map_on_constructor.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
6060
}
6161
},
6262
hir::QPath::TypeRelative(_, path) => path.ident.name,
63-
hir::QPath::LangItem(..) => return,
6463
};
6564
match constructor_symbol {
6665
sym::Some | sym::Ok if path.ident.name == sym::map => (),

clippy_lints/src/utils/author.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
270270
}
271271

272272
fn qpath(&self, qpath: &Binding<&QPath<'_>>, hir_id_binding: &str, hir_id: HirId) {
273-
if let QPath::LangItem(lang_item, ..) = *qpath.value {
274-
chain!(self, "matches!({qpath}, QPath::LangItem(LangItem::{lang_item:?}, _))");
275-
} else if let Some(def_id) = self.cx.qpath_res(qpath.value, hir_id).opt_def_id()
273+
if let Some(def_id) = self.cx.qpath_res(qpath.value, hir_id).opt_def_id()
276274
&& !def_id.is_local()
277275
{
278276
bind!(self, def_id);

clippy_utils/src/check_proc_macro.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ fn qpath_search_pat(path: &QPath<'_>) -> (Pat, Pat) {
121121
(start, end)
122122
},
123123
QPath::TypeRelative(_, name) => (Pat::Str(""), Pat::Sym(name.ident.name)),
124-
QPath::LangItem(..) => (Pat::Str(""), Pat::Str("")),
125124
}
126125
}
127126

clippy_utils/src/eager_or_lazy.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
167167
QPath::TypeRelative(_, name) => {
168168
self.eagerness |= fn_eagerness(self.cx, id, name.ident.name, !args.is_empty());
169169
},
170-
QPath::LangItem(..) => self.eagerness = Lazy,
171170
},
172171
_ => self.eagerness = Lazy,
173172
},

0 commit comments

Comments
 (0)