1
- //@ known-bug: #110395
2
- //@ failure-status: 101
3
- //@ normalize-stderr-test: ".*note: .*\n\n" -> ""
4
- //@ normalize-stderr-test: "thread 'rustc' panicked.*:\n.*\n" -> ""
5
- //@ rustc-env:RUST_BACKTRACE=0
6
- // FIXME(effects) check-pass
7
1
//@ compile-flags: -Znext-solver
8
2
9
3
#![ crate_type = "lib" ]
10
- #![ feature( no_core, lang_items, unboxed_closures, auto_traits, intrinsics, rustc_attrs, staged_api) ]
11
- #![ feature( fundamental, marker_trait_attr) ]
12
- #![ feature( const_trait_impl, effects) ]
4
+ #![ feature(
5
+ no_core,
6
+ lang_items,
7
+ unboxed_closures,
8
+ auto_traits,
9
+ intrinsics,
10
+ rustc_attrs,
11
+ fundamental,
12
+ marker_trait_attr,
13
+ const_trait_impl,
14
+ effects
15
+ ) ]
13
16
#![ allow( internal_features, incomplete_features) ]
14
17
#![ no_std]
15
18
#![ no_core]
16
- #![ stable( feature = "minicore" , since = "1.0.0" ) ]
17
19
18
20
#[ lang = "sized" ]
19
- trait Sized { }
21
+ pub trait Sized { }
20
22
#[ lang = "copy" ]
21
- trait Copy { }
23
+ pub trait Copy { }
24
+
25
+ impl Copy for bool { }
26
+ impl Copy for u8 { }
27
+ impl < T : ?Sized > Copy for & T { }
22
28
23
29
#[ lang = "add" ]
24
30
#[ const_trait]
25
- trait Add < Rhs = Self > {
31
+ pub trait Add < Rhs = Self > {
26
32
type Output ;
27
33
28
34
fn add ( self , rhs : Rhs ) -> Self :: Output ;
@@ -43,10 +49,9 @@ const fn bar() {
43
49
let x = 42_i32 + 43_i32 ;
44
50
}
45
51
46
-
47
52
#[ lang = "Try" ]
48
53
#[ const_trait]
49
- trait Try : FromResidual < Self :: Residual > {
54
+ pub trait Try : FromResidual < Self :: Residual > {
50
55
type Output ;
51
56
type Residual ;
52
57
@@ -57,9 +62,8 @@ trait Try: FromResidual<Self::Residual> {
57
62
fn branch ( self ) -> ControlFlow < Self :: Residual , Self :: Output > ;
58
63
}
59
64
60
- // FIXME
61
- // #[const_trait]
62
- trait FromResidual < R = <Self as /* FIXME: ~const */ Try >:: Residual > {
65
+ #[ const_trait]
66
+ pub trait FromResidual < R = <Self as Try >:: Residual > {
63
67
#[ lang = "from_residual" ]
64
68
fn from_residual ( residual : R ) -> Self ;
65
69
}
@@ -74,102 +78,59 @@ enum ControlFlow<B, C = ()> {
74
78
#[ const_trait]
75
79
#[ lang = "fn" ]
76
80
#[ rustc_paren_sugar]
77
- trait Fn < Args : Tuple > : ~const FnMut < Args > {
81
+ pub trait Fn < Args : Tuple > : ~const FnMut < Args > {
78
82
extern "rust-call" fn call ( & self , args : Args ) -> Self :: Output ;
79
83
}
80
84
81
85
#[ const_trait]
82
86
#[ lang = "fn_mut" ]
83
87
#[ rustc_paren_sugar]
84
- trait FnMut < Args : Tuple > : ~const FnOnce < Args > {
88
+ pub trait FnMut < Args : Tuple > : ~const FnOnce < Args > {
85
89
extern "rust-call" fn call_mut ( & mut self , args : Args ) -> Self :: Output ;
86
90
}
87
91
88
92
#[ const_trait]
89
93
#[ lang = "fn_once" ]
90
94
#[ rustc_paren_sugar]
91
- trait FnOnce < Args : Tuple > {
95
+ pub trait FnOnce < Args : Tuple > {
92
96
#[ lang = "fn_once_output" ]
93
97
type Output ;
94
98
95
99
extern "rust-call" fn call_once ( self , args : Args ) -> Self :: Output ;
96
100
}
97
101
98
- struct ConstFnMutClosure < CapturedData , Function > {
99
- data : CapturedData ,
100
- func : Function ,
101
- }
102
-
103
102
#[ lang = "tuple_trait" ]
104
- trait Tuple { }
105
-
106
- macro_rules! impl_fn_mut_tuple {
107
- ( $( $var: ident) * ) => {
108
- impl <' a, $( $var, ) * ClosureArguments : Tuple , Function , ClosureReturnValue > const
109
- FnOnce <ClosureArguments > for ConstFnMutClosure <( $( & ' a mut $var) ,* ) , Function >
110
- where
111
- Function : ~const Fn ( ( $( & mut $var) ,* ) , ClosureArguments ) -> ClosureReturnValue ,
112
- Function : ~const Destruct ,
113
- {
114
- type Output = ClosureReturnValue ;
115
-
116
- extern "rust-call" fn call_once( mut self , args: ClosureArguments ) -> Self :: Output {
117
- self . call_mut( args)
118
- }
119
- }
120
- impl <' a, $( $var, ) * ClosureArguments : Tuple , Function , ClosureReturnValue > const
121
- FnMut <ClosureArguments > for ConstFnMutClosure <( $( & ' a mut $var) ,* ) , Function >
122
- where
123
- Function : ~const Fn ( ( $( & mut $var) ,* ) , ClosureArguments ) -> ClosureReturnValue ,
124
- Function : ~const Destruct ,
125
- {
126
- extern "rust-call" fn call_mut( & mut self , args: ClosureArguments ) -> Self :: Output {
127
- #[ allow( non_snake_case) ]
128
- let ( $( $var) ,* ) = & mut self . data;
129
- ( self . func) ( ( $( $var) ,* ) , args)
130
- }
131
- }
132
- } ;
133
- }
134
- //impl_fn_mut_tuple!(A);
135
- //impl_fn_mut_tuple!(A B);
136
- //impl_fn_mut_tuple!(A B C);
137
- //impl_fn_mut_tuple!(A B C D);
138
- //impl_fn_mut_tuple!(A B C D E);
103
+ pub trait Tuple { }
139
104
140
105
#[ lang = "legacy_receiver" ]
141
- trait LegacyReceiver { }
106
+ pub trait LegacyReceiver { }
142
107
143
108
impl < T : ?Sized > LegacyReceiver for & T { }
144
109
145
110
impl < T : ?Sized > LegacyReceiver for & mut T { }
146
111
147
112
#[ lang = "destruct" ]
148
113
#[ const_trait]
149
- trait Destruct { }
114
+ pub trait Destruct { }
150
115
151
116
#[ lang = "freeze" ]
152
- unsafe auto trait Freeze { }
117
+ pub unsafe auto trait Freeze { }
153
118
154
119
#[ lang = "drop" ]
155
120
#[ const_trait]
156
- trait Drop {
121
+ pub trait Drop {
157
122
fn drop ( & mut self ) ;
158
123
}
159
124
160
- /*
161
125
#[ const_trait]
162
- trait Residual<O> {
126
+ pub trait Residual < O > {
163
127
type TryType : ~const Try < Output = O , Residual = Self > + Try < Output = O , Residual = Self > ;
164
128
}
165
- */
166
129
167
130
const fn size_of < T > ( ) -> usize {
168
131
42
169
132
}
170
133
171
- impl Copy for u8 { }
172
-
173
134
impl usize {
174
135
#[ rustc_allow_incoherent_impl]
175
136
const fn repeat_u8 ( x : u8 ) -> usize {
@@ -190,15 +151,14 @@ fn panic_fmt() {}
190
151
191
152
#[ lang = "index" ]
192
153
#[ const_trait]
193
- trait Index < Idx : ?Sized > {
154
+ pub trait Index < Idx : ?Sized > {
194
155
type Output : ?Sized ;
195
156
196
157
fn index ( & self , index : Idx ) -> & Self :: Output ;
197
158
}
198
159
199
-
200
160
#[ const_trait]
201
- unsafe trait SliceIndex < T : ?Sized > {
161
+ pub unsafe trait SliceIndex < T : ?Sized > {
202
162
type Output : ?Sized ;
203
163
fn index ( self , slice : & T ) -> & Self :: Output ;
204
164
}
@@ -214,51 +174,45 @@ where
214
174
index. index ( self )
215
175
}
216
176
}
217
- /* FIXME
177
+
218
178
impl < T , I , const N : usize > const Index < I > for [ T ; N ]
219
179
where
220
180
[ T ] : ~const Index < I > ,
221
181
{
222
182
type Output = <[ T ] as Index < I > >:: Output ;
223
183
224
184
#[ inline]
225
- // FIXME: make `Self::Output` act like `<Self as ~const Index<I>>::Output`
226
185
fn index ( & self , index : I ) -> & <[ T ] as Index < I > >:: Output {
227
186
Index :: index ( self as & [ T ] , index)
228
187
}
229
188
}
230
- */
231
189
232
190
#[ lang = "unsize" ]
233
- trait Unsize < T : ?Sized > {
234
- }
191
+ pub trait Unsize < T : ?Sized > { }
235
192
236
193
#[ lang = "coerce_unsized" ]
237
- trait CoerceUnsized < T : ?Sized > {
238
- }
194
+ pub trait CoerceUnsized < T : ?Sized > { }
239
195
240
196
impl < ' a , ' b : ' a , T : ?Sized + Unsize < U > , U : ?Sized > CoerceUnsized < & ' a U > for & ' b T { }
241
197
242
-
243
198
#[ lang = "deref" ]
244
- // #[const_trait] FIXME
245
- trait Deref {
199
+ #[ const_trait]
200
+ pub trait Deref {
246
201
#[ lang = "deref_target" ]
247
202
type Target : ?Sized ;
248
203
249
204
fn deref ( & self ) -> & Self :: Target ;
250
205
}
251
206
252
-
253
- impl < T : ?Sized > /* const */ Deref for & T {
207
+ impl < T : ?Sized > const Deref for & T {
254
208
type Target = T ;
255
209
256
210
fn deref ( & self ) -> & T {
257
211
* self
258
212
}
259
213
}
260
214
261
- impl < T : ?Sized > /* const */ Deref for & mut T {
215
+ impl < T : ?Sized > const Deref for & mut T {
262
216
type Target = T ;
263
217
264
218
fn deref ( & self ) -> & T {
@@ -291,7 +245,6 @@ impl<T> Option<T> {
291
245
292
246
use Option :: * ;
293
247
294
- /*
295
248
const fn as_deref < T > ( opt : & Option < T > ) -> Option < & T :: Target >
296
249
where
297
250
T : ~const Deref ,
@@ -301,15 +254,14 @@ where
301
254
Option :: None => Option :: None ,
302
255
}
303
256
}
304
- */
305
257
306
258
#[ const_trait]
307
- trait Into < T > : Sized {
259
+ pub trait Into < T > : Sized {
308
260
fn into ( self ) -> T ;
309
261
}
310
262
311
263
#[ const_trait]
312
- trait From < T > : Sized {
264
+ pub trait From < T > : Sized {
313
265
fn from ( value : T ) -> Self ;
314
266
}
315
267
@@ -344,7 +296,7 @@ fn from_str(s: &str) -> Result<bool, ()> {
344
296
345
297
#[ lang = "eq" ]
346
298
#[ const_trait]
347
- trait PartialEq < Rhs : ?Sized = Self > {
299
+ pub trait PartialEq < Rhs : ?Sized = Self > {
348
300
fn eq ( & self , other : & Rhs ) -> bool ;
349
301
fn ne ( & self , other : & Rhs ) -> bool {
350
302
!self . eq ( other)
@@ -366,10 +318,9 @@ impl PartialEq for str {
366
318
}
367
319
}
368
320
369
-
370
321
#[ lang = "not" ]
371
322
#[ const_trait]
372
- trait Not {
323
+ pub trait Not {
373
324
type Output ;
374
325
fn not ( self ) -> Self :: Output ;
375
326
}
@@ -381,9 +332,6 @@ impl const Not for bool {
381
332
}
382
333
}
383
334
384
- impl Copy for bool { }
385
- impl < ' a > Copy for & ' a str { }
386
-
387
335
#[ lang = "pin" ]
388
336
#[ fundamental]
389
337
#[ repr( transparent) ]
@@ -404,23 +352,21 @@ impl<'a, T: ?Sized> Pin<&'a T> {
404
352
}
405
353
}
406
354
407
-
408
355
impl < P : Deref > Pin < P > {
409
- /* const */ fn as_ref ( & self ) -> Pin < & P :: Target >
356
+ const fn as_ref ( & self ) -> Pin < & P :: Target >
410
357
where
411
- P : /* ~const */ Deref ,
358
+ P : ~const Deref ,
412
359
{
413
360
unsafe { Pin :: new_unchecked ( & * self . pointer ) }
414
361
}
415
362
}
416
363
417
-
418
364
impl < ' a , T : ?Sized > Pin < & ' a mut T > {
419
365
const unsafe fn get_unchecked_mut ( self ) -> & ' a mut T {
420
366
self . pointer
421
367
}
422
368
}
423
- /* FIXME lol
369
+
424
370
impl < T > Option < T > {
425
371
const fn as_pin_ref ( self : Pin < & Self > ) -> Option < Pin < & T > > {
426
372
match Pin :: get_ref ( self ) . as_ref ( ) {
@@ -438,16 +384,15 @@ impl<T> Option<T> {
438
384
}
439
385
}
440
386
}
441
- */
442
387
443
- impl < P : /* ~const */ Deref > /* const */ Deref for Pin < P > {
388
+ impl < P : ~const Deref > const Deref for Pin < P > {
444
389
type Target = P :: Target ;
445
390
fn deref ( & self ) -> & P :: Target {
446
391
Pin :: get_ref ( Pin :: as_ref ( self ) )
447
392
}
448
393
}
449
394
450
- impl < T > /* const */ Deref for Option < T > {
395
+ impl < T > const Deref for Option < T > {
451
396
type Target = T ;
452
397
fn deref ( & self ) -> & T {
453
398
loop { }
@@ -499,23 +444,22 @@ impl<T: ?Sized> Deref for Ref<'_, T> {
499
444
500
445
#[ lang = "clone" ]
501
446
#[ rustc_trivial_field_reads]
502
- #[ const_trait]
503
- trait Clone : Sized {
447
+ // FIXME: #[const_trait]
448
+ pub trait Clone : Sized {
504
449
fn clone ( & self ) -> Self ;
505
450
fn clone_from ( & mut self , source : & Self )
506
451
where
507
- Self : ~const Destruct ,
452
+ // FIXME: Self: ~const Destruct,
508
453
{
509
454
* self = source. clone ( )
510
455
}
511
456
}
512
457
513
458
#[ lang = "structural_peq" ]
514
- trait StructuralPartialEq { }
459
+ pub trait StructuralPartialEq { }
515
460
516
- const fn drop < T : ~const Destruct > ( _: T ) { }
461
+ // FIXME: const fn drop<T: ~const Destruct>(_: T) {}
517
462
518
- #[ rustc_const_stable_indirect]
519
463
#[ rustc_intrinsic_must_be_overridden]
520
464
#[ rustc_intrinsic]
521
465
const fn const_eval_select < ARG : Tuple , F , G , RET > (
@@ -529,10 +473,3 @@ where
529
473
{
530
474
loop { }
531
475
}
532
-
533
- fn test_const_eval_select ( ) {
534
- const fn const_fn ( ) { }
535
- fn rt_fn ( ) { }
536
-
537
- const_eval_select ( ( ) , const_fn, rt_fn) ;
538
- }
0 commit comments