update message
This commit is contained in:
parent
c2e849c022
commit
64fe2c183d
|
@ -1885,21 +1885,21 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
err.note(
|
err.note(
|
||||||
"the `Copy` trait is required because the repeated element will be copied",
|
"the `Copy` trait is required because the repeated element will be copied",
|
||||||
);
|
);
|
||||||
if is_const_fn && !self.tcx.sess.is_nightly_build() {
|
|
||||||
|
if is_const_fn {
|
||||||
err.help(
|
err.help(
|
||||||
"consider creating a new `const` item and initializing with the result \
|
"consider creating a new `const` item and initializing with the result \
|
||||||
of the function call to be used in the repeat position, like \
|
of the function call to be used in the repeat position, like \
|
||||||
`const VAL: Type = const_fn();` and `let x = [VAL; 42];`",
|
`const VAL: Type = const_fn();` and `let x = [VAL; 42];`",
|
||||||
);
|
);
|
||||||
} else if self.tcx.sess.is_nightly_build() && is_const_fn {
|
}
|
||||||
|
|
||||||
|
if self.tcx.sess.is_nightly_build() && is_const_fn {
|
||||||
err.help(
|
err.help(
|
||||||
"create an inline `const` block, see PR \
|
"create an inline `const` block, see PR \
|
||||||
#2920 <https://github.com/rust-lang/rfcs/pull/2920> \
|
#2920 <https://github.com/rust-lang/rfcs/pull/2920> \
|
||||||
for more information",
|
for more information",
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
// Don't suggest anything to the user as suggesting the user to make the function `const`
|
|
||||||
// could lead them down the wrong path.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ObligationCauseCode::VariableType(hir_id) => {
|
ObligationCauseCode::VariableType(hir_id) => {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
This directory contains the source code of the rust project, including:
|
This directory contains the source code of the rust project, including:
|
||||||
|
|
||||||
- The test suite
|
- The test suite
|
||||||
- The bootstrapping build system
|
- The bootstrapping build system
|
||||||
- Various submodules for tools, like rustdoc, rls, etc.
|
- Various submodules for tools, like rustdoc, rls, etc.
|
||||||
|
|
|
@ -7,6 +7,7 @@ LL | let _: [Option<Bar>; 2] = [no_copy(); 2];
|
||||||
= help: the following implementations were found:
|
= help: the following implementations were found:
|
||||||
<Option<T> as Copy>
|
<Option<T> as Copy>
|
||||||
= note: the `Copy` trait is required because the repeated element will be copied
|
= note: the `Copy` trait is required because the repeated element will be copied
|
||||||
|
= help: consider creating a new `const` item and initializing with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
|
||||||
= help: create an inline `const` block, see PR #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
|
= help: create an inline `const` block, see PR #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
// should hint to create an inline const block
|
// should hint to create an inline `const` block
|
||||||
// as all tests are on "nightly"
|
// or to create a new `const` item
|
||||||
let strings: [String; 5] = [String::new(); 5];
|
let strings: [String; 5] = [String::new(); 5];
|
||||||
//~^ ERROR the trait bound `String: Copy` is not satisfied
|
//~^ ERROR the trait bound `String: Copy` is not satisfied
|
||||||
println!("{:?}", strings);
|
println!("{:?}", strings);
|
||||||
|
|
|
@ -5,6 +5,7 @@ LL | let strings: [String; 5] = [String::new(); 5];
|
||||||
| ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
| ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
||||||
|
|
|
|
||||||
= note: the `Copy` trait is required because the repeated element will be copied
|
= note: the `Copy` trait is required because the repeated element will be copied
|
||||||
|
= help: consider creating a new `const` item and initializing with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
|
||||||
= help: create an inline `const` block, see PR #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
|
= help: create an inline `const` block, see PR #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Reference in New Issue