Better diagnostics when mismatched types due to implict static lifetime
This commit is contained in:
parent
77d155973c
commit
3cd5ad5cd7
11 changed files with 168 additions and 24 deletions
|
@ -1903,7 +1903,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
| ObligationCauseCode::UnifyReceiver(..)
|
||||
| ObligationCauseCode::OpaqueType
|
||||
| ObligationCauseCode::MiscObligation
|
||||
| ObligationCauseCode::WellFormed(..) => {}
|
||||
| ObligationCauseCode::WellFormed(..)
|
||||
| ObligationCauseCode::MatchImpl(..) => {}
|
||||
ObligationCauseCode::SliceOrArrayElem => {
|
||||
err.note("slice and array elements must have `Sized` type");
|
||||
}
|
||||
|
|
|
@ -1903,9 +1903,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
debug!(?impl_trait_ref, ?placeholder_obligation_trait_ref);
|
||||
|
||||
let cause = ObligationCause::new(
|
||||
obligation.cause.span,
|
||||
obligation.cause.body_id,
|
||||
ObligationCauseCode::MatchImpl(Lrc::new(obligation.cause.code.clone()), impl_def_id),
|
||||
);
|
||||
|
||||
let InferOk { obligations, .. } = self
|
||||
.infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.at(&cause, obligation.param_env)
|
||||
.eq(placeholder_obligation_trait_ref, impl_trait_ref)
|
||||
.map_err(|e| debug!("match_impl: failed eq_trait_refs due to `{}`", e))?;
|
||||
nested_obligations.extend(obligations);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue