-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
64 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
struct X<const N: usize = { | ||
(||1usize)() | ||
//~^ ERROR cannot call | ||
//~^ ERROR the trait bound | ||
}>; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
error[E0015]: cannot call non-const closure in constants | ||
error[E0277]: the trait bound `[closure@$DIR/issue-93647.rs:2:6: 2:8]: Fn<()>` is not satisfied | ||
--> $DIR/issue-93647.rs:2:5 | ||
| | ||
LL | (||1usize)() | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-93647.rs:2:6: 2:8]` | ||
| | ||
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-93647.rs:2:6: 2:8]` | ||
note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-93647.rs:2:6: 2:8]`, but that implementation is not `const` | ||
--> $DIR/issue-93647.rs:2:5 | ||
| | ||
= note: closures need an RFC before allowed to be called in constants | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
LL | (||1usize)() | ||
| ^^^^^^^^^^^^ | ||
= note: wrap the `[closure@$DIR/issue-93647.rs:2:6: 2:8]` in a closure with no arguments: `|| { /* code */ }` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
const X: u8 = | ||
|| -> u8 { 5 }() | ||
//~^ ERROR cannot call non-const closure | ||
//~^ ERROR the trait bound | ||
; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
error[E0015]: cannot call non-const closure in constants | ||
error[E0277]: the trait bound `[closure@$DIR/issue-28113.rs:4:5: 4:13]: Fn<()>` is not satisfied | ||
--> $DIR/issue-28113.rs:4:5 | ||
| | ||
LL | || -> u8 { 5 }() | ||
| ^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-28113.rs:4:5: 4:13]` | ||
| | ||
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-28113.rs:4:5: 4:13]` | ||
note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-28113.rs:4:5: 4:13]`, but that implementation is not `const` | ||
--> $DIR/issue-28113.rs:4:5 | ||
| | ||
= note: closures need an RFC before allowed to be called in constants | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
LL | || -> u8 { 5 }() | ||
| ^^^^^^^^^^^^^^^^ | ||
= note: wrap the `[closure@$DIR/issue-28113.rs:4:5: 4:13]` in a closure with no arguments: `|| { /* code */ }` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,17 @@ | ||
error[E0015]: cannot call non-const closure in constant functions | ||
error[E0277]: the trait bound `[closure@$DIR/issue-56164.rs:1:19: 1:21]: Fn<()>` is not satisfied | ||
--> $DIR/issue-56164.rs:1:18 | ||
| | ||
LL | const fn foo() { (||{})() } | ||
| ^^^^^^^^ | ||
| | ||
= note: closures need an RFC before allowed to be called in constant functions | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: function pointer calls are not allowed in constant functions | ||
--> $DIR/issue-56164.rs:7:5 | ||
| ^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-56164.rs:1:19: 1:21]` | ||
| | ||
LL | input() | ||
| ^^^^^^^ | ||
|
||
error: erroneous constant used | ||
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-56164.rs:1:19: 1:21]` | ||
note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-56164.rs:1:19: 1:21]`, but that implementation is not `const` | ||
--> $DIR/issue-56164.rs:1:18 | ||
| | ||
LL | const fn foo() { (||{})() } | ||
| ^^^^^^ referenced constant has errors | ||
| | ||
= note: `#[deny(const_err)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> | ||
|
||
error: aborting due to 3 previous errors | ||
| ^^^^^^^^ | ||
= note: wrap the `[closure@$DIR/issue-56164.rs:1:19: 1:21]` in a closure with no arguments: `|| { /* code */ }` | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
Future incompatibility report: Future breakage diagnostic: | ||
error: erroneous constant used | ||
--> $DIR/issue-56164.rs:1:18 | ||
| | ||
LL | const fn foo() { (||{})() } | ||
| ^^^^^^ referenced constant has errors | ||
| | ||
= note: `#[deny(const_err)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> | ||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
src/test/ui/consts/issue-68542-closure-in-array-len.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
error[E0015]: cannot call non-const closure in constants | ||
error[E0277]: the trait bound `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]: Fn<()>` is not satisfied | ||
--> $DIR/issue-68542-closure-in-array-len.rs:6:13 | ||
| | ||
LL | a: [(); (|| { 0 })()] | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` | ||
| | ||
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` | ||
note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]`, but that implementation is not `const` | ||
--> $DIR/issue-68542-closure-in-array-len.rs:6:13 | ||
| | ||
= note: closures need an RFC before allowed to be called in constants | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
LL | a: [(); (|| { 0 })()] | ||
| ^^^^^^^^^^^^ | ||
= note: wrap the `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` in a closure with no arguments: `|| { /* code */ }` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,21 @@ | ||
error[E0015]: cannot call non-const closure in constant functions | ||
--> $DIR/unstable-const-fn-in-libcore.rs:22:26 | ||
| | ||
LL | Opt::None => f(), | ||
| ^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
help: consider further restricting this bound | ||
| | ||
LL | const fn unwrap_or_else<F: FnOnce() -> T + ~const std::ops::FnOnce<()>>(self, f: F) -> T { | ||
| +++++++++++++++++++++++++++++ | ||
|
||
error[E0493]: destructors cannot be evaluated at compile-time | ||
--> $DIR/unstable-const-fn-in-libcore.rs:17:53 | ||
--> $DIR/unstable-const-fn-in-libcore.rs:17:60 | ||
| | ||
LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T { | ||
| ^ constant functions cannot evaluate destructors | ||
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { | ||
| ^ constant functions cannot evaluate destructors | ||
... | ||
LL | } | ||
| - value is dropped here | ||
|
||
error[E0493]: destructors cannot be evaluated at compile-time | ||
--> $DIR/unstable-const-fn-in-libcore.rs:17:47 | ||
--> $DIR/unstable-const-fn-in-libcore.rs:17:54 | ||
| | ||
LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T { | ||
| ^^^^ constant functions cannot evaluate destructors | ||
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { | ||
| ^^^^ constant functions cannot evaluate destructors | ||
... | ||
LL | } | ||
| - value is dropped here | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0015, E0493. | ||
For more information about an error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0493`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters