File tree Expand file tree Collapse file tree 7 files changed +108
-0
lines changed
consts/const-item-without-ty
parser/const-item-without-ty Expand file tree Collapse file tree 7 files changed +108
-0
lines changed Original file line number Diff line number Diff line change 1+ //@ check-fail
2+
3+ #![ feature( const_items_unit_type_default) ]
4+
5+ const _ = assert!( false ) ;
6+ //~^ ERROR: evaluation panicked: assertion failed: false [E0080]
7+ const _ = assert!( 2 + 2 == 5 ) ;
8+ //~^ ERROR: evaluation panicked: assertion failed: 2 + 2 == 5 [E0080]
9+
10+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0080]: evaluation panicked: assertion failed: false
2+ --> $DIR/assert-fail.rs:5:11
3+ |
4+ LL | const _ = assert!(false);
5+ | ^^^^^^^^^^^^^^ evaluation of `_` failed here
6+
7+ error[E0080]: evaluation panicked: assertion failed: 2 + 2 == 5
8+ --> $DIR/assert-fail.rs:7:11
9+ |
10+ LL | const _ = assert!(2 + 2 == 5);
11+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
12+
13+ error: aborting due to 2 previous errors
14+
15+ For more information about this error, try `rustc --explain E0080`.
Original file line number Diff line number Diff line change 1+ //@ check-pass
2+ #![ feature( const_items_unit_type_default) ]
3+
4+ const _ = assert!( true ) ;
5+ const _ = assert!( 2 + 2 == 4 ) ;
6+
7+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ //@ check-fail
2+
3+ #![ feature( const_items_unit_type_default) ]
4+
5+ const _ = {
6+ assert ! ( true ) ;
7+ 2 + 2 //~ ERROR: mismatched types [E0308]
8+ } ;
9+
10+ const fn id < T > ( t : T ) -> T {
11+ t
12+ }
13+
14+ const _ = id( 2 ) ;
15+ //~^ ERROR: mismatched types [E0308]
16+ const _ = id( ( ) ) ;
17+
18+
19+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0308]: mismatched types
2+ --> $DIR/typecheck.rs:7:5
3+ |
4+ LL | 2 + 2
5+ | ^^^^^ expected `()`, found integer
6+
7+ error[E0308]: mismatched types
8+ --> $DIR/typecheck.rs:14:14
9+ |
10+ LL | const _ = id(2);
11+ | -- ^ expected `()`, found integer
12+ | |
13+ | arguments to this function are incorrect
14+ |
15+ help: the return type of this call is `{integer}` due to the type of the argument passed
16+ --> $DIR/typecheck.rs:14:11
17+ |
18+ LL | const _ = id(2);
19+ | ^^^-^
20+ | |
21+ | this argument influences the return type of `id`
22+ note: function defined here
23+ --> $DIR/typecheck.rs:10:10
24+ |
25+ LL | const fn id<T>(t: T) -> T {
26+ | ^^ ----
27+
28+ error: aborting due to 2 previous errors
29+
30+ For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change 1+ //@ check-pass
2+ #![ feature( const_items_unit_type_default) ]
3+
4+ #[ cfg( false ) ]
5+ const _ = assert!( false ) ;
6+
7+ #[ expect( unused) ]
8+ const _ = {
9+ let a = 1 ;
10+ assert ! ( true ) ;
11+ } ;
12+
13+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ //@ check-pass
2+ #![ feature( const_items_unit_type_default) ]
3+
4+ macro_rules! foo {
5+ ( $item: item) => {
6+ $item
7+ } ;
8+ }
9+
10+ foo ! ( const _ = { } ; ) ;
11+
12+ fn main ( ) {
13+ foo ! ( const _ = { } ; ) ;
14+ }
You can’t perform that action at this time.
0 commit comments