1
Fork 0

Rollup merge of #119805 - chenyukang:yukang-fix-119530, r=davidtwco

Suggest array::from_fn for array initialization

Fixes #119530
This commit is contained in:
León Orell Valerian Liehr 2024-01-23 21:19:52 +01:00 committed by GitHub
commit dd538b5f05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 40 additions and 0 deletions

View file

@ -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()