]> git.proxmox.com Git - rustc.git/blob - tests/ui/closures/2229_closure_analysis/migrations/issue-90024-adt-correct-subst.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / closures / 2229_closure_analysis / migrations / issue-90024-adt-correct-subst.rs
1 // Test that rustc doesn't ICE as in #90024.
2 // check-pass
3 // edition=2018
4
5 #![warn(rust_2021_incompatible_closure_captures)]
6
7 // Checks there's no double-subst into the generic args, otherwise we get OOB
8 // MCVE by @lqd
9 pub struct Graph<N, E, Ix> {
10 _edges: E,
11 _nodes: N,
12 _ix: Vec<Ix>,
13 }
14 fn graph<N, E>() -> Graph<N, E, i32> {
15 todo!()
16 }
17 fn first_ice() {
18 let g = graph::<i32, i32>();
19 let _ = || g;
20 }
21
22 // Checks that there is a subst into the fields, otherwise we get normalization error
23 // MCVE by @cuviper
24 use std::iter::Empty;
25 struct Foo<I: Iterator> {
26 data: Vec<I::Item>,
27 }
28 pub fn second_ice() {
29 let v = Foo::<Empty<()>> { data: vec![] };
30
31 (|| v.data[0])();
32 }
33
34 pub fn main() {
35 first_ice();
36 second_ice();
37 }