4
4
5
5
use std:: {
6
6
fmt:: { self , Debug } ,
7
- iter , mem,
7
+ mem,
8
8
} ;
9
9
10
10
use base_db:: Crate ;
11
- use chalk_ir:: { BoundVar , Safety , TyKind , cast:: Cast } ;
12
- use chalk_solve:: rust_ir;
11
+ use chalk_ir:: { BoundVar , Safety , TyKind } ;
13
12
use either:: Either ;
14
13
use hir_def:: {
15
14
GenericDefId , HasModule , ImportPathConfig , ItemContainerId , LocalFieldId , Lookup , ModuleDefId ,
@@ -47,6 +46,7 @@ use crate::{
47
46
LifetimeData , LifetimeOutlives , MemoryMap , Mutability , OpaqueTy , ProjectionTy , ProjectionTyExt ,
48
47
QuantifiedWhereClause , Scalar , Substitution , TraitEnvironment , TraitRef , TraitRefExt , Ty ,
49
48
TyExt , WhereClause ,
49
+ chalk_db:: inline_bound_to_generic_predicate,
50
50
consteval:: try_const_usize,
51
51
db:: { HirDatabase , InternedClosure } ,
52
52
from_assoc_type_id, from_foreign_def_id, from_placeholder_idx,
@@ -643,7 +643,10 @@ impl HirDisplay for ProjectionTy {
643
643
. iter ( )
644
644
. map ( |bound| {
645
645
// We ignore `Self` anyway when formatting, so it's fine put an error type in it.
646
- inline_bound_to_generic_predicate ( bound)
646
+ inline_bound_to_generic_predicate (
647
+ bound,
648
+ TyKind :: Error . intern ( Interner ) ,
649
+ )
647
650
} )
648
651
. collect :: < Vec < _ > > ( ) ,
649
652
SizedByDefault :: Sized {
@@ -656,45 +659,6 @@ impl HirDisplay for ProjectionTy {
656
659
}
657
660
}
658
661
659
- /// Fills `Self` with an error type.
660
- pub ( crate ) fn inline_bound_to_generic_predicate (
661
- bound : & chalk_ir:: Binders < rust_ir:: InlineBound < Interner > > ,
662
- ) -> QuantifiedWhereClause {
663
- let ( bound, binders) = bound. as_ref ( ) . into_value_and_skipped_binders ( ) ;
664
- match bound {
665
- rust_ir:: InlineBound :: TraitBound ( trait_bound) => {
666
- let trait_ref = TraitRef {
667
- trait_id : trait_bound. trait_id ,
668
- substitution : Substitution :: from_iter (
669
- Interner ,
670
- iter:: once ( TyKind :: Error . intern ( Interner ) . cast ( Interner ) )
671
- . chain ( trait_bound. args_no_self . iter ( ) . cloned ( ) ) ,
672
- ) ,
673
- } ;
674
- chalk_ir:: Binders :: new ( binders, WhereClause :: Implemented ( trait_ref) )
675
- }
676
- rust_ir:: InlineBound :: AliasEqBound ( alias_eq) => {
677
- let substitution = Substitution :: from_iter (
678
- Interner ,
679
- alias_eq
680
- . parameters
681
- . iter ( )
682
- . cloned ( )
683
- . chain ( iter:: once ( TyKind :: Error . intern ( Interner ) . cast ( Interner ) ) )
684
- . chain ( alias_eq. trait_bound . args_no_self . iter ( ) . cloned ( ) ) ,
685
- ) ;
686
- let alias = AliasEq {
687
- ty : alias_eq. value . clone ( ) ,
688
- alias : AliasTy :: Projection ( ProjectionTy {
689
- associated_ty_id : alias_eq. associated_ty_id ,
690
- substitution,
691
- } ) ,
692
- } ;
693
- chalk_ir:: Binders :: new ( binders, WhereClause :: AliasEq ( alias) )
694
- }
695
- }
696
- }
697
-
698
662
impl HirDisplay for OpaqueTy {
699
663
fn hir_fmt ( & self , f : & mut HirFormatter < ' _ > ) -> Result < ( ) , HirDisplayError > {
700
664
if f. should_truncate ( ) {
@@ -1845,7 +1809,7 @@ pub fn write_bounds_like_dyn_trait_with_prefix(
1845
1809
}
1846
1810
}
1847
1811
1848
- fn write_bounds_like_dyn_trait (
1812
+ pub ( crate ) fn write_bounds_like_dyn_trait (
1849
1813
f : & mut HirFormatter < ' _ > ,
1850
1814
this : Either < & Ty , & Lifetime > ,
1851
1815
predicates : & [ QuantifiedWhereClause ] ,
0 commit comments