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) {
|
if let (ty::Str, hir::Mutability::Not) = (ty.kind(), mutability) {
|
||||||
"\"\"".to_string()
|
"\"\"".to_string()
|
||||||
} else {
|
} else {
|
||||||
let Some(ty) = self.ty_kind_suggestion(param_env, *ty) else {
|
let ty = self.ty_kind_suggestion(param_env, *ty)?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
format!("&{}{ty}", mutability.prefix_str())
|
format!("&{}{ty}", mutability.prefix_str())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4587,11 +4585,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
format!("[{}; {}]", self.ty_kind_suggestion(param_env, *ty)?, len)
|
format!("[{}; {}]", self.ty_kind_suggestion(param_env, *ty)?, len)
|
||||||
}
|
}
|
||||||
ty::Tuple(tys) => format!(
|
ty::Tuple(tys) => format!(
|
||||||
"({})",
|
"({}{})",
|
||||||
tys.iter()
|
tys.iter()
|
||||||
.map(|ty| self.ty_kind_suggestion(param_env, ty))
|
.map(|ty| self.ty_kind_suggestion(param_env, ty))
|
||||||
.collect::<Option<Vec<String>>>()?
|
.collect::<Option<Vec<String>>>()?
|
||||||
.join(", ")
|
.join(", "),
|
||||||
|
if tys.len() == 1 { "," } else { "" }
|
||||||
),
|
),
|
||||||
_ => "value".to_string(),
|
_ => "value".to_string(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,8 +8,8 @@ LL | return;
|
||||||
|
|
|
|
||||||
help: give the `return` a value of the expected type
|
help: give the `return` a value of the expected type
|
||||||
|
|
|
|
||||||
LL | return (42);
|
LL | return (42,);
|
||||||
| ++++
|
| +++++
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue