]> git.lizzy.rs Git - rust.git/commitdiff
self.associated_item can return none
authorjsirs <44773712+jsirs@users.noreply.github.com>
Mon, 5 Nov 2018 12:37:36 +0000 (14:37 +0200)
committerGitHub <noreply@github.com>
Mon, 5 Nov 2018 12:37:36 +0000 (14:37 +0200)
self.associated_item can return none, replace unwrap with '?' and bubble up None value instead of panicking

src/librustc_typeck/check/method/mod.rs

index 11448750618e218252dd96cb040609c91127dac6..3fd61dbb97d94463e01aaf4701c536c8681b05fe 100644 (file)
@@ -290,7 +290,7 @@ pub fn lookup_method_in_trait(&self,
         // type parameters or early-bound regions.
         let tcx = self.tcx;
         let method_item =
-            self.associated_item(trait_def_id, m_name, Namespace::Value).unwrap();
+            self.associated_item(trait_def_id, m_name, Namespace::Value)?;
         let def_id = method_item.def_id;
         let generics = tcx.generics_of(def_id);
         assert_eq!(generics.params.len(), 0);