diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index feb49ed1e30..3c29c72841e 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -110,13 +110,14 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow { #[instrument(level = "trace", skip(self), ret)] fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { - // FIXME(alias): merge these match t.kind() { - ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => self.visit_opaque(*def_id, substs), - ty::Alias(ty::Projection, proj) - if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder => + ty::Alias(_, ty::AliasTy { def_id, substs }) + if matches!( + self.tcx.def_kind(*def_id), + DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder + ) => { - self.visit_opaque(proj.def_id, proj.substs) + self.visit_opaque(*def_id, substs) } _ => t.super_visit_with(self), } diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 7079322a4a4..3d2b2c6ff2d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -338,13 +338,14 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>( impl<'tcx> InferCtxt<'tcx> { pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option> { - // FIXME(alias): Merge these let (def_id, substs) = match *ty.kind() { - ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => (def_id, substs), - ty::Alias(ty::Projection, data) - if self.tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder => + ty::Alias(_, ty::AliasTy { def_id, substs }) + if matches!( + self.tcx.def_kind(def_id), + DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder + ) => { - (data.def_id, data.substs) + (def_id, substs) } _ => return None, }; @@ -1730,7 +1731,6 @@ enum Similar<'tcx> { TypeError::Sorts(values) => { let extra = expected == found; let sort_string = |ty: Ty<'tcx>, path: Option| { - // FIXME(alias): Merge these let mut s = match (extra, ty.kind()) { (true, ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) => { let sm = self.tcx.sess.source_map();