File tree 1 file changed +57
-0
lines changed
1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ // run-pass
2
+ // compile-flags: -g -O -Zmir-opt-level=0 -Zinline-mir=y -Zmir-enable-passes=+ReferencePropagation
3
+
4
+ #![ allow( dead_code) ]
5
+
6
+ use std:: marker:: PhantomData ;
7
+
8
+ struct RawTable < T > {
9
+ marker : PhantomData < T > ,
10
+ }
11
+
12
+ impl < T > RawTable < T > {
13
+ fn iter ( & self ) -> RawIter < T > {
14
+ RawIter { marker : PhantomData }
15
+ }
16
+ }
17
+
18
+ struct RawIter < T > {
19
+ marker : PhantomData < T > ,
20
+ }
21
+
22
+ impl < T > Iterator for RawIter < T > {
23
+ type Item = ( ) ;
24
+ fn next ( & mut self ) -> Option < ( ) > {
25
+ None
26
+ }
27
+ }
28
+
29
+ struct HashMap < T > {
30
+ table : RawTable < T > ,
31
+ }
32
+
33
+ struct Iter < T > {
34
+ inner : RawIter < T > , // Removing this breaks the reproducer
35
+ }
36
+
37
+ impl < T > IntoIterator for & HashMap < T > {
38
+ type Item = T ;
39
+ type IntoIter = Iter < T > ;
40
+ fn into_iter ( self ) -> Iter < T > {
41
+ Iter { inner : self . table . iter ( ) }
42
+ }
43
+ }
44
+
45
+ impl < T > Iterator for Iter < T > {
46
+ type Item = T ;
47
+ fn next ( & mut self ) -> Option < T > {
48
+ None
49
+ }
50
+ }
51
+
52
+ pub fn main ( ) {
53
+ let maybe_hash_set: Option < HashMap < ( ) > > = None ;
54
+ for _ in maybe_hash_set. as_ref ( ) . unwrap_or ( & HashMap { table : RawTable { marker : PhantomData } } )
55
+ {
56
+ }
57
+ }
You can’t perform that action at this time.
0 commit comments