Skip to content

Commit

Permalink
Avoid using unwrap() in suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Mar 6, 2020
1 parent 865b44a commit 1631b4d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(&self_ty.kind, parent_pred)
{
if let ty::Adt(def, _) = p.skip_binder().trait_ref.self_ty().kind {
let id = self.tcx.hir().as_local_hir_id(def.did).unwrap();
let node = self.tcx.hir().get(id);
let node = self
.tcx
.hir()
.as_local_hir_id(def.did)
.map(|id| self.tcx.hir().get(id));
match node {
hir::Node::Item(hir::Item { kind, .. }) => {
Some(hir::Node::Item(hir::Item { kind, .. })) => {
if let Some(g) = kind.generics() {
let key = match &g.where_clause.predicates[..] {
[.., pred] => {
Expand Down

0 comments on commit 1631b4d

Please sign in to comment.