mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Remove redundant in_trait from hir::TyKind::OpaqueDef
This commit is contained in:
parent
360f7d7b73
commit
f95bdf453e
@ -1776,7 +1776,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
hir::TyKind::OpaqueDef(
|
||||
hir::ItemId { owner_id: hir::OwnerId { def_id: opaque_ty_def_id } },
|
||||
generic_args,
|
||||
in_trait,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -832,7 +832,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
||||
fn get_future_inner_return_ty(&self, hir_ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> {
|
||||
let hir = self.infcx.tcx.hir();
|
||||
|
||||
let hir::TyKind::OpaqueDef(id, _, _) = hir_ty.kind else {
|
||||
let hir::TyKind::OpaqueDef(id, _) = hir_ty.kind else {
|
||||
span_bug!(
|
||||
hir_ty.span,
|
||||
"lowered return type of async fn is not OpaqueDef: {:?}",
|
||||
|
@ -2632,7 +2632,7 @@ impl<'hir> Ty<'hir> {
|
||||
}
|
||||
TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
|
||||
TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),
|
||||
TyKind::OpaqueDef(_, generic_args, _) => are_suggestable_generic_args(generic_args),
|
||||
TyKind::OpaqueDef(_, generic_args) => are_suggestable_generic_args(generic_args),
|
||||
TyKind::Path(QPath::TypeRelative(ty, segment)) => {
|
||||
ty.is_suggestable_infer_ty() || are_suggestable_generic_args(segment.args().args)
|
||||
}
|
||||
@ -2856,7 +2856,7 @@ pub enum TyKind<'hir> {
|
||||
/// possibly parameters) that are actually bound on the `impl Trait`.
|
||||
///
|
||||
/// The last parameter specifies whether this opaque appears in a trait definition.
|
||||
OpaqueDef(ItemId, &'hir [GenericArg<'hir>], bool),
|
||||
OpaqueDef(ItemId, &'hir [GenericArg<'hir>]),
|
||||
/// A trait object type `Bound1 + Bound2 + Bound3`
|
||||
/// where `Bound` is a trait or a lifetime.
|
||||
TraitObject(
|
||||
|
@ -894,7 +894,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) -> V::Resul
|
||||
TyKind::Path(ref qpath) => {
|
||||
try_visit!(visitor.visit_qpath(qpath, typ.hir_id, typ.span));
|
||||
}
|
||||
TyKind::OpaqueDef(item_id, lifetimes, _in_trait) => {
|
||||
TyKind::OpaqueDef(item_id, lifetimes) => {
|
||||
try_visit!(visitor.visit_nested_item(item_id));
|
||||
walk_list!(visitor, visit_generic_arg, lifetimes);
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
||||
// and the duplicated parameter, to ensure that they do not get out of sync.
|
||||
if let Node::Item(&Item { kind: ItemKind::OpaqueTy(..), .. }) = node {
|
||||
let opaque_ty_node = tcx.parent_hir_node(hir_id);
|
||||
let Node::Ty(&hir::Ty { kind: TyKind::OpaqueDef(_, lifetimes, _), .. }) = opaque_ty_node
|
||||
let Node::Ty(&hir::Ty { kind: TyKind::OpaqueDef(_, lifetimes), .. }) = opaque_ty_node
|
||||
else {
|
||||
bug!("unexpected {opaque_ty_node:?}")
|
||||
};
|
||||
|
@ -689,7 +689,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||
};
|
||||
self.with(scope, |this| this.visit_ty(mt.ty));
|
||||
}
|
||||
hir::TyKind::OpaqueDef(item_id, lifetimes, _in_trait) => {
|
||||
hir::TyKind::OpaqueDef(item_id, lifetimes) => {
|
||||
// Resolve the lifetimes in the bounds to the lifetime defs in the generics.
|
||||
// `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
|
||||
// `type MyAnonTy<'b> = impl MyTrait<'b>;`
|
||||
|
@ -2087,11 +2087,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
|
||||
self.lower_path(opt_self_ty, path, hir_ty.hir_id, false)
|
||||
}
|
||||
&hir::TyKind::OpaqueDef(item_id, lifetimes, in_trait) => {
|
||||
&hir::TyKind::OpaqueDef(item_id, lifetimes) => {
|
||||
let opaque_ty = tcx.hir().item(item_id);
|
||||
|
||||
match opaque_ty.kind {
|
||||
hir::ItemKind::OpaqueTy(&hir::OpaqueTy { .. }) => {
|
||||
hir::ItemKind::OpaqueTy(&hir::OpaqueTy { in_trait, .. }) => {
|
||||
let local_def_id = item_id.owner_id.def_id;
|
||||
// If this is an RPITIT and we are using the new RPITIT lowering scheme, we
|
||||
// generate the def_id of an associated type for the trait and return as
|
||||
|
@ -510,7 +510,7 @@ impl<'v> hir::intravisit::Visitor<'v> for TraitObjectVisitor<'v> {
|
||||
) => {
|
||||
self.0.push(ty);
|
||||
}
|
||||
hir::TyKind::OpaqueDef(item_id, _, _) => {
|
||||
hir::TyKind::OpaqueDef(item_id, _) => {
|
||||
self.0.push(ty);
|
||||
let item = self.1.item(item_id);
|
||||
hir::intravisit::walk_item(self, item);
|
||||
|
@ -656,7 +656,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
|
||||
if let TyKind::OpaqueDef(item_id, _, _) = ty.kind {
|
||||
if let TyKind::OpaqueDef(item_id, _) = ty.kind {
|
||||
let item = self.tcx.hir().item(item_id);
|
||||
intravisit::walk_item(self, item);
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ pub fn suggest_new_region_bound(
|
||||
}
|
||||
match fn_return.kind {
|
||||
// FIXME(precise_captures): Suggest adding to `use<...>` list instead.
|
||||
TyKind::OpaqueDef(item_id, _, _) => {
|
||||
TyKind::OpaqueDef(item_id, _) => {
|
||||
let item = tcx.hir().item(item_id);
|
||||
let ItemKind::OpaqueTy(opaque) = &item.kind else {
|
||||
return;
|
||||
|
@ -857,7 +857,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'hir hir::Ty<'hir>) {
|
||||
let hir::TyKind::OpaqueDef(item_id, _, _) = ty.kind else {
|
||||
let hir::TyKind::OpaqueDef(item_id, _) = ty.kind else {
|
||||
return hir::intravisit::walk_ty(self, ty);
|
||||
};
|
||||
let opaque_ty = self.tcx.hir().item(item_id).expect_opaque_ty();
|
||||
|
@ -323,7 +323,7 @@ fn associated_types_for_impl_traits_in_associated_fn(
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for RPITVisitor<'tcx> {
|
||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
|
||||
if let hir::TyKind::OpaqueDef(item_id, _, _) = ty.kind
|
||||
if let hir::TyKind::OpaqueDef(item_id, _) = ty.kind
|
||||
&& self.rpits.insert(item_id.owner_id.def_id)
|
||||
{
|
||||
let opaque_item =
|
||||
|
@ -1828,7 +1828,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
|
||||
Array(Box::new(clean_ty(ty, cx)), length.into())
|
||||
}
|
||||
TyKind::Tup(tys) => Tuple(tys.iter().map(|ty| clean_ty(ty, cx)).collect()),
|
||||
TyKind::OpaqueDef(item_id, _, _) => {
|
||||
TyKind::OpaqueDef(item_id, _) => {
|
||||
let item = cx.tcx.hir().item(item_id);
|
||||
if let hir::ItemKind::OpaqueTy(ty) = item.kind {
|
||||
ImplTrait(ty.bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect())
|
||||
|
@ -199,7 +199,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for TypeWalker<'cx, 'tcx> {
|
||||
fn visit_ty(&mut self, t: &'tcx Ty<'tcx>) {
|
||||
if let Some((def_id, _)) = t.peel_refs().as_generic_param() {
|
||||
self.ty_params.remove(&def_id);
|
||||
} else if let TyKind::OpaqueDef(id, _, _) = t.kind {
|
||||
} else if let TyKind::OpaqueDef(id, _) = t.kind {
|
||||
// Explicitly walk OpaqueDef. Normally `walk_ty` would do the job, but it calls
|
||||
// `visit_nested_item`, which checks that `Self::NestedFilter::INTER` is set. We're
|
||||
// using `OnlyBodies`, so the check ends up failing and the type isn't fully walked.
|
||||
|
@ -523,7 +523,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_ty(&mut self, ty: &'tcx Ty<'_>) {
|
||||
match ty.kind {
|
||||
TyKind::OpaqueDef(item, bounds, _) => {
|
||||
TyKind::OpaqueDef(item, bounds) => {
|
||||
let map = self.cx.tcx.hir();
|
||||
let item = map.item(item);
|
||||
let len = self.lts.len();
|
||||
|
@ -105,7 +105,7 @@ fn future_trait_ref<'tcx>(
|
||||
cx: &LateContext<'tcx>,
|
||||
ty: &'tcx Ty<'tcx>,
|
||||
) -> Option<(&'tcx TraitRef<'tcx>, Vec<LifetimeName>)> {
|
||||
if let TyKind::OpaqueDef(item_id, bounds, false) = ty.kind
|
||||
if let TyKind::OpaqueDef(item_id, bounds) = ty.kind
|
||||
&& let item = cx.tcx.hir().item(item_id)
|
||||
&& let ItemKind::OpaqueTy(opaque) = &item.kind
|
||||
&& let Some(trait_ref) = opaque.bounds.iter().find_map(|bound| {
|
||||
|
@ -1115,9 +1115,8 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
||||
}
|
||||
},
|
||||
TyKind::Path(ref qpath) => self.hash_qpath(qpath),
|
||||
TyKind::OpaqueDef(_, arg_list, in_trait) => {
|
||||
TyKind::OpaqueDef(_, arg_list) => {
|
||||
self.hash_generic_args(arg_list);
|
||||
in_trait.hash(&mut self.s);
|
||||
},
|
||||
TyKind::TraitObject(_, lifetime, _) => {
|
||||
self.hash_lifetime(lifetime);
|
||||
|
Loading…
Reference in New Issue
Block a user