-
Notifications
You must be signed in to change notification settings - Fork 13k
/
Copy pathexpanded-exhaustive.rs
872 lines (757 loc) · 16.2 KB
/
expanded-exhaustive.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
//@ compile-flags: -Zunpretty=expanded -Zunstable-options
//@ edition:2024
//@ check-pass
#![feature(async_closure)]
#![feature(auto_traits)]
#![feature(box_patterns)]
#![feature(builtin_syntax)]
#![feature(concat_idents)]
#![feature(const_trait_impl)]
#![feature(core_pattern_type)]
#![feature(decl_macro)]
#![feature(deref_patterns)]
#![feature(explicit_tail_calls)]
#![feature(gen_blocks)]
#![feature(let_chains)]
#![feature(more_qualified_paths)]
#![feature(never_patterns)]
#![feature(never_type)]
#![feature(pattern_types)]
#![feature(prelude_import)]
#![feature(specialization)]
#![feature(trace_macros)]
#![feature(trait_alias)]
#![feature(try_blocks)]
#![feature(yeet_expr)]
#![allow(incomplete_features)]
#[prelude_import]
use self::prelude::*;
mod prelude {
pub use std::prelude::rust_2024::*;
pub type T = _;
pub trait Trait {
const CONST: ();
}
}
mod attributes {
//! inner single-line doc comment
/*!
* inner multi-line doc comment
*/
#![doc = "inner doc attribute"]
#![allow(dead_code, unused_variables)]
#![no_std]
/// outer single-line doc comment
/**
* outer multi-line doc comment
*/
#[doc = "outer doc attribute"]
#[doc = concat!("mac", "ro")]
#[allow()]
#[repr(C)]
struct Struct;
}
mod expressions {
/// ExprKind::Array
fn expr_array() {
[];
[true];
[true,];
[true, true];
["long........................................................................"];
["long............................................................", true];
}
/// ExprKind::ConstBlock
fn expr_const_block() {
const {};
const { 1 };
const { struct S; };
}
/// ExprKind::Call
fn expr_call() {
let f;
f();
f::<u8>();
f::<1>();
f::<'static, u8, 1>();
f(true);
f(true,);
()();
}
/// ExprKind::MethodCall
fn expr_method_call() {
let x;
x.f();
x.f::<u8>();
x.collect::<Vec<_>>();
}
/// ExprKind::Tup
fn expr_tup() {
();
(true,);
(true, false);
(true, false,);
}
/// ExprKind::Binary
fn expr_binary() {
let (a, b, c, d, x, y);
true || false;
true || false && false;
a < 1 && 2 < b && c > 3 && 4 > d;
a & b & !c;
a + b * c - d + -1 * -2 - -3;
x = !y;
}
/// ExprKind::Unary
fn expr_unary() {
let expr;
*expr;
!expr;
-expr;
}
/// ExprKind::Lit
fn expr_lit() {
'x';
1_000_i8;
1.00000000000000000000001;
}
/// ExprKind::Cast
fn expr_cast() {
let expr;
expr as T;
expr as T<u8>;
}
/// ExprKind::Type
fn expr_type() {
let expr;
builtin # type_ascribe(expr, T);
}
/// ExprKind::Let
fn expr_let() {
let b;
if let Some(a) = b {}
if let _ = true && false {}
if let _ = (true && false) {}
}
/// ExprKind::If
fn expr_if() {
if true {}
if !true {}
if let true = true {} else {}
if true {} else if false {}
if true {} else if false {} else {}
if true { return; } else if false { 0 } else { 0 }
}
/// ExprKind::While
fn expr_while() {
while false {}
'a: while false {}
while let true = true {}
}
/// ExprKind::ForLoop
fn expr_for_loop() {
let x;
for _ in x {}
'a: for _ in x {}
}
/// ExprKind::Loop
fn expr_loop() {
loop {}
'a: loop {}
}
/// ExprKind::Match
fn expr_match() {
let value;
match value {}
match value { ok => 1 }
match value {
ok => 1,
err => 0,
}
}
/// ExprKind::Closure
fn expr_closure() {
let value;
|| {};
|x| {};
|x: u8| {};
|| ();
move || value;
async || value;
async move || value;
static || value;
static move || value;
(static async || value);
(static async move || value);
|| -> u8 { value };
1 + || {};
}
/// ExprKind::Block
fn expr_block() {
{}
unsafe {}
'a: {}
#[allow()] {}
{ #![allow()] }
}
/// ExprKind::Gen
fn expr_gen() {
async {};
async move {};
gen {};
gen move {};
async gen {};
async gen move {};
}
/// ExprKind::Await
fn expr_await() {
let fut;
fut.await;
}
/// ExprKind::TryBlock
fn expr_try_block() {
try {}
try { return; }
}
/// ExprKind::Assign
fn expr_assign() {
let expr;
expr = true;
}
/// ExprKind::AssignOp
fn expr_assign_op() {
let expr;
expr += true;
}
/// ExprKind::Field
fn expr_field() {
let expr;
expr.field;
expr.0;
}
/// ExprKind::Index
fn expr_index() {
let expr;
expr[true];
}
/// ExprKind::Range
fn expr_range() {
let (lo, hi);
..;
..hi;
lo..;
lo..hi;
lo .. hi;
..=hi;
lo..=hi;
-2..=-1;
}
/// ExprKind::Underscore
fn expr_underscore() {
_;
}
/// ExprKind::Path
fn expr_path() {
let x;
crate::expressions::expr_path;
crate::expressions::expr_path::<'static>;
<T as Default>::default;
<T as ::core::default::Default>::default::<>;
x::();
x::(T, T) -> T;
crate::() -> ()::expressions::() -> ()::expr_path;
core::()::marker::()::PhantomData;
}
/// ExprKind::AddrOf
fn expr_addr_of() {
let expr;
&expr;
&mut expr;
&raw const expr;
&raw mut expr;
}
/// ExprKind::Break
fn expr_break() {
'a: {
break;
break 'a;
break true;
break 'a true;
}
}
/// ExprKind::Continue
fn expr_continue() {
'a: {
continue;
continue 'a;
}
}
/// ExprKind::Ret
fn expr_ret() {
return;
return true;
}
/// ExprKind::InlineAsm
fn expr_inline_asm() {
let x;
core::arch::asm!(
"mov {tmp}, {x}",
"shl {tmp}, 1",
"shl {x}, 2",
"add {x}, {tmp}",
x = inout(reg) x,
tmp = out(reg) _,
);
}
/// ExprKind::OffsetOf
fn expr_offset_of() {
core::mem::offset_of!(T, field);
}
/// ExprKind::MacCall
fn expr_mac_call() {
stringify!(...);
stringify![...];
stringify! { ... };
}
/// ExprKind::Struct
fn expr_struct() {
struct Struct {}
let (x, base);
Struct {};
<Struct as ToOwned>::Owned {};
Struct { .. };
Struct { .. base };
Struct { x };
Struct { x, ..base };
Struct { x: true };
Struct { x: true, .. };
Struct { x: true, ..base };
Struct { 0: true, ..base };
}
/// ExprKind::Repeat
fn expr_repeat() {
[(); 0];
}
/// ExprKind::Paren
fn expr_paren() {
let expr;
(expr);
}
/// ExprKind::Try
fn expr_try() {
let expr;
expr?;
}
/// ExprKind::Yield
fn expr_yield() {
yield;
yield true;
}
/// ExprKind::Yeet
fn expr_yeet() {
do yeet;
do yeet 0;
}
/// ExprKind::Become
fn expr_become() {
become true;
}
/// ExprKind::IncludedBytes
fn expr_include_bytes() {
include_bytes!("auxiliary/data.txt");
}
/// ExprKind::FormatArgs
fn expr_format_args() {
let expr;
format_args!("");
format_args!("{}", expr);
}
}
mod items {
/// ItemKind::ExternCrate
mod item_extern_crate {
extern crate core;
extern crate self as unpretty;
pub extern crate core as _;
}
/// ItemKind::Use
mod item_use {
use crate::{expressions, items::item_use};
pub use core::*;
}
/// ItemKind::Static
mod item_static {
pub static A: () = {};
static mut B: () = {};
}
/// ItemKind::Const
mod item_const {
pub const A: () = {};
trait TraitItems {
const B: ();
const C: () = {};
}
}
/// ItemKind::Fn
mod item_fn {
pub const unsafe extern "C" fn f() {}
pub async unsafe extern fn g() {}
fn h<'a, T>() where T: 'a {}
trait TraitItems {
unsafe extern fn f();
}
impl TraitItems for _ {
default unsafe extern fn f() {}
}
}
/// ItemKind::Mod
mod item_mod {
// ...
}
/// ItemKind::ForeignMod
mod item_foreign_mod {
unsafe extern "C++" {}
unsafe extern {}
}
/// ItemKind::GlobalAsm
mod item_global_asm {
core::arch::global_asm!(".globl my_asm_func");
}
/// ItemKind::TyAlias
mod item_ty_alias {
pub type Type<'a> where T: 'a, = T;
}
/// ItemKind::Enum
mod item_enum {
pub enum Void {}
enum Empty {
Unit,
Tuple(),
Struct {},
}
enum Generic<'a, T>
where
T: 'a,
{
Tuple(T),
Struct { t: T },
}
}
/// ItemKind::Struct
mod item_struct {
pub struct Unit;
struct Tuple();
struct Newtype(Unit);
struct Struct {}
struct Generic<'a, T>
where
T: 'a,
{
t: T,
}
}
/// ItemKind::Union
mod item_union {
union Generic<'a, T>
where
T: 'a,
{
t: T,
}
}
/// ItemKind::Trait
mod item_trait {
pub unsafe auto trait Send {}
trait Trait<'a>: Sized
where
Self: 'a,
{
}
}
/// ItemKind::TraitAlias
mod item_trait_alias {
pub trait Trait<T> = Sized where for<'a> T: 'a;
}
/// ItemKind::Impl
mod item_impl {
impl () {}
impl<T> () {}
impl Default for () {}
impl<T> const Default for () {}
}
/// ItemKind::MacCall
mod item_mac_call {
trace_macros!(false);
trace_macros![false];
trace_macros! { false }
}
/// ItemKind::MacroDef
mod item_macro_def {
macro_rules! mac { () => {...}; }
pub macro stringify() {}
}
/// ItemKind::Delegation
mod item_delegation {
/*! FIXME: todo */
}
/// ItemKind::DelegationMac
mod item_delegation_mac {
/*! FIXME: todo */
}
}
mod patterns {
/// PatKind::Wild
fn pat_wild() {
let _;
}
/// PatKind::Ident
fn pat_ident() {
let x;
let ref x;
let mut x;
let ref mut x;
let ref mut x @ _;
}
/// PatKind::Struct
fn pat_struct() {
let T {};
let T::<T> {};
let T::<'static> {};
let T { x };
let T { x: _x };
let T { .. };
let T { x, .. };
let T { x: _x, .. };
let T { 0: _x, .. };
let <T as ToOwned>::Owned {};
}
/// PatKind::TupleStruct
fn pat_tuple_struct() {
struct Tuple();
let Tuple();
let Tuple::<T>();
let Tuple::<'static>();
let Tuple(x);
let Tuple(..);
let Tuple(x, ..);
}
/// PatKind::Or
fn pat_or() {
let (true | false);
let (| true);
let (|true| false);
}
/// PatKind::Path
fn pat_path() {
let core::marker::PhantomData;
let core::marker::PhantomData::<T>;
let core::marker::PhantomData::<'static>;
let <T as Trait>::CONST;
}
/// PatKind::Tuple
fn pat_tuple() {
let ();
let (true,);
let (true, false);
}
/// PatKind::Box
fn pat_box() {
let box pat;
}
/// PatKind::Deref
fn pat_deref() {
let deref!(pat);
}
/// PatKind::Ref
fn pat_ref() {
let &pat;
let &mut pat;
}
/// PatKind::Lit
fn pat_lit() {
let 1_000_i8;
let -"";
}
/// PatKind::Range
fn pat_range() {
let ..1;
let 0..;
let 0..1;
let 0..=1;
let -2..=-1;
}
/// PatKind::Slice
fn pat_slice() {
let [];
let [true];
let [true,];
let [true, false];
}
/// PatKind::Rest
fn pat_rest() {
let ..;
}
/// PatKind::Never
fn pat_never() {
let !;
let Some(!);
}
/// PatKind::Paren
fn pat_paren() {
let (pat);
}
/// PatKind::MacCall
fn pat_mac_call() {
let stringify!();
let stringify![];
let stringify! {};
}
}
mod statements {
/// StmtKind::Let
fn stmt_let() {
let _;
let _ = true;
let _: T = true;
let _ = true else { return; };
}
/// StmtKind::Item
fn stmt_item() {
struct Struct {}
struct Unit;
}
/// StmtKind::Expr
fn stmt_expr() {
()
}
/// StmtKind::Semi
fn stmt_semi() {
1 + 1;
}
/// StmtKind::Empty
fn stmt_empty() {
;
}
/// StmtKind::MacCall
fn stmt_mac_call() {
stringify!(...);
stringify![...];
stringify! { ... };
}
}
mod types {
/// TyKind::Slice
fn ty_slice() {
let _: [T];
}
/// TyKind::Array
fn ty_array() {
let _: [T; 0];
}
/// TyKind::Ptr
fn ty_ptr() {
let _: *const T;
let _: *mut T;
}
/// TyKind::Ref
fn ty_ref() {
let _: &T;
let _: &mut T;
let _: &'static T;
let _: &'static mut [T];
let _: &T<T<T<T<T>>>>;
let _: &T<T<T<T<T> > > >;
}
/// TyKind::BareFn
fn ty_bare_fn() {
let _: fn();
let _: fn() -> ();
let _: fn(T);
let _: fn(t: T);
let _: for<> fn();
let _: for<'a> fn();
}
/// TyKind::Never
fn ty_never() {
let _: !;
}
/// TyKind::Tup
fn ty_tup() {
let _: ();
let _: (T,);
let _: (T, T);
}
/// TyKind::Path
fn ty_path() {
let _: T;
let _: T<'static>;
let _: T<T>;
let _: T::<T>;
let _: T() -> !;
let _: <T as ToOwned>::Owned;
}
/// TyKind::TraitObject
fn ty_trait_object() {
let _: dyn Send;
let _: dyn Send + 'static;
let _: dyn 'static + Send;
let _: dyn for<'a> Send;
}
/// TyKind::ImplTrait
const fn ty_impl_trait() {
let _: impl Send;
let _: impl Send + 'static;
let _: impl 'static + Send;
let _: impl ?Sized;
let _: impl ~const Clone;
let _: impl for<'a> Send;
}
/// TyKind::Paren
fn ty_paren() {
let _: (T);
}
/// TyKind::Typeof
fn ty_typeof() {
/*! unused for now */
}
/// TyKind::Infer
fn ty_infer() {
let _: _;
}
/// TyKind::ImplicitSelf
fn ty_implicit_self() {
/*! there is no syntax for this */
}
/// TyKind::MacCall
fn ty_mac_call() {
let _: concat_idents!(T);
let _: concat_idents![T];
let _: concat_idents! { T };
}
/// TyKind::CVarArgs
fn ty_c_var_args() {
/*! FIXME: todo */
}
/// TyKind::Pat
fn ty_pat() {
let _: core::pattern_type!(u32 is 1..);
}
}
mod visibilities {
/// VisibilityKind::Public
mod visibility_public {
pub struct Pub;
}
/// VisibilityKind::Restricted
mod visibility_restricted {
pub(crate) struct PubCrate;
pub(self) struct PubSelf;
pub(super) struct PubSuper;
pub(in crate) struct PubInCrate;
pub(in self) struct PubInSelf;
pub(in super) struct PubInSuper;
pub(in crate::visibilities) struct PubInCrateVisibilities;
pub(in self::super) struct PubInSelfSuper;
pub(in super::visibility_restricted) struct PubInSuperMod;
}
}