From 969f588025ab2c3224757e282ef78a546c4f56c4 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 19 Jan 2019 18:58:04 +0100 Subject: Generics -> GenericParams --- crates/ra_hir/src/code_model_api.rs | 22 +++++++++--------- crates/ra_hir/src/db.rs | 6 ++--- crates/ra_hir/src/generics.rs | 8 +++---- crates/ra_hir/src/mock.rs | 2 +- crates/ra_hir/src/ty.rs | 38 +++++++++++++++---------------- crates/ra_hir/src/ty/method_resolution.rs | 4 ++-- crates/ra_ide_api/src/db.rs | 2 +- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 6c85e5939..88eda5ed0 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -12,7 +12,7 @@ use crate::{ expr::BodySyntaxMapping, ty::InferenceResult, adt::VariantData, - generics::Generics, + generics::GenericParams, code_model_impl::def_id_to_ast, }; @@ -203,8 +203,8 @@ impl Struct { def_id_to_ast(db, self.def_id) } - pub fn generics(&self, db: &impl HirDatabase) -> Arc { - db.generics(self.def_id) + pub fn generic_params(&self, db: &impl HirDatabase) -> Arc { + db.generic_params(self.def_id) } } @@ -234,8 +234,8 @@ impl Enum { def_id_to_ast(db, self.def_id) } - pub fn generics(&self, db: &impl HirDatabase) -> Arc { - db.generics(self.def_id) + pub fn generic_params(&self, db: &impl HirDatabase) -> Arc { + db.generic_params(self.def_id) } } @@ -349,8 +349,8 @@ impl Function { db.infer(self.def_id) } - pub fn generics(&self, db: &impl HirDatabase) -> Arc { - db.generics(self.def_id) + pub fn generic_params(&self, db: &impl HirDatabase) -> Arc { + db.generic_params(self.def_id) } } @@ -398,8 +398,8 @@ impl Trait { def_id_to_ast(db, self.def_id) } - pub fn generics(&self, db: &impl HirDatabase) -> Arc { - db.generics(self.def_id) + pub fn generic_params(&self, db: &impl HirDatabase) -> Arc { + db.generic_params(self.def_id) } } @@ -417,7 +417,7 @@ impl Type { def_id_to_ast(db, self.def_id) } - pub fn generics(&self, db: &impl HirDatabase) -> Arc { - db.generics(self.def_id) + pub fn generic_params(&self, db: &impl HirDatabase) -> Arc { + db.generic_params(self.def_id) } } diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 10e64f880..f383701d7 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -14,7 +14,7 @@ use crate::{ ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks}, adt::{StructData, EnumData, EnumVariantData}, impl_block::ModuleImplBlocks, - generics::Generics, + generics::GenericParams, }; #[salsa::query_group] @@ -102,8 +102,8 @@ pub trait HirDatabase: #[salsa::invoke(crate::expr::body_syntax_mapping)] fn body_syntax_mapping(&self, def_id: DefId) -> Arc; - #[salsa::invoke(crate::generics::Generics::generics_query)] - fn generics(&self, def_id: DefId) -> Arc; + #[salsa::invoke(crate::generics::GenericParams::generic_params_query)] + fn generic_params(&self, def_id: DefId) -> Arc; #[salsa::invoke(crate::FnSignature::fn_signature_query)] fn fn_signature(&self, def_id: DefId) -> Arc; diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index cdabc0424..d8248ad49 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs @@ -18,14 +18,14 @@ pub struct GenericParam { /// Data about the generic parameters of a function, struct, impl, etc. #[derive(Clone, PartialEq, Eq, Debug, Default)] -pub struct Generics { +pub struct GenericParams { pub(crate) params: Vec, } -impl Generics { - pub(crate) fn generics_query(db: &impl HirDatabase, def_id: DefId) -> Arc { +impl GenericParams { + pub(crate) fn generic_params_query(db: &impl HirDatabase, def_id: DefId) -> Arc { let (_file_id, node) = def_id.source(db); - let mut generics = Generics::default(); + let mut generics = GenericParams::default(); if let Some(type_param_list) = node.children().find_map(TypeParamList::cast) { for (idx, type_param) in type_param_list.type_params().enumerate() { let name = type_param diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs index d674db8e6..6e6f2f04b 100644 --- a/crates/ra_hir/src/mock.rs +++ b/crates/ra_hir/src/mock.rs @@ -243,7 +243,7 @@ salsa::database_storage! { fn body_hir() for db::BodyHirQuery; fn body_syntax_mapping() for db::BodySyntaxMappingQuery; fn fn_signature() for db::FnSignatureQuery; - fn generics() for db::GenericsQuery; + fn generic_params() for db::GenericParamsQuery; } } } diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 3608daae4..3170ed24e 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -37,7 +37,7 @@ use crate::{ type_ref::{TypeRef, Mutability}, name::KnownName, expr::{Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, FieldPat}, - generics::Generics, + generics::GenericParams, path::GenericArg, }; @@ -283,7 +283,7 @@ impl Ty { // resolver architecture module: &Module, impl_block: Option<&ImplBlock>, - generics: &Generics, + generics: &GenericParams, type_ref: &TypeRef, ) -> Self { match type_ref { @@ -335,7 +335,7 @@ impl Ty { db: &impl HirDatabase, module: &Module, impl_block: Option<&ImplBlock>, - generics: &Generics, + generics: &GenericParams, type_ref: Option<&TypeRef>, ) -> Self { type_ref.map_or(Ty::Unknown, |t| { @@ -347,7 +347,7 @@ impl Ty { db: &impl HirDatabase, module: &Module, impl_block: Option<&ImplBlock>, - generics: &Generics, + generics: &GenericParams, path: &Path, ) -> Self { if let Some(name) = path.as_ident() { @@ -357,7 +357,7 @@ impl Ty { return Ty::Float(float_ty); } else if name.as_known_name() == Some(KnownName::SelfType) { // TODO pass the impl block's generics? - let generics = &Generics::default(); + let generics = &GenericParams::default(); return Ty::from_hir_opt( db, module, @@ -397,7 +397,7 @@ impl Ty { // the scope of the segment... module: &Module, impl_block: Option<&ImplBlock>, - outer_generics: &Generics, + outer_generics: &GenericParams, path: &Path, resolved: DefId, ) -> Substs { @@ -408,10 +408,10 @@ impl Ty { .last() .expect("path should have at least one segment"); let (def_generics, segment) = match def { - Def::Struct(s) => (s.generics(db), last), - Def::Enum(e) => (e.generics(db), last), - Def::Function(f) => (f.generics(db), last), - Def::Trait(t) => (t.generics(db), last), + Def::Struct(s) => (s.generic_params(db), last), + Def::Enum(e) => (e.generic_params(db), last), + Def::Function(f) => (f.generic_params(db), last), + Def::Trait(t) => (t.generic_params(db), last), Def::EnumVariant(ev) => { // the generic args for an enum variant may be either specified // on the segment referring to the enum, or on the segment @@ -426,7 +426,7 @@ impl Ty { // Option::None:: last }; - (ev.parent_enum(db).generics(db), segment) + (ev.parent_enum(db).generic_params(db), segment) } _ => return Substs::empty(), }; @@ -607,7 +607,7 @@ fn type_for_fn(db: &impl HirDatabase, f: Function) -> Ty { let signature = f.signature(db); let module = f.module(db); let impl_block = f.impl_block(db); - let generics = f.generics(db); + let generics = f.generic_params(db); let input = signature .params() .iter() @@ -624,7 +624,7 @@ fn type_for_fn(db: &impl HirDatabase, f: Function) -> Ty { Ty::FnPtr(Arc::new(sig)) } -fn make_substs(generics: &Generics) -> Substs { +fn make_substs(generics: &GenericParams) -> Substs { Substs( generics .params @@ -636,7 +636,7 @@ fn make_substs(generics: &Generics) -> Substs { } fn type_for_struct(db: &impl HirDatabase, s: Struct) -> Ty { - let generics = s.generics(db); + let generics = s.generic_params(db); Ty::Adt { def_id: s.def_id(), name: s.name(db).unwrap_or_else(Name::missing), @@ -645,7 +645,7 @@ fn type_for_struct(db: &impl HirDatabase, s: Struct) -> Ty { } pub(crate) fn type_for_enum(db: &impl HirDatabase, s: Enum) -> Ty { - let generics = s.generics(db); + let generics = s.generic_params(db); Ty::Adt { def_id: s.def_id(), name: s.name(db).unwrap_or_else(Name::missing), @@ -684,8 +684,8 @@ pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Ty { pub(super) fn type_for_field(db: &impl HirDatabase, def_id: DefId, field: Name) -> Option { let def = def_id.resolve(db); let (variant_data, generics) = match def { - Def::Struct(s) => (s.variant_data(db), s.generics(db)), - Def::EnumVariant(ev) => (ev.variant_data(db), ev.parent_enum(db).generics(db)), + Def::Struct(s) => (s.variant_data(db), s.generic_params(db)), + Def::EnumVariant(ev) => (ev.variant_data(db), ev.parent_enum(db).generic_params(db)), // TODO: unions _ => panic!( "trying to get type for field in non-struct/variant {:?}", @@ -880,7 +880,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { fn make_ty(&mut self, type_ref: &TypeRef) -> Ty { // TODO provide generics of function - let generics = Generics::default(); + let generics = GenericParams::default(); let ty = Ty::from_hir( self.db, &self.module, @@ -1075,7 +1075,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { }; // TODO remove the duplication between here and `Ty::from_path`? // TODO provide generics of function - let generics = Generics::default(); + let generics = GenericParams::default(); let substs = Ty::substs_from_path( self.db, &self.module, diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 53b6d15a8..9f65c5fe1 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs @@ -11,7 +11,7 @@ use ra_db::SourceRootId; use crate::{ HirDatabase, DefId, module_tree::ModuleId, Module, Crate, Name, Function, impl_block::{ImplId, ImplBlock, ImplItem}, - generics::Generics + generics::GenericParams }; use super::Ty; @@ -69,7 +69,7 @@ impl CrateImplBlocks { // ignore for now } else { // TODO provide generics of impl - let generics = Generics::default(); + let generics = GenericParams::default(); let target_ty = Ty::from_hir( db, &module, diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index d53919973..a1b666899 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs @@ -129,7 +129,7 @@ salsa::database_storage! { fn body_hir() for hir::db::BodyHirQuery; fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; fn fn_signature() for hir::db::FnSignatureQuery; - fn generics() for hir::db::GenericsQuery; + fn generic_params() for hir::db::GenericParamsQuery; } } } -- cgit v1.2.3