forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#65858 - davidtwco:rfc-2203-feature-gate-in-…
…error, r=ecstatic-morse suggest `const_in_array_repeat_expression` flag This PR adds a suggestion to add the `#![feature(const_in_array_repeat_expression)]` attribute to the crate when a promotable expression is used in a repeat expression and the feature gate is not enabled. Unfortunately, this ended up being a little bit more complex than I anticipated, which may not have been worth it given that this would all be removed when the feature is stabilized. However, with rust-lang#65732 and rust-lang#65737 being open, and the feature gate having not been being suggested to potential users, the feature might not be stabilized in a while, so maybe this is worth landing. cc @Centril (addresses [this comment](rust-lang#61749 (comment))) r? @ecstatic-morse (opened issues related to RFC 2203 recently)
- Loading branch information
Showing
8 changed files
with
83 additions
and
14 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
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
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
16 changes: 14 additions & 2 deletions
16
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 |
---|---|---|
@@ -1,13 +1,25 @@ | ||
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 | ||
--> $DIR/feature-gate-const_in_array_repeat_expressions.rs:8: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 | ||
= note: this array initializer can be evaluated at compile-time, for more information, see issue https://github.com/rust-lang/rust/issues/49147 | ||
= help: add `#![feature(const_in_array_repeat_expression)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
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:14:36 | ||
| | ||
LL | let arr: [Option<String>; 2] = [Some("foo".to_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 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |