diff options
| author | Ryo Yoshida <low.ryoshida@gmail.com> | 2022-09-13 01:52:16 +0900 |
|---|---|---|
| committer | Ryo Yoshida <low.ryoshida@gmail.com> | 2022-09-13 02:20:35 +0900 |
| commit | d223c28c7d89de5a6f040e254c8a602ae7d48814 (patch) | |
| tree | ceab5ba3a437b3ab2164b05c40551173356cf928 | |
| parent | efb56160c91f0c1db511423fad8cc09fdd73d618 (diff) | |
| download | rust-d223c28c7d89de5a6f040e254c8a602ae7d48814.tar.gz rust-d223c28c7d89de5a6f040e254c8a602ae7d48814.zip | |
Remove unnecessary `Option`
| -rw-r--r-- | crates/hir-ty/src/db.rs | 2 | ||||
| -rw-r--r-- | crates/hir-ty/src/traits.rs | 6 | ||||
| -rw-r--r-- | crates/hir/src/lib.rs | 7 |
3 files changed, 10 insertions, 5 deletions
diff --git a/crates/hir-ty/src/db.rs b/crates/hir-ty/src/db.rs index dd5639f00d2..69283e55a4c 100644 --- a/crates/hir-ty/src/db.rs +++ b/crates/hir-ty/src/db.rs @@ -156,7 +156,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> { &self, projection: crate::ProjectionTy, env: Arc<crate::TraitEnvironment>, - ) -> Option<crate::Ty>; + ) -> Ty; #[salsa::invoke(trait_solve_wait)] #[salsa::transparent] diff --git a/crates/hir-ty/src/traits.rs b/crates/hir-ty/src/traits.rs index aaff894b34f..372c3a3cca6 100644 --- a/crates/hir-ty/src/traits.rs +++ b/crates/hir-ty/src/traits.rs @@ -69,10 +69,10 @@ pub(crate) fn normalize_projection_query( db: &dyn HirDatabase, projection: ProjectionTy, env: Arc<TraitEnvironment>, -) -> Option<Ty> { - let mut table = InferenceTable::new(db, env.clone()); +) -> Ty { + let mut table = InferenceTable::new(db, env); let ty = table.normalize_projection_ty(projection); - Some(table.resolve_completely(ty)) + table.resolve_completely(ty) } /// Solve a trait goal using Chalk. diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index d49d2e1ca3a..c981ffbc789 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2880,7 +2880,12 @@ impl Type { }) .build(); - db.normalize_projection(projection, self.env.clone()).map(|ty| self.derived(ty)) + let ty = db.normalize_projection(projection, self.env.clone()); + if ty.is_unknown() { + None + } else { + Some(self.derived(ty)) + } } pub fn is_copy(&self, db: &dyn HirDatabase) -> bool { |
