Rollup merge of #155007 - josetorrs:rename-is-impl-trait, r=WaffleLapkin,Kivooeo

renaming method is_impl_trait to is_opaque

Completing one of the tasks mentioned in this issue: https://github.com/rust-lang/rust/issues/154941

r? @WaffleLapkin
This commit is contained in:
Jacob Pratt
2026-04-08 23:04:00 -04:00
committed by GitHub
6 changed files with 6 additions and 6 deletions
@@ -2167,7 +2167,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) {
for def_id in visitor.opaques { for def_id in visitor.opaques {
let ty_span = tcx.def_span(def_id); let ty_span = tcx.def_span(def_id);
if !seen.contains(&ty_span) { 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}`")); err.span_label(ty_span, format!("returning this {descr}type `{ty}`"));
seen.insert(ty_span); seen.insert(ty_span);
} }
@@ -1462,7 +1462,7 @@ fn cat_projection(
&& self && self
.cx .cx
.structurally_resolve_type(self.cx.tcx().hir_span(base_place.hir_id), place_ty) .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 }); projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty });
} }
+1 -1
View File
@@ -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; let def_id = trait_predicate.trait_ref.def_id;
if cx.tcx.is_lang_item(def_id, LangItem::Drop) { if cx.tcx.is_lang_item(def_id, LangItem::Drop) {
// Explicitly allow `impl Drop`, a drop-guards-as-unnameable-type pattern. // 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; continue;
} }
let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return }; let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return };
+1 -1
View File
@@ -1594,7 +1594,7 @@ pub fn is_fn_ptr(self) -> bool {
} }
#[inline] #[inline]
pub fn is_impl_trait(self) -> bool { pub fn is_opaque(self) -> bool {
matches!(self.kind(), Alias(ty::AliasTy { kind: ty::Opaque { .. }, .. })) matches!(self.kind(), Alias(ty::AliasTy { kind: ty::Opaque { .. }, .. }))
} }
@@ -41,7 +41,7 @@ fn needs_turbofish<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'tcx>) -> bool
if !fn_return_ty if !fn_return_ty
.skip_binder() .skip_binder()
.walk() .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; return false;
}, },
@@ -207,7 +207,7 @@ fn fn_inputs_has_impl_trait_ty(cx: &LateContext<'_>, def_id: LocalDefId) -> bool
inputs.iter().any(|input| { inputs.iter().any(|input| {
matches!( matches!(
input.kind(), 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()
) )
}) })
} }