Skip to content

Commit

Permalink
Rollup merge of rust-lang#118514 - Enselic:ice-probe, r=cjgillot
Browse files Browse the repository at this point in the history
rustc_hir_typeck: Fix ICE when probing for non-ASCII function alternative

Closes rust-lang#118499

Apparently triggered by rust-lang#118381
  • Loading branch information
matthiaskrgr authored Dec 2, 2023
2 parents 4e3dc97 + 5c8c3a2 commit c0f37fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1799,9 +1799,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
.iter()
.find(|cand| self.matches_by_doc_alias(cand.def_id))
.map(|cand| cand.name)
})
.unwrap();
Ok(applicable_close_candidates.into_iter().find(|method| method.name == best_name))
});
Ok(best_name.and_then(|best_name| {
applicable_close_candidates.into_iter().find(|method| method.name == best_name)
}))
}
})
}
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/suggestions/non_ascii_ident.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
fn main() {
// There shall be no suggestions here. In particular not `Ok`.
let _ = 读文; //~ ERROR cannot find value `读文` in this scope

let f = 0f32; // Important line to make this an ICE regression test
读文(f); //~ ERROR cannot find function `读文` in this scope
}
8 changes: 7 additions & 1 deletion tests/ui/suggestions/non_ascii_ident.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ error[E0425]: cannot find value `读文` in this scope
LL | let _ = 读文;
| ^^^^ not found in this scope

error: aborting due to 1 previous error
error[E0425]: cannot find function `读文` in this scope
--> $DIR/non_ascii_ident.rs:6:5
|
LL | 读文(f);
| ^^^^ not found in this scope

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0425`.

0 comments on commit c0f37fa

Please sign in to comment.