about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-01-23 21:19:52 +0100
committerGitHub <noreply@github.com>2024-01-23 21:19:52 +0100
commitdd538b5f05a648d50f7e94ccf01763e68a053453 (patch)
tree88bebcaddb705c3d442485a9e6c0f0633fa643f7 /compiler
parente8f9e5481e3418d0525c4d54e61630391075c31d (diff)
parent3ed96e35c422941535cf0b19e5207572c8f38157 (diff)
downloadrust-dd538b5f05a648d50f7e94ccf01763e68a053453.tar.gz
rust-dd538b5f05a648d50f7e94ccf01763e68a053453.zip
Rollup merge of #119805 - chenyukang:yukang-fix-119530, r=davidtwco
Suggest array::from_fn for array initialization

Fixes #119530
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index 0e33e9cd790..e31aaaa1969 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -3152,6 +3152,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
                         ],
                         Applicability::MachineApplicable,
                     );
+                } else {
+                    // FIXME: we may suggest array::repeat instead
+                    err.help("consider using `core::array::from_fn` to initialize the array");
+                    err.help("see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information");
                 }
 
                 if self.tcx.sess.is_nightly_build()