Skip to content

Commit 52fa003

Browse files
committed
Auto merge of rust-lang#148193 - camsteffen:remove-qpath-langitem, r=cjgillot
Remove `QPath::LangItem` Closes rust-lang#115178. r? cjgillot
2 parents 78db66e + a2d8955 commit 52fa003

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+99
-133
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/indexing_slicing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
124124
let note = "the suggestion might not be applicable in constant blocks";
125125
let ty = cx.typeck_results().expr_ty(array).peel_refs();
126126
let allowed_in_tests = self.allow_indexing_slicing_in_tests && is_in_test(cx.tcx, expr.hir_id);
127-
if let Some(range) = higher::Range::hir(index) {
127+
if let Some(range) = higher::Range::hir(cx, index) {
128128
// Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..]
129129
if let ty::Array(_, s) = ty.kind() {
130130
let size: u128 = if let Some(size) = s.try_to_target_usize(cx.tcx) {

clippy_lints/src/infinite_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
178178
Finite
179179
}
180180
},
181-
ExprKind::Struct(..) => higher::Range::hir(expr).is_some_and(|r| r.end.is_none()).into(),
181+
ExprKind::Struct(..) => higher::Range::hir(cx, expr).is_some_and(|r| r.end.is_none()).into(),
182182
_ => Finite,
183183
}
184184
}

clippy_lints/src/large_futures.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
44
use clippy_utils::ty::implements_trait;
55
use rustc_abi::Size;
66
use rustc_errors::Applicability;
7-
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource, QPath};
7+
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_session::impl_lint_pass;
1010

@@ -58,7 +58,8 @@ impl<'tcx> LateLintPass<'tcx> for LargeFuture {
5858
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
5959
if let ExprKind::Match(scrutinee, _, MatchSource::AwaitDesugar) = expr.kind
6060
&& let ExprKind::Call(func, [arg]) = scrutinee.kind
61-
&& let ExprKind::Path(QPath::LangItem(LangItem::IntoFutureIntoFuture, ..)) = func.kind
61+
&& let ExprKind::Path(qpath) = func.kind
62+
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::IntoFutureIntoFuture)
6263
&& !expr.span.from_expansion()
6364
&& let ty = cx.typeck_results().expr_ty(arg)
6465
&& let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait()

clippy_lints/src/loops/char_indices_as_byte_indices.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn check_index_usage<'tcx>(
131131
fn index_consumed_at<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> {
132132
for (_, node) in cx.tcx.hir_parent_iter(expr.hir_id) {
133133
match node {
134-
Node::Expr(expr) if higher::Range::hir(expr).is_some() => {},
134+
Node::Expr(expr) if higher::Range::hir(cx, expr).is_some() => {},
135135
Node::ExprField(_) => {},
136136
Node::Expr(expr) => return Some(expr),
137137
_ => break,

clippy_lints/src/loops/manual_memcpy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(super) fn check<'tcx>(
2929
end: Some(end),
3030
limits,
3131
span: _,
32-
}) = higher::Range::hir(arg)
32+
}) = higher::Range::hir(cx, arg)
3333
// the var must be a single name
3434
&& let PatKind::Binding(_, canonical_id, _, _) = pat.kind
3535
{

clippy_lints/src/loops/manual_slice_fill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(super) fn check<'tcx>(
3232
end: Some(end),
3333
limits: RangeLimits::HalfOpen,
3434
span: _,
35-
}) = higher::Range::hir(arg)
35+
}) = higher::Range::hir(cx, arg)
3636
&& let ExprKind::Lit(Spanned {
3737
node: LitKind::Int(Pu128(0), _),
3838
..

clippy_lints/src/loops/mut_range_bound.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, body: &Expr<'_>) {
1616
start: Some(start),
1717
end: Some(end),
1818
..
19-
}) = higher::Range::hir(arg)
19+
}) = higher::Range::hir(cx, arg)
2020
&& let (mut_id_start, mut_id_end) = (check_for_mutability(cx, start), check_for_mutability(cx, end))
2121
&& (mut_id_start.is_some() || mut_id_end.is_some())
2222
{

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(super) fn check<'tcx>(
3131
ref end,
3232
limits,
3333
span,
34-
}) = higher::Range::hir(arg)
34+
}) = higher::Range::hir(cx, arg)
3535
// the var must be a single name
3636
&& let PatKind::Binding(_, canonical_id, ident, _) = pat.kind
3737
{

0 commit comments

Comments
 (0)