From 7a5fb37cf12f4e25ce1ba7e464dd257408444bfb Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 20 Mar 2021 10:46:36 +0100 Subject: Rename GenericPredicate -> WhereClause --- crates/hir_ty/src/lower.rs | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'crates/hir_ty/src/lower.rs') diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 7d22c3df5..4199dc7a6 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -33,9 +33,9 @@ use crate::{ all_super_trait_refs, associated_type_by_name_including_super_traits, generics, variant_data, }, - AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, FnPointer, FnSig, - GenericPredicate, ImplTraitId, OpaqueTy, PolyFnSig, ProjectionTy, ReturnTypeImplTrait, - ReturnTypeImplTraits, Substitution, TraitEnvironment, TraitRef, Ty, TyKind, TypeWalk, + AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, FnPointer, FnSig, ImplTraitId, + OpaqueTy, PolyFnSig, ProjectionTy, ReturnTypeImplTrait, ReturnTypeImplTraits, Substitution, + TraitEnvironment, TraitRef, Ty, TyKind, TypeWalk, WhereClause, }; #[derive(Debug)] @@ -373,8 +373,7 @@ impl<'a> TyLoweringContext<'a> { // FIXME report error (ambiguous associated type) TyKind::Unknown.intern(&Interner) } else { - TyKind::Dyn(Arc::new([GenericPredicate::Implemented(trait_ref)])) - .intern(&Interner) + TyKind::Dyn(Arc::new([WhereClause::Implemented(trait_ref)])).intern(&Interner) }; return (ty, None); } @@ -667,7 +666,7 @@ impl<'a> TyLoweringContext<'a> { pub(crate) fn lower_where_predicate( &'a self, where_predicate: &'a WherePredicate, - ) -> impl Iterator + 'a { + ) -> impl Iterator + 'a { match where_predicate { WherePredicate::ForLifetime { target, bound, .. } | WherePredicate::TypeBound { target, bound } => { @@ -699,17 +698,15 @@ impl<'a> TyLoweringContext<'a> { &'a self, bound: &'a TypeBound, self_ty: Ty, - ) -> impl Iterator + 'a { + ) -> impl Iterator + 'a { let mut bindings = None; let trait_ref = match bound { TypeBound::Path(path) => { bindings = self.lower_trait_ref_from_path(path, Some(self_ty)); - Some( - bindings.clone().map_or(GenericPredicate::Error, GenericPredicate::Implemented), - ) + Some(bindings.clone().map_or(WhereClause::Error, WhereClause::Implemented)) } TypeBound::Lifetime(_) => None, - TypeBound::Error => Some(GenericPredicate::Error), + TypeBound::Error => Some(WhereClause::Error), }; trait_ref.into_iter().chain( bindings @@ -722,7 +719,7 @@ impl<'a> TyLoweringContext<'a> { &'a self, bound: &'a TypeBound, trait_ref: TraitRef, - ) -> impl Iterator + 'a { + ) -> impl Iterator + 'a { let last_segment = match bound { TypeBound::Path(path) => path.segments().last(), TypeBound::Error | TypeBound::Lifetime(_) => None, @@ -738,7 +735,7 @@ impl<'a> TyLoweringContext<'a> { &binding.name, ); let (super_trait_ref, associated_ty) = match found { - None => return SmallVec::<[GenericPredicate; 1]>::new(), + None => return SmallVec::<[WhereClause; 1]>::new(), Some(t) => t, }; let projection_ty = ProjectionTy { @@ -752,7 +749,7 @@ impl<'a> TyLoweringContext<'a> { let ty = self.lower_ty(type_ref); let alias_eq = AliasEq { alias: AliasTy::Projection(projection_ty.clone()), ty }; - preds.push(GenericPredicate::AliasEq(alias_eq)); + preds.push(WhereClause::AliasEq(alias_eq)); } for bound in &binding.bounds { preds.extend(self.lower_type_bound( @@ -809,7 +806,7 @@ pub fn associated_type_shorthand_candidates( let mut traits_: Vec<_> = predicates .iter() .filter_map(|pred| match &pred.value { - GenericPredicate::Implemented(tr) => Some(tr.clone()), + WhereClause::Implemented(tr) => Some(tr.clone()), _ => None, }) .collect(); @@ -881,7 +878,7 @@ pub(crate) fn field_types_query( pub(crate) fn generic_predicates_for_param_query( db: &dyn HirDatabase, param_id: TypeParamId, -) -> Arc<[Binders]> { +) -> Arc<[Binders]> { let resolver = param_id.parent.resolver(db.upcast()); let ctx = TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); @@ -907,7 +904,7 @@ pub(crate) fn generic_predicates_for_param_recover( _db: &dyn HirDatabase, _cycle: &[String], _param_id: &TypeParamId, -) -> Arc<[Binders]> { +) -> Arc<[Binders]> { Arc::new([]) } @@ -925,7 +922,7 @@ pub(crate) fn trait_environment_query( if pred.is_error() { continue; } - if let GenericPredicate::Implemented(tr) = &pred { + if let WhereClause::Implemented(tr) = &pred { traits_in_scope.push((tr.self_type_parameter().clone(), tr.hir_trait_id())); } let program_clause: chalk_ir::ProgramClause = @@ -951,7 +948,7 @@ pub(crate) fn trait_environment_query( cov_mark::hit!(trait_self_implements_self); let substs = Substitution::type_params(db, trait_id); let trait_ref = TraitRef { trait_id: to_chalk_trait_id(trait_id), substitution: substs }; - let pred = GenericPredicate::Implemented(trait_ref); + let pred = WhereClause::Implemented(trait_ref); let program_clause: chalk_ir::ProgramClause = pred.clone().to_chalk(db).cast(&Interner); clauses.push(program_clause.into_from_env_clause(&Interner)); @@ -966,7 +963,7 @@ pub(crate) fn trait_environment_query( pub(crate) fn generic_predicates_query( db: &dyn HirDatabase, def: GenericDefId, -) -> Arc<[Binders]> { +) -> Arc<[Binders]> { let resolver = def.resolver(db.upcast()); let ctx = TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); -- cgit v1.2.3