diff options
| author | Jakob Degen <jakob@degen.com> | 2021-10-23 22:36:50 -0400 |
|---|---|---|
| committer | Jakob Degen <jakob@degen.com> | 2021-10-23 22:36:50 -0400 |
| commit | eae42fd9d0d6e568282a4c782405058b64f1ef0b (patch) | |
| tree | 90637f139a905c9924da201f92ce451722b6fa74 | |
| parent | 9158fc2071d8b6424ca56bcebc1cf21d264e9d7d (diff) | |
| download | rust-eae42fd9d0d6e568282a4c782405058b64f1ef0b.tar.gz rust-eae42fd9d0d6e568282a4c782405058b64f1ef0b.zip | |
Add regresstion test for #90024.
Uses 2 MCVEs from the issue tracker that test opposite sides of the problem.
| -rw-r--r-- | src/test/ui/closures/2229_closure_analysis/migrations/issue-90024-adt-correct-subst.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/issue-90024-adt-correct-subst.rs b/src/test/ui/closures/2229_closure_analysis/migrations/issue-90024-adt-correct-subst.rs new file mode 100644 index 00000000000..ed8cb042b3e --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/migrations/issue-90024-adt-correct-subst.rs @@ -0,0 +1,37 @@ +// Test that rustc doesn't ICE as in #90024. +// check-pass +// edition=2018 + +#![warn(rust_2021_incompatible_closure_captures)] + +// Checks there's no double-subst into the generic args, otherwise we get OOB +// MCVE by @lqd +pub struct Graph<N, E, Ix> { + _edges: E, + _nodes: N, + _ix: Vec<Ix>, +} +fn graph<N, E>() -> Graph<N, E, i32> { + todo!() +} +fn first_ice() { + let g = graph::<i32, i32>(); + let _ = || g; +} + +// Checks that there is a subst into the fields, otherwise we get normalization error +// MCVE by @cuviper +use std::iter::Empty; +struct Foo<I: Iterator> { + data: Vec<I::Item>, +} +pub fn second_ice() { + let v = Foo::<Empty<()>> { data: vec![] }; + + (|| v.data[0])(); +} + +pub fn main() { + first_ice(); + second_ice(); +} |
