Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a `const_in_array_repeat_expressions` feature gate and only create `Candidate::Repeat` if it is enabled.
- Loading branch information
Showing
9 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/doc/unstable-book/src/language-features/const-in-array-repeat-expressions.md
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# `const_in_array_repeat_expressions` | ||
|
||
The tracking issue for this feature is: [#49147] | ||
|
||
[#44109]: https://github.com/rust-lang/rust/issues/49147 | ||
|
||
------------------------ | ||
|
||
Relaxes the rules for repeat expressions, `[x; N]` such that `x` may also be `const` (strictly | ||
speaking rvalue promotable), in addition to `typeof(x): Copy`. The result of `[x; N]` where `x` is | ||
`const` is itself also `const`. |
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
1 change: 1 addition & 0 deletions
1
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-borrowck.rs
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
4 changes: 2 additions & 2 deletions
4
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-borrowck.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
2 changes: 1 addition & 1 deletion
2
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-borrowck.rs
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
11 changes: 11 additions & 0 deletions
11
src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.rs
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// ignore-tidy-linelength | ||
#![allow(warnings)] | ||
|
||
struct Bar; | ||
|
||
fn foo() { | ||
let arr: [Option<String>; 2] = [None::<String>; 2]; | ||
//~^ ERROR the trait bound `std::option::Option<std::string::String>: std::marker::Copy` is not satisfied [E0277] | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0277]: the trait bound `std::option::Option<std::string::String>: std::marker::Copy` is not satisfied | ||
--> $DIR/feature-gate-const_in_array_repeat_expressions.rs:7:36 | ||
| | ||
LL | let arr: [Option<String>; 2] = [None::<String>; 2]; | ||
| ^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<std::string::String>` | ||
| | ||
= help: the following implementations were found: | ||
<std::option::Option<T> as std::marker::Copy> | ||
= note: the `Copy` trait is required because the repeated element will be copied | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |