1
Fork 0

Fix value suggestion for array in generic context

This commit is contained in:
Michael Goulet 2024-04-14 09:21:38 -04:00
parent d6ac50e547
commit e4c71f1fd8
4 changed files with 30 additions and 5 deletions

View file

@ -22,6 +22,7 @@
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(extract_if)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(option_take_if)]
#![feature(never_type)]

View file

@ -4583,11 +4583,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
format!("&{}{ty}", mutability.prefix_str())
}
}
ty::Array(ty, len) => format!(
"[{}; {}]",
self.ty_kind_suggestion(param_env, *ty)?,
len.eval_target_usize(tcx, ty::ParamEnv::reveal_all()),
),
ty::Array(ty, len) if let Some(len) = len.try_eval_target_usize(tcx, param_env) => {
format!("[{}; {}]", self.ty_kind_suggestion(param_env, *ty)?, len)
}
ty::Tuple(tys) => format!(
"({})",
tys.iter()