File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ // check-pass
2
+ // known-bug: #40582
3
+
4
+ // Should fail. Should not be possible to implement `make_static`.
5
+
6
+ #![ feature( specialization) ]
7
+ #![ allow( incomplete_features) ]
8
+
9
+ trait FromRef < ' a , T : ?Sized > {
10
+ fn from_ref ( r : & ' a T ) -> Self ;
11
+ }
12
+
13
+ impl < ' a , T : ?Sized > FromRef < ' a , T > for & ' a T {
14
+ fn from_ref ( r : & ' a T ) -> Self {
15
+ r
16
+ }
17
+ }
18
+
19
+ impl < ' a , T : ?Sized , R > FromRef < ' a , T > for R {
20
+ default fn from_ref ( _: & ' a T ) -> Self {
21
+ unimplemented ! ( )
22
+ }
23
+ }
24
+
25
+ fn make_static < T : ?Sized > ( data : & T ) -> & ' static T {
26
+ fn helper < T : ?Sized , R > ( data : & T ) -> R {
27
+ R :: from_ref ( data)
28
+ }
29
+ helper ( data)
30
+ }
31
+
32
+ fn main ( ) {
33
+ let s = "specialization" . to_owned ( ) ;
34
+ println ! ( "{:?}" , make_static( s. as_str( ) ) ) ;
35
+ }
You can’t perform that action at this time.
0 commit comments