diff options
author | Florian Diebold <[email protected]> | 2021-04-05 20:29:20 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-05 20:58:03 +0100 |
commit | b443e5304ec43ae2049c72b694ff62baf4314cbb (patch) | |
tree | 30a4648745c87468d435c30edf9dbe851a7830ae /crates/hir_ty/src/types.rs | |
parent | 738174671ae40092684d7a9a543f939e318051e5 (diff) |
Remove some unused methods, move some to types.rs
Diffstat (limited to 'crates/hir_ty/src/types.rs')
-rw-r--r-- | crates/hir_ty/src/types.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/hir_ty/src/types.rs b/crates/hir_ty/src/types.rs index 6dffda1ca..4a626d5e7 100644 --- a/crates/hir_ty/src/types.rs +++ b/crates/hir_ty/src/types.rs | |||
@@ -360,6 +360,15 @@ impl<T: Clone> Binders<&T> { | |||
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | impl<T: TypeWalk> Binders<T> { | ||
364 | /// Substitutes all variables. | ||
365 | pub fn substitute(self, interner: &Interner, subst: &Substitution) -> T { | ||
366 | let (value, binders) = self.into_value_and_skipped_binders(); | ||
367 | assert_eq!(subst.len(interner), binders.len(interner)); | ||
368 | value.subst_bound_vars(subst) | ||
369 | } | ||
370 | } | ||
371 | |||
363 | impl<T: std::fmt::Debug> std::fmt::Debug for Binders<T> { | 372 | impl<T: std::fmt::Debug> std::fmt::Debug for Binders<T> { |
364 | fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { | 373 | fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { |
365 | let Binders { ref binders, ref value } = *self; | 374 | let Binders { ref binders, ref value } = *self; |
@@ -375,6 +384,12 @@ pub struct TraitRef { | |||
375 | pub substitution: Substitution, | 384 | pub substitution: Substitution, |
376 | } | 385 | } |
377 | 386 | ||
387 | impl TraitRef { | ||
388 | pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { | ||
389 | &self.substitution.at(interner, 0).assert_ty_ref(interner) | ||
390 | } | ||
391 | } | ||
392 | |||
378 | /// Like `generics::WherePredicate`, but with resolved types: A condition on the | 393 | /// Like `generics::WherePredicate`, but with resolved types: A condition on the |
379 | /// parameters of a generic item. | 394 | /// parameters of a generic item. |
380 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 395 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |