File tree 6 files changed +40
-7
lines changed 6 files changed +40
-7
lines changed Original file line number Diff line number Diff line change @@ -964,15 +964,15 @@ This does not pose a problem by itself because they can't be accessed directly."
964
964
let ( msg, note) = if let UnstableFeatures :: Disallow =
965
965
self . tcx . sess . opts . unstable_features {
966
966
( format ! ( "calls in {}s are limited to \
967
- struct and enum constructors ",
967
+ tuple structs and tuple variants ",
968
968
self . mode) ,
969
969
Some ( "a limited form of compile-time function \
970
970
evaluation is available on a nightly \
971
971
compiler via `const fn`") )
972
972
} else {
973
973
( format ! ( "calls in {}s are limited \
974
974
to constant functions, \
975
- struct and enum constructors ",
975
+ tuple structs and tuple variants ",
976
976
self . mode) ,
977
977
None )
978
978
} ;
Original file line number Diff line number Diff line change 11
11
fn xyz ( ) -> u8 { 42 }
12
12
13
13
const NUM : u8 = xyz ( ) ;
14
- //~^ ERROR calls in constants are limited to constant functions, struct and enum constructors
14
+ //~^ ERROR calls in constants are limited to constant functions, tuple structs and tuple variants
15
15
//~| ERROR constant evaluation error
16
16
17
17
fn main ( ) {
Original file line number Diff line number Diff line change 7
7
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
+
11
+ // ignore-tidy-linelength
12
+
10
13
#![ feature( const_fn) ]
11
14
12
15
const bad : u32 = {
@@ -20,7 +23,7 @@ const bad_two : u32 = {
20
23
{
21
24
invalid ( ) ;
22
25
//~^ ERROR: blocks in constants are limited to items and tail expressions
23
- //~^^ ERROR: calls in constants are limited to constant functions, struct and enum
26
+ //~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
24
27
0
25
28
}
26
29
} ;
@@ -44,7 +47,7 @@ static bad_five : u32 = {
44
47
{
45
48
invalid ( ) ;
46
49
//~^ ERROR: blocks in statics are limited to items and tail expressions
47
- //~^^ ERROR: calls in statics are limited to constant functions, struct and enum
50
+ //~^^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
48
51
0
49
52
}
50
53
} ;
@@ -68,7 +71,7 @@ static mut bad_eight : u32 = {
68
71
{
69
72
invalid ( ) ;
70
73
//~^ ERROR: blocks in statics are limited to items and tail expressions
71
- //~^^ ERROR: calls in statics are limited to constant functions, struct and enum
74
+ //~^^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
72
75
0
73
76
}
74
77
} ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ error[E0016]: blocks in constant functions are limited to items and tail express
4
4
LL | let mut sum = 0;
5
5
| ^
6
6
7
- error[E0015]: calls in constant functions are limited to constant functions, struct and enum constructors
7
+ error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
8
8
--> $DIR/const-fn-error.rs:18:14
9
9
|
10
10
LL | for i in 0..x {
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 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
+ #![ allow( dead_code) ]
12
+
13
+ struct Foo { a : u8 }
14
+ fn bar ( ) -> Foo {
15
+ Foo { a : 5 }
16
+ }
17
+
18
+ static foo: Foo = bar ( ) ;
19
+ //~^ ERROR calls in statics are limited to constant functions, tuple structs and tuple variants
20
+
21
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
2
+ --> $DIR/mir_check_nonconst.rs:18:19
3
+ |
4
+ LL | static foo: Foo = bar();
5
+ | ^^^^^
6
+
7
+ error: aborting due to previous error
8
+
9
+ For more information about this error, try `rustc --explain E0015`.
You can’t perform that action at this time.
0 commit comments