Use the root trait predicate to determine whether to remove references
Fix #84837.
This commit is contained in:
parent
bb7211702e
commit
8b8cce16bf
6 changed files with 76 additions and 1 deletions
|
@ -1359,6 +1359,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
let mut span = obligation.cause.span;
|
||||
let mut trait_pred = trait_pred;
|
||||
let mut code = obligation.cause.code();
|
||||
while let Some((c, Some(parent_trait_pred))) = code.parent() {
|
||||
// We want the root obligation, in order to detect properly handle
|
||||
// `for _ in &mut &mut vec![] {}`.
|
||||
code = c;
|
||||
trait_pred = parent_trait_pred;
|
||||
}
|
||||
while span.desugaring_kind().is_some() {
|
||||
// Remove all the hir desugaring contexts while maintaining the macro contexts.
|
||||
span.remove_mark();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue