Skip to content

Commit

Permalink
Replace _ with /* Type */ in let binding type suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Aug 8, 2024
1 parent 1c57b0f commit a158bbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let ty = header.trait_ref.skip_binder().args.type_at(1);
if ty == self_ty {
if target_type {
paths.push(format!("{target}"));
let mut ty_str = format!("{target}");
if &ty_str == "_" {
ty_str = "/* Type */".to_string();
}
paths.push(ty_str);
} else {
paths.push(format!("<{self_ty} as Into<{target}>>::into"));
}
Expand Down Expand Up @@ -777,8 +781,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let identity_method = args.rebase_onto(tcx, def_id, trait_assoc_substs);
if target_type {
let fn_sig = tcx.fn_sig(def_id).instantiate(tcx, identity_method);
let ret = fn_sig.skip_binder().output();
paths.push(format!("{ret}"));
let mut ret = format!("{}", fn_sig.skip_binder().output());
if &ret == "_" {
ret = "/* Type */".to_string();
}
paths.push(ret);
} else {
paths.push(self.tcx.value_path_str_with_args(def_id, identity_method));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/pattern/slice-pattern-refutable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LL | let [a, b, c] = Zeroes.into() else {
|
help: consider giving this pattern a type
|
LL | let [a, b, c]: _ = Zeroes.into() else {
| +++
LL | let [a, b, c]: /* Type */ = Zeroes.into() else {
| ++++++++++++
help: consider giving this pattern a type
|
LL | let [a, b, c]: [usize; 3] = Zeroes.into() else {
Expand Down

0 comments on commit a158bbc

Please sign in to comment.