Skip to content

Commit 41ad624

Browse files
appease clippy
1 parent 6fd51e7 commit 41ad624

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint;
22
use clippy_utils::qualify_min_const_fn::is_min_const_fn;
33
use clippy_utils::ty::has_drop;
4-
use clippy_utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, meets_msrv, msrvs, trait_ref_of_method};
4+
use clippy_utils::{is_entrypoint_fn, meets_msrv, msrvs, trait_ref_of_method};
55
use rustc_hir as hir;
66
use rustc_hir::def_id::CRATE_DEF_ID;
77
use rustc_hir::intravisit::FnKind;
@@ -104,7 +104,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
104104
}
105105

106106
// Building MIR for `fn`s with unsatisfiable preds results in ICE.
107-
if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) {
107+
if cx.tcx.item_has_impossible_predicates(def_id.to_def_id()) {
108108
return;
109109
}
110110

src/tools/clippy/clippy_lints/src/redundant_clone.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then};
22
use clippy_utils::source::snippet_opt;
33
use clippy_utils::ty::{has_drop, is_copy, is_type_diagnostic_item, walk_ptrs_ty_depth};
4-
use clippy_utils::{fn_has_unsatisfiable_preds, match_def_path, paths};
4+
use clippy_utils::{match_def_path, paths};
55
use if_chain::if_chain;
66
use rustc_data_structures::fx::FxHashMap;
77
use rustc_errors::Applicability;
@@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
8484
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
8585

8686
// Building MIR for `fn`s with unsatisfiable preds results in ICE.
87-
if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) {
87+
if cx.tcx.item_has_impossible_predicates(def_id.to_def_id()) {
8888
return;
8989
}
9090

src/tools/clippy/clippy_utils/src/lib.rs

+1-26
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use rustc_middle::ty::fast_reject::SimplifiedTypeGen::{
9191
ArraySimplifiedType, BoolSimplifiedType, CharSimplifiedType, FloatSimplifiedType, IntSimplifiedType,
9292
PtrSimplifiedType, SliceSimplifiedType, StrSimplifiedType, UintSimplifiedType,
9393
};
94-
use rustc_middle::ty::{layout::IntegerExt, BorrowKind, DefIdTree, Ty, TyCtxt, TypeAndMut, TypeFoldable, UpvarCapture};
94+
use rustc_middle::ty::{layout::IntegerExt, BorrowKind, DefIdTree, Ty, TyCtxt, TypeAndMut, UpvarCapture};
9595
use rustc_middle::ty::{FloatTy, IntTy, UintTy};
9696
use rustc_semver::RustcVersion;
9797
use rustc_session::Session;
@@ -1891,31 +1891,6 @@ pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool {
18911891
}
18921892
}
18931893

1894-
/// Check if it's even possible to satisfy the `where` clause for the item.
1895-
///
1896-
/// `trivial_bounds` feature allows functions with unsatisfiable bounds, for example:
1897-
///
1898-
/// ```ignore
1899-
/// fn foo() where i32: Iterator {
1900-
/// for _ in 2i32 {}
1901-
/// }
1902-
/// ```
1903-
pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool {
1904-
use rustc_trait_selection::traits;
1905-
let predicates = cx
1906-
.tcx
1907-
.predicates_of(did)
1908-
.predicates
1909-
.iter()
1910-
.filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None });
1911-
traits::impossible_predicates(
1912-
cx.tcx,
1913-
traits::elaborate_predicates(cx.tcx, predicates)
1914-
.map(|o| o.predicate)
1915-
.collect::<Vec<_>>(),
1916-
)
1917-
}
1918-
19191894
/// Returns the `DefId` of the callee if the given expression is a function or method call.
19201895
pub fn fn_def_id(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<DefId> {
19211896
match &expr.kind {

0 commit comments

Comments
 (0)