-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #89648 - nbdd0121:issue-89606, r=nikomatsakis
Ignore type of projections for upvar capturing Fix #89606 Ignore type of projections for upvar capturing. Originally HashMap is used, and the hash/eq implementation of Place takes the type of projections into account. These types may differ by lifetime which causes #89606 to ICE. I originally considered erasing regions but `place.ty()` is used when creating upvar tuple type, more than just serving as a key type, so I switched to a linear comparison with custom eq (`compare_place_ignore_ty`) instead. r? `@wesleywiser` `@rustbot` label +T-compiler
- Loading branch information
Showing
2 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Regression test for #89606. Used to ICE. | ||
// | ||
// check-pass | ||
// revisions: twenty_eighteen twenty_twentyone | ||
// [twenty_eighteen]compile-flags: --edition 2018 | ||
// [twenty_twentyone]compile-flags: --edition 2021 | ||
|
||
struct S<'a>(Option<&'a mut i32>); | ||
|
||
fn by_ref(s: &mut S<'_>) { | ||
(|| { | ||
let S(_o) = s; | ||
s.0 = None; | ||
})(); | ||
} | ||
|
||
fn by_value(s: S<'_>) { | ||
(|| { | ||
let S(ref _o) = s; | ||
let _g = s.0; | ||
})(); | ||
} | ||
|
||
struct V<'a>((Option<&'a mut i32>,)); | ||
|
||
fn nested(v: &mut V<'_>) { | ||
(|| { | ||
let V((_o,)) = v; | ||
v.0 = (None, ); | ||
})(); | ||
} | ||
|
||
fn main() { | ||
let mut s = S(None); | ||
by_ref(&mut s); | ||
by_value(s); | ||
|
||
let mut v = V((None, )); | ||
nested(&mut v); | ||
} |