Use ty::OpaqueTy everywhere
This commit is contained in:
parent
918ede6474
commit
7f3af72606
55 changed files with 156 additions and 118 deletions
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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(_)
|
||||
|
|
|
@ -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),
|
||||
};
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue