aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/chalk_ext.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-04-04 12:30:07 +0100
committerGitHub <[email protected]>2021-04-04 12:30:07 +0100
commit082996032054031bd1b68ee45ab04293f4877e91 (patch)
treeccf4586bbb70ef9ebf429a2c79a5f409549ebf73 /crates/hir_ty/src/chalk_ext.rs
parentc9bcbf9a43eb0bf1a5255f704080305e568f0a36 (diff)
parentcde3857897955558ed0e60cf8158e18d5c75d188 (diff)
Merge #8327
8327: Move `Ty` creation methods out of `Ty` (Chalk move preparation) r=flodiebold a=flodiebold When we'll move to using `chalk_ir::Ty` (#8313), we won't be able to have our own inherent methods on `Ty` anymore, so we need to move the helpers elsewhere. This adds a `TyBuilder` that allows easily constructing `Ty` and related types (`TraitRef`, `ProjectionTy`, `Substitution`). It also replaces `SubstsBuilder`. `TyBuilder` can construct different things based on its type parameter; e.g. if it has an `AdtId`, we're constructing an ADT type, but if it has a `TraitId`, we're constructing a `TraitRef`. The common thing for all of them is that we need to build a `Substitution`, so the API stays the same for all of them except at the beginning and end. We also use `TyBuilder` to house various one-shot methods for constructing types, e.g. `TyBuilder::unit()`. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/chalk_ext.rs')
-rw-r--r--crates/hir_ty/src/chalk_ext.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/hir_ty/src/chalk_ext.rs b/crates/hir_ty/src/chalk_ext.rs
new file mode 100644
index 000000000..b7463366b
--- /dev/null
+++ b/crates/hir_ty/src/chalk_ext.rs
@@ -0,0 +1,13 @@
1//! Various extensions traits for Chalk types.
2
3use crate::{Interner, Ty, TyKind};
4
5pub trait TyExt {
6 fn is_unit(&self) -> bool;
7}
8
9impl TyExt for Ty {
10 fn is_unit(&self) -> bool {
11 matches!(self.kind(&Interner), TyKind::Tuple(0, _))
12 }
13}