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 5, 2020
1 parent 75cf41a commit 8efb9eb
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 8efb9eb

Please sign in to comment.