diff options
| author | Michael Goulet <michael@errs.io> | 2022-11-26 21:09:39 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-12-13 17:29:26 +0000 |
| commit | 7f3af726065d9eaabf93d87f22d97f60cca7a5f1 (patch) | |
| tree | d3501a3fc742f5e786697c99c7e230a497551e1a /compiler/rustc_trait_selection/src | |
| parent | 918ede64740b3610dfd8b43ff0d995261a236ac5 (diff) | |
| download | rust-7f3af726065d9eaabf93d87f22d97f60cca7a5f1.tar.gz rust-7f3af726065d9eaabf93d87f22d97f60cca7a5f1.zip | |
Use ty::OpaqueTy everywhere
Diffstat (limited to 'compiler/rustc_trait_selection/src')
7 files changed, 14 insertions, 12 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 40c81025471..7a391037f31 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -855,7 +855,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { fn_sig.inputs().map_bound(|inputs| &inputs[1..]), )) } - ty::Opaque(def_id, substs) => { + ty::Opaque(ty::OpaqueTy { def_id, substs }) => { self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| { if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder() && Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output() @@ -2644,7 +2644,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { Some(ident) => err.span_note(ident.span, &msg), None => err.note(&msg), }, - ty::Opaque(def_id, _) => { + ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) => { // Avoid printing the future from `core::future::identity_future`, it's not helpful if tcx.parent(*def_id) == identity_future { break 'print; diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 5789754e4fc..69f0e9865dc 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -496,7 +496,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> { // This is really important. While we *can* handle this, this has // severe performance implications for large opaque types with // late-bound regions. See `issue-88862` benchmark. - ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => { + ty::Opaque(ty::OpaqueTy { def_id, substs }) if !substs.has_escaping_bound_vars() => { // Only normalize `impl Trait` outside of type inference, usually in codegen. match self.param_env.reveal() { Reveal::UserFacing => ty.super_fold_with(self), @@ -1378,7 +1378,9 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>( // If so, extract what we know from the trait and try to come up with a good answer. let bounds = match *obligation.predicate.self_ty().kind() { ty::Projection(ref data) => tcx.bound_item_bounds(data.item_def_id).subst(tcx, data.substs), - ty::Opaque(def_id, substs) => tcx.bound_item_bounds(def_id).subst(tcx, substs), + ty::Opaque(ty::OpaqueTy { def_id, substs }) => { + tcx.bound_item_bounds(def_id).subst(tcx, substs) + } ty::Infer(ty::TyVar(_)) => { // If the self-type is an inference variable, then it MAY wind up // being a projected type, so induce an ambiguity. diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index 7ad532d8a34..41a162a9f67 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -205,7 +205,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { // This is really important. While we *can* handle this, this has // severe performance implications for large opaque types with // late-bound regions. See `issue-88862` benchmark. - ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => { + ty::Opaque(ty::OpaqueTy { def_id, substs }) if !substs.has_escaping_bound_vars() => { // Only normalize `impl Trait` outside of type inference, usually in codegen. match self.param_env.reveal() { Reveal::UserFacing => ty.try_super_fold_with(self), diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index e4b70f0d2ff..4cd2d445bd0 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -830,7 +830,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::GeneratorWitness(_) | ty::Never | ty::Projection(_) - | ty::Opaque(_, _) + | ty::Opaque(ty::OpaqueTy { def_id: _, substs: _ }) | ty::Param(_) | ty::Bound(_, _) | ty::Error(_) diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index fda415155c4..cd3025024fe 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -156,7 +156,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let placeholder_trait_predicate = ty::Binder::dummy(placeholder_trait_predicate); let (def_id, substs) = match *placeholder_self_ty.kind() { ty::Projection(proj) => (proj.item_def_id, proj.substs), - ty::Opaque(def_id, substs) => (def_id, substs), + ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs), _ => bug!("projection candidate for unexpected type: {:?}", placeholder_self_ty), }; diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 035deb61639..054bbf8fb0e 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1596,7 +1596,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let tcx = self.infcx.tcx; let (def_id, substs) = match *placeholder_trait_predicate.trait_ref.self_ty().kind() { ty::Projection(ref data) => (data.item_def_id, data.substs), - ty::Opaque(def_id, substs) => (def_id, substs), + ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs), _ => { span_bug!( obligation.cause.span, @@ -2260,7 +2260,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { t.rebind(def.all_fields().map(|f| f.ty(self.tcx(), substs)).collect()) } - ty::Opaque(def_id, substs) => { + ty::Opaque(ty::OpaqueTy { def_id, substs }) => { // We can resolve the `impl Trait` to its concrete type, // which enforces a DAG between the functions requiring // the auto trait bounds in question. diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index e47ba64245f..ab678e4d98f 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -648,12 +648,12 @@ impl<'tcx> WfPredicates<'tcx> { // types appearing in the fn signature } - ty::Opaque(did, substs) => { + ty::Opaque(ty::OpaqueTy { def_id, substs }) => { // All of the requirements on type parameters // have already been checked for `impl Trait` in // return position. We do need to check type-alias-impl-trait though. - if ty::is_impl_trait_defn(self.tcx, did).is_none() { - let obligations = self.nominal_obligations(did, substs); + if ty::is_impl_trait_defn(self.tcx, def_id).is_none() { + let obligations = self.nominal_obligations(def_id, substs); self.out.extend(obligations); } } |
