Skip to content

Commit c0f37fa

Browse files
authored
Rollup merge of #118514 - Enselic:ice-probe, r=cjgillot
rustc_hir_typeck: Fix ICE when probing for non-ASCII function alternative Closes #118499 Apparently triggered by #118381
2 parents 4e3dc97 + 5c8c3a2 commit c0f37fa

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

compiler/rustc_hir_typeck/src/method/probe.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1799,9 +1799,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
17991799
.iter()
18001800
.find(|cand| self.matches_by_doc_alias(cand.def_id))
18011801
.map(|cand| cand.name)
1802-
})
1803-
.unwrap();
1804-
Ok(applicable_close_candidates.into_iter().find(|method| method.name == best_name))
1802+
});
1803+
Ok(best_name.and_then(|best_name| {
1804+
applicable_close_candidates.into_iter().find(|method| method.name == best_name)
1805+
}))
18051806
}
18061807
})
18071808
}
+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
fn main() {
22
// There shall be no suggestions here. In particular not `Ok`.
33
let _ = 读文; //~ ERROR cannot find value `读文` in this scope
4+
5+
let f = 0f32; // Important line to make this an ICE regression test
6+
读文(f); //~ ERROR cannot find function `读文` in this scope
47
}

tests/ui/suggestions/non_ascii_ident.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ error[E0425]: cannot find value `读文` in this scope
44
LL | let _ = 读文;
55
| ^^^^ not found in this scope
66

7-
error: aborting due to 1 previous error
7+
error[E0425]: cannot find function `读文` in this scope
8+
--> $DIR/non_ascii_ident.rs:6:5
9+
|
10+
LL | 读文(f);
11+
| ^^^^ not found in this scope
12+
13+
error: aborting due to 2 previous errors
814

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

0 commit comments

Comments
 (0)