Skip to content

Commit b0df8f0

Browse files
authored
Rollup merge of rust-lang#50031 - krk:issue-46336, r=estebank
Clarified E0015 message. Closes rust-lang#46336
2 parents 6586074 + b39b3a2 commit b0df8f0

File tree

6 files changed

+40
-7
lines changed

6 files changed

+40
-7
lines changed

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,15 +964,15 @@ This does not pose a problem by itself because they can't be accessed directly."
964964
let (msg, note) = if let UnstableFeatures::Disallow =
965965
self.tcx.sess.opts.unstable_features {
966966
(format!("calls in {}s are limited to \
967-
struct and enum constructors",
967+
tuple structs and tuple variants",
968968
self.mode),
969969
Some("a limited form of compile-time function \
970970
evaluation is available on a nightly \
971971
compiler via `const fn`"))
972972
} else {
973973
(format!("calls in {}s are limited \
974974
to constant functions, \
975-
struct and enum constructors",
975+
tuple structs and tuple variants",
976976
self.mode),
977977
None)
978978
};

src/test/compile-fail/issue-43105.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fn xyz() -> u8 { 42 }
1212

1313
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
1515
//~| ERROR constant evaluation error
1616

1717
fn main() {

src/test/compile-fail/issue32829.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
11+
// ignore-tidy-linelength
12+
1013
#![feature(const_fn)]
1114

1215
const bad : u32 = {
@@ -20,7 +23,7 @@ const bad_two : u32 = {
2023
{
2124
invalid();
2225
//~^ 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
2427
0
2528
}
2629
};
@@ -44,7 +47,7 @@ static bad_five : u32 = {
4447
{
4548
invalid();
4649
//~^ 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
4851
0
4952
}
5053
};
@@ -68,7 +71,7 @@ static mut bad_eight : u32 = {
6871
{
6972
invalid();
7073
//~^ 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
7275
0
7376
}
7477
};

src/test/ui/const-fn-error.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0016]: blocks in constant functions are limited to items and tail express
44
LL | let mut sum = 0;
55
| ^
66

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
88
--> $DIR/const-fn-error.rs:18:14
99
|
1010
LL | for i in 0..x {

src/test/ui/mir_check_nonconst.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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() {}

src/test/ui/mir_check_nonconst.stderr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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`.

0 commit comments

Comments
 (0)