Remove dyn_compatible_for_dispatch
This commit is contained in:
parent
617aad8c2e
commit
f3d31f77e4
58 changed files with 524 additions and 899 deletions
|
@ -538,10 +538,10 @@ fn receiver_for_self_ty<'tcx>(
|
|||
/// a pointer.
|
||||
///
|
||||
/// In practice, we cannot use `dyn Trait` explicitly in the obligation because it would result in
|
||||
/// a new check that `Trait` is dyn-compatible, creating a cycle (until dyn_compatible_for_dispatch
|
||||
/// is stabilized, see tracking issue <https://github.com/rust-lang/rust/issues/43561>).
|
||||
/// Instead, we fudge a little by introducing a new type parameter `U` such that
|
||||
/// a new check that `Trait` is dyn-compatible, creating a cycle.
|
||||
/// Instead, we emulate a placeholder by introducing a new type parameter `U` such that
|
||||
/// `Self: Unsize<U>` and `U: Trait + ?Sized`, and use `U` in place of `dyn Trait`.
|
||||
///
|
||||
/// Written as a chalk-style query:
|
||||
/// ```ignore (not-rust)
|
||||
/// forall (U: Trait + ?Sized) {
|
||||
|
@ -572,8 +572,6 @@ fn receiver_is_dispatchable<'tcx>(
|
|||
|
||||
// the type `U` in the query
|
||||
// use a bogus type parameter to mimic a forall(U) query using u32::MAX for now.
|
||||
// FIXME(mikeyhew) this is a total hack. Once dyn_compatible_for_dispatch is stabilized, we can
|
||||
// replace this with `dyn Trait`
|
||||
let unsized_self_ty: Ty<'tcx> =
|
||||
Ty::new_param(tcx, u32::MAX, rustc_span::sym::RustaceansAreAwesome);
|
||||
|
||||
|
|
|
@ -859,13 +859,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
if let Some(principal) = data.principal() {
|
||||
if !self.infcx.tcx.features().dyn_compatible_for_dispatch() {
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
} else if self.tcx().is_dyn_compatible(principal.def_id()) {
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
} else {
|
||||
// Only auto trait bounds exist.
|
||||
return;
|
||||
|
|
|
@ -904,19 +904,14 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
|
|||
// FIXME(#27579) RFC also considers adding trait
|
||||
// obligations that don't refer to Self and
|
||||
// checking those
|
||||
|
||||
let defer_to_coercion = tcx.features().dyn_compatible_for_dispatch();
|
||||
|
||||
if !defer_to_coercion {
|
||||
if let Some(principal) = data.principal_def_id() {
|
||||
self.out.push(traits::Obligation::with_depth(
|
||||
tcx,
|
||||
self.cause(ObligationCauseCode::WellFormed(None)),
|
||||
self.recursion_depth,
|
||||
self.param_env,
|
||||
ty::Binder::dummy(ty::PredicateKind::DynCompatible(principal)),
|
||||
));
|
||||
}
|
||||
if let Some(principal) = data.principal_def_id() {
|
||||
self.out.push(traits::Obligation::with_depth(
|
||||
tcx,
|
||||
self.cause(ObligationCauseCode::WellFormed(None)),
|
||||
self.recursion_depth,
|
||||
self.param_env,
|
||||
ty::Binder::dummy(ty::PredicateKind::DynCompatible(principal)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue