improve const fn
RepeatVec
diagnostics
This commit is contained in:
parent
eb476b172f
commit
bba2bac9fe
@ -1908,7 +1908,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
if is_const_fn {
|
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 it 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];`",
|
||||||
);
|
);
|
||||||
@ -1916,7 +1916,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
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 RFC \
|
||||||
#2920 <https://github.com/rust-lang/rfcs/pull/2920> \
|
#2920 <https://github.com/rust-lang/rfcs/pull/2920> \
|
||||||
for more information",
|
for more information",
|
||||||
);
|
);
|
||||||
|
@ -7,8 +7,8 @@ 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: consider creating a new `const` item and initializing it 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 RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ 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: consider creating a new `const` item and initializing it 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 RFC #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…
x
Reference in New Issue
Block a user