diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 9b44034adc23..b55506117c1d 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -2167,7 +2167,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) { for def_id in visitor.opaques { let ty_span = tcx.def_span(def_id); if !seen.contains(&ty_span) { - let descr = if ty.is_impl_trait() { "opaque " } else { "" }; + let descr = if ty.is_opaque() { "opaque " } else { "" }; err.span_label(ty_span, format!("returning this {descr}type `{ty}`")); seen.insert(ty_span); } diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 9587b774c4ff..f3d0b4d000c2 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -1462,7 +1462,7 @@ fn cat_projection( && self .cx .structurally_resolve_type(self.cx.tcx().hir_span(base_place.hir_id), place_ty) - .is_impl_trait() + .is_opaque() { projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty }); } diff --git a/compiler/rustc_lint/src/traits.rs b/compiler/rustc_lint/src/traits.rs index 99222742b65d..9c2aada46c41 100644 --- a/compiler/rustc_lint/src/traits.rs +++ b/compiler/rustc_lint/src/traits.rs @@ -97,7 +97,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { let def_id = trait_predicate.trait_ref.def_id; if cx.tcx.is_lang_item(def_id, LangItem::Drop) { // Explicitly allow `impl Drop`, a drop-guards-as-unnameable-type pattern. - if trait_predicate.trait_ref.self_ty().is_impl_trait() { + if trait_predicate.trait_ref.self_ty().is_opaque() { continue; } let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return }; diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 7b30723d291c..08bfe15137a2 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1594,7 +1594,7 @@ pub fn is_fn_ptr(self) -> bool { } #[inline] - pub fn is_impl_trait(self) -> bool { + pub fn is_opaque(self) -> bool { matches!(self.kind(), Alias(ty::AliasTy { kind: ty::Opaque { .. }, .. })) } diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_fold.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_fold.rs index 367d98ece195..0b38bdcdf544 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_fold.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_fold.rs @@ -41,7 +41,7 @@ fn needs_turbofish<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'tcx>) -> bool if !fn_return_ty .skip_binder() .walk() - .any(|generic| generic.as_type().is_some_and(Ty::is_impl_trait)) => + .any(|generic| generic.as_type().is_some_and(Ty::is_opaque)) => { return false; }, diff --git a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs index c9fcc1bb6aba..99c326671843 100644 --- a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs +++ b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs @@ -207,7 +207,7 @@ fn fn_inputs_has_impl_trait_ty(cx: &LateContext<'_>, def_id: LocalDefId) -> bool inputs.iter().any(|input| { matches!( input.kind(), - &ty::Alias(ty::AliasTy { kind: ty::Free{def_id} , ..}) if cx.tcx.type_of(def_id).skip_binder().is_impl_trait() + &ty::Alias(ty::AliasTy { kind: ty::Free{def_id} , ..}) if cx.tcx.type_of(def_id).skip_binder().is_opaque() ) }) }