File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // This tests for an ICE (and, if ignored, subsequent LLVM abort) when
12
+ // a lifetime-parametric fn is passed into a context whose expected
13
+ // type has a differing lifetime parameterization.
14
+
15
+ struct A < ' a > {
16
+ _a : & ' a i32 ,
17
+ }
18
+
19
+ fn call < T > ( s : T , functions : & Vec < for <' n > fn ( & ' n T ) > ) {
20
+ for function in functions {
21
+ function ( & s) ;
22
+ }
23
+ }
24
+
25
+ fn f ( a : & A ) { println ! ( "a holds {}" , a. _a) ; }
26
+
27
+ fn main ( ) {
28
+ let a = A { _a : & 10 } ;
29
+
30
+ let vec: Vec < for <' u , ' v > fn ( & ' u A < ' v > ) > = vec ! [ f] ;
31
+ call ( a, & vec) ;
32
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Tests for an LLVM abort when storing a lifetime-parametric fn into
12
+ // context that is expecting one that is not lifetime-parametric
13
+ // (i.e. has no `for <'_>`).
14
+
15
+ pub struct A < ' a > ( & ' a ( ) ) ;
16
+ pub struct S < T > ( T ) ;
17
+
18
+ pub fn bad < ' s > ( v : & mut S < fn ( A < ' s > ) > , y : S < for <' b > fn ( A < ' b > ) > ) {
19
+ * v = y;
20
+ }
21
+
22
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments