Skip to content

Commit 7f53c32

Browse files
authored
Rollup merge of #69727 - JohnTitor:sugg-unwrap, r=estebank
Avoid using `unwrap()` in suggestions Addresses #69725, still need a regression test. r? @estebank
2 parents b059d02 + 8efb9eb commit 7f53c32

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/librustc_typeck/check/method/suggest.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
547547
(&self_ty.kind, parent_pred)
548548
{
549549
if let ty::Adt(def, _) = p.skip_binder().trait_ref.self_ty().kind {
550-
let id = self.tcx.hir().as_local_hir_id(def.did).unwrap();
551-
let node = self.tcx.hir().get(id);
550+
let node = self
551+
.tcx
552+
.hir()
553+
.as_local_hir_id(def.did)
554+
.map(|id| self.tcx.hir().get(id));
552555
match node {
553-
hir::Node::Item(hir::Item { kind, .. }) => {
556+
Some(hir::Node::Item(hir::Item { kind, .. })) => {
554557
if let Some(g) = kind.generics() {
555558
let key = match &g.where_clause.predicates[..] {
556559
[.., pred] => {

0 commit comments

Comments
 (0)