Fix 1-tuple value suggestion
This commit is contained in:
parent
4af94cfa05
commit
325b24d763
2 changed files with 6 additions and 7 deletions
|
@ -4577,9 +4577,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
if let (ty::Str, hir::Mutability::Not) = (ty.kind(), mutability) {
|
||||
"\"\"".to_string()
|
||||
} else {
|
||||
let Some(ty) = self.ty_kind_suggestion(param_env, *ty) else {
|
||||
return None;
|
||||
};
|
||||
let ty = self.ty_kind_suggestion(param_env, *ty)?;
|
||||
format!("&{}{ty}", mutability.prefix_str())
|
||||
}
|
||||
}
|
||||
|
@ -4587,11 +4585,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
format!("[{}; {}]", self.ty_kind_suggestion(param_env, *ty)?, len)
|
||||
}
|
||||
ty::Tuple(tys) => format!(
|
||||
"({})",
|
||||
"({}{})",
|
||||
tys.iter()
|
||||
.map(|ty| self.ty_kind_suggestion(param_env, ty))
|
||||
.collect::<Option<Vec<String>>>()?
|
||||
.join(", ")
|
||||
.join(", "),
|
||||
if tys.len() == 1 { "," } else { "" }
|
||||
),
|
||||
_ => "value".to_string(),
|
||||
})
|
||||
|
|
|
@ -8,8 +8,8 @@ LL | return;
|
|||
|
|
||||
help: give the `return` a value of the expected type
|
||||
|
|
||||
LL | return (42);
|
||||
| ++++
|
||||
LL | return (42,);
|
||||
| +++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue