Rollup merge of #138174 - compiler-errors:elaborate-unsize-self-pred, r=BoxyUwU
Elaborate trait assumption in `receiver_is_dispatchable` Fixes #138172. See comment on the linked test. Probably not a fix for the general problem, bc I think this may still be incomplete for other weird `where` clauses on the receiver. But 🤷, supertraits seems like an obvious one to fix.
This commit is contained in:
commit
143eb4f03e
5 changed files with 105 additions and 12 deletions
|
@ -24,7 +24,9 @@ use super::elaborate;
|
|||
use crate::infer::TyCtxtInferExt;
|
||||
pub use crate::traits::DynCompatibilityViolation;
|
||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
use crate::traits::{MethodViolationCode, Obligation, ObligationCause, util};
|
||||
use crate::traits::{
|
||||
MethodViolationCode, Obligation, ObligationCause, normalize_param_env_or_error, util,
|
||||
};
|
||||
|
||||
/// Returns the dyn-compatibility violations that affect HIR ty lowering.
|
||||
///
|
||||
|
@ -579,8 +581,8 @@ fn receiver_is_dispatchable<'tcx>(
|
|||
let unsized_receiver_ty =
|
||||
receiver_for_self_ty(tcx, receiver_ty, unsized_self_ty, method.def_id);
|
||||
|
||||
// create a modified param env, with `Self: Unsize<U>` and `U: Trait` added to caller bounds
|
||||
// `U: ?Sized` is already implied here
|
||||
// create a modified param env, with `Self: Unsize<U>` and `U: Trait` (and all of
|
||||
// its supertraits) added to caller bounds. `U: ?Sized` is already implied here.
|
||||
let param_env = {
|
||||
let param_env = tcx.param_env(method.def_id);
|
||||
|
||||
|
@ -598,10 +600,13 @@ fn receiver_is_dispatchable<'tcx>(
|
|||
ty::TraitRef::new_from_args(tcx, trait_def_id, args).upcast(tcx)
|
||||
};
|
||||
|
||||
let caller_bounds =
|
||||
param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]);
|
||||
|
||||
ty::ParamEnv::new(tcx.mk_clauses_from_iter(caller_bounds))
|
||||
normalize_param_env_or_error(
|
||||
tcx,
|
||||
ty::ParamEnv::new(tcx.mk_clauses_from_iter(
|
||||
param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]),
|
||||
)),
|
||||
ObligationCause::dummy_with_span(tcx.def_span(method.def_id)),
|
||||
)
|
||||
};
|
||||
|
||||
// Receiver: DispatchFromDyn<Receiver[Self => U]>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue