From 6911bc89a784ce72b4dfd8e0ba72bd22ce898395 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 13 Dec 2019 22:01:06 +0100 Subject: Rename N! to name! --- crates/ra_hir/src/code_model.rs | 4 +-- crates/ra_hir_def/src/body/lower.rs | 4 +-- crates/ra_hir_def/src/builtin_type.rs | 42 +++++++++++++++--------------- crates/ra_hir_def/src/data.rs | 4 +-- crates/ra_hir_def/src/generics.rs | 6 ++--- crates/ra_hir_def/src/nameres/collector.rs | 4 +-- crates/ra_hir_def/src/path.rs | 8 +++--- crates/ra_hir_def/src/resolver.rs | 16 ++++++------ crates/ra_hir_expand/src/builtin_derive.rs | 2 +- crates/ra_hir_expand/src/builtin_macro.rs | 2 +- crates/ra_hir_expand/src/name.rs | 4 +-- crates/ra_hir_ty/src/autoderef.rs | 4 +-- crates/ra_hir_ty/src/infer.rs | 12 ++++----- crates/ra_hir_ty/src/infer/expr.rs | 4 +-- crates/ra_hir_ty/src/traits/builtin.rs | 6 ++--- crates/ra_hir_ty/src/utils.rs | 4 +-- 16 files changed, 63 insertions(+), 63 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index d1153fa62..7850ea9a7 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -17,7 +17,7 @@ use hir_def::{ }; use hir_expand::{ diagnostics::DiagnosticSink, - name::{AsName, N}, + name::{name, AsName}, MacroDefId, }; use hir_ty::{ @@ -723,7 +723,7 @@ impl Local { } pub fn is_self(self, db: &impl HirDatabase) -> bool { - self.name(db) == Some(N![self]) + self.name(db) == Some(name![self]) } pub fn is_mut(self, db: &impl HirDatabase) -> bool { diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 6c760166f..61193b4d8 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -2,7 +2,7 @@ //! representation. use either::Either; -use hir_expand::name::{AsName, Name, N}; +use hir_expand::name::{name, AsName, Name}; use ra_arena::Arena; use ra_syntax::{ ast::{ @@ -68,7 +68,7 @@ where let ptr = AstPtr::new(&self_param); let param_pat = self.alloc_pat( Pat::Bind { - name: N![self], + name: name![self], mode: BindingAnnotation::Unannotated, subpat: None, }, diff --git a/crates/ra_hir_def/src/builtin_type.rs b/crates/ra_hir_def/src/builtin_type.rs index 757123f82..d14901a9b 100644 --- a/crates/ra_hir_def/src/builtin_type.rs +++ b/crates/ra_hir_def/src/builtin_type.rs @@ -5,7 +5,7 @@ use std::fmt; -use hir_expand::name::{Name, N}; +use hir_expand::name::{name, Name}; #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Signedness { @@ -52,26 +52,26 @@ pub enum BuiltinType { impl BuiltinType { #[rustfmt::skip] pub const ALL: &'static [(Name, BuiltinType)] = &[ - (N![char], BuiltinType::Char), - (N![bool], BuiltinType::Bool), - (N![str], BuiltinType::Str), - - (N![isize], BuiltinType::Int(BuiltinInt::ISIZE)), - (N![i8], BuiltinType::Int(BuiltinInt::I8)), - (N![i16], BuiltinType::Int(BuiltinInt::I16)), - (N![i32], BuiltinType::Int(BuiltinInt::I32)), - (N![i64], BuiltinType::Int(BuiltinInt::I64)), - (N![i128], BuiltinType::Int(BuiltinInt::I128)), - - (N![usize], BuiltinType::Int(BuiltinInt::USIZE)), - (N![u8], BuiltinType::Int(BuiltinInt::U8)), - (N![u16], BuiltinType::Int(BuiltinInt::U16)), - (N![u32], BuiltinType::Int(BuiltinInt::U32)), - (N![u64], BuiltinType::Int(BuiltinInt::U64)), - (N![u128], BuiltinType::Int(BuiltinInt::U128)), - - (N![f32], BuiltinType::Float(BuiltinFloat::F32)), - (N![f64], BuiltinType::Float(BuiltinFloat::F64)), + (name![char], BuiltinType::Char), + (name![bool], BuiltinType::Bool), + (name![str], BuiltinType::Str), + + (name![isize], BuiltinType::Int(BuiltinInt::ISIZE)), + (name![i8], BuiltinType::Int(BuiltinInt::I8)), + (name![i16], BuiltinType::Int(BuiltinInt::I16)), + (name![i32], BuiltinType::Int(BuiltinInt::I32)), + (name![i64], BuiltinType::Int(BuiltinInt::I64)), + (name![i128], BuiltinType::Int(BuiltinInt::I128)), + + (name![usize], BuiltinType::Int(BuiltinInt::USIZE)), + (name![u8], BuiltinType::Int(BuiltinInt::U8)), + (name![u16], BuiltinType::Int(BuiltinInt::U16)), + (name![u32], BuiltinType::Int(BuiltinInt::U32)), + (name![u64], BuiltinType::Int(BuiltinInt::U64)), + (name![u128], BuiltinType::Int(BuiltinInt::U128)), + + (name![f32], BuiltinType::Float(BuiltinFloat::F32)), + (name![f64], BuiltinType::Float(BuiltinFloat::F64)), ]; } diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index afeac0ec2..4f4ef57cc 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use hir_expand::{ - name::{AsName, Name, N}, + name::{name, AsName, Name}, AstId, }; use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; @@ -37,7 +37,7 @@ impl FunctionData { let self_type = if let Some(type_ref) = self_param.ascribed_type() { TypeRef::from_ast(type_ref) } else { - let self_type = TypeRef::Path(N![Self].into()); + let self_type = TypeRef::Path(name![Self].into()); match self_param.kind() { ast::SelfParamKind::Owned => self_type, ast::SelfParamKind::Ref => { diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 2b13748f3..e9c28c730 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use either::Either; use hir_expand::{ - name::{AsName, Name, N}, + name::{name, AsName, Name}, InFile, }; use ra_arena::{map::ArenaMap, Arena}; @@ -90,11 +90,11 @@ impl GenericParams { // traits get the Self type as an implicit first type parameter let self_param_id = - generics.types.alloc(TypeParamData { name: N![Self], default: None }); + generics.types.alloc(TypeParamData { name: name![Self], default: None }); sm.insert(self_param_id, Either::Left(src.value.clone())); // add super traits as bounds on Self // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar - let self_param = TypeRef::Path(N![Self].into()); + let self_param = TypeRef::Path(name![Self].into()); generics.fill_bounds(&src.value, self_param); generics.fill(&mut sm, &src.value); diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index e81bac914..5d7469a6e 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -6,7 +6,7 @@ use hir_expand::{ builtin_derive::find_builtin_derive, builtin_macro::find_builtin_macro, - name::{AsName, Name, N}, + name::{name, AsName, Name}, HirFileId, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; use ra_cfg::CfgOptions; @@ -918,7 +918,7 @@ where } fn is_macro_rules(path: &Path) -> bool { - path.as_ident() == Some(&N![macro_rules]) + path.as_ident() == Some(&name![macro_rules]) } #[cfg(test)] diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 36ad27867..c1376af36 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -6,7 +6,7 @@ use std::{iter, sync::Arc}; use either::Either; use hir_expand::{ hygiene::Hygiene, - name::{AsName, Name, N}, + name::{name, AsName, Name}, }; use ra_db::CrateId; use ra_syntax::{ @@ -276,7 +276,7 @@ impl GenericArgs { } if let Some(ret_type) = ret_type { let type_ref = TypeRef::from_ast_opt(ret_type.type_ref()); - bindings.push((N![Output], type_ref)) + bindings.push((name![Output], type_ref)) } if args.is_empty() && bindings.is_empty() { None @@ -297,12 +297,12 @@ impl From for Path { } pub mod known { - use hir_expand::name::N; + use hir_expand::name::name; use super::{Path, PathKind}; macro_rules! P { - ($start:ident $(:: $seg:ident)*) => { Path::from_simple_segments(PathKind::Abs, vec![N![$start], $(N![$seg],)*]) }; + ($start:ident $(:: $seg:ident)*) => { Path::from_simple_segments(PathKind::Abs, vec![name![$start], $(name![$seg],)*]) }; } pub fn std_iter_into_iterator() -> Path { diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 0fb529527..b6d595a20 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use hir_expand::{ - name::{Name, N}, + name::{name, Name}, MacroDefId, }; use ra_db::CrateId; @@ -163,13 +163,13 @@ impl Resolver { } } Scope::ImplBlockScope(impl_) => { - if first_name == &N![Self] { + if first_name == &name![Self] { let idx = if path.segments.len() == 1 { None } else { Some(1) }; return Some((TypeNs::SelfType(*impl_), idx)); } } Scope::AdtScope(adt) => { - if first_name == &N![Self] { + if first_name == &name![Self] { let idx = if path.segments.len() == 1 { None } else { Some(1) }; return Some((TypeNs::AdtSelfType(*adt), idx)); } @@ -223,7 +223,7 @@ impl Resolver { return None; } let n_segments = path.segments.len(); - let tmp = N![self]; + let tmp = name![self]; let first_name = if path.is_self() { &tmp } else { &path.segments.first()?.name }; let skip_to_mod = path.kind != PathKind::Plain && !path.is_self(); for scope in self.scopes.iter().rev() { @@ -259,13 +259,13 @@ impl Resolver { Scope::GenericParams { .. } => continue, Scope::ImplBlockScope(impl_) if n_segments > 1 => { - if first_name == &N![Self] { + if first_name == &name![Self] { let ty = TypeNs::SelfType(*impl_); return Some(ResolveValueResult::Partial(ty, 1)); } } Scope::AdtScope(adt) if n_segments > 1 => { - if first_name == &N![Self] { + if first_name == &name![Self] { let ty = TypeNs::AdtSelfType(*adt); return Some(ResolveValueResult::Partial(ty, 1)); } @@ -439,10 +439,10 @@ impl Scope { } } Scope::ImplBlockScope(i) => { - f(N![Self], ScopeDef::ImplSelfType((*i).into())); + f(name![Self], ScopeDef::ImplSelfType((*i).into())); } Scope::AdtScope(i) => { - f(N![Self], ScopeDef::AdtSelfType((*i).into())); + f(name![Self], ScopeDef::AdtSelfType((*i).into())); } Scope::ExprScope(scope) => { scope.expr_scopes.entries(scope.scope_id).iter().for_each(|e| { diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index d7f8ada78..b26441253 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -34,7 +34,7 @@ macro_rules! register_builtin { pub fn find_builtin_derive(ident: &name::Name) -> Option { let kind = match ident { - $( id if id == &name::N![$trait] => BuiltinDeriveExpander::$trait, )* + $( id if id == &name::name![$trait] => BuiltinDeriveExpander::$trait, )* _ => return None, }; diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index e5046ad4c..d2b3d769e 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs @@ -34,7 +34,7 @@ macro_rules! register_builtin { ast_id: AstId, ) -> Option { let kind = match ident { - $( id if id == &name::N![$name] => BuiltinFnLikeExpander::$kind, )* + $( id if id == &name::name![$name] => BuiltinFnLikeExpander::$kind, )* _ => return None, }; diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs index 8b3141d75..59d8214fd 100644 --- a/crates/ra_hir_expand/src/name.rs +++ b/crates/ra_hir_expand/src/name.rs @@ -186,7 +186,7 @@ pub mod known { pub const SELF_TYPE: super::Name = super::Name::new_inline_ascii(b"Self"); #[macro_export] - macro_rules! N { + macro_rules! name { (self) => { $crate::name::known::SELF_PARAM }; @@ -199,4 +199,4 @@ pub mod known { } } -pub use crate::N; +pub use crate::name; diff --git a/crates/ra_hir_ty/src/autoderef.rs b/crates/ra_hir_ty/src/autoderef.rs index 04822d56e..ee48fa537 100644 --- a/crates/ra_hir_ty/src/autoderef.rs +++ b/crates/ra_hir_ty/src/autoderef.rs @@ -6,7 +6,7 @@ use std::iter::successors; use hir_def::lang_item::LangItemTarget; -use hir_expand::name::N; +use hir_expand::name::name; use log::{info, warn}; use ra_db::CrateId; @@ -52,7 +52,7 @@ fn deref_by_trait( LangItemTarget::TraitId(it) => it, _ => return None, }; - let target = db.trait_data(deref_trait).associated_type_by_name(&N![Target])?; + let target = db.trait_data(deref_trait).associated_type_by_name(&name![Target])?; let generic_params = generics(db, target.into()); if generic_params.len() != 1 { diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index bb366bb8b..edf4e69ba 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -29,7 +29,7 @@ use hir_def::{ type_ref::{Mutability, TypeRef}, AdtId, AssocItemId, DefWithBodyId, FunctionId, StructFieldId, TypeAliasId, VariantId, }; -use hir_expand::{diagnostics::DiagnosticSink, name::N}; +use hir_expand::{diagnostics::DiagnosticSink, name::name}; use ra_arena::map::ArenaMap; use ra_prof::profile; @@ -424,31 +424,31 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { fn resolve_into_iter_item(&self) -> Option { let path = known::std_iter_into_iterator(); let trait_ = self.resolver.resolve_known_trait(self.db, &path)?; - self.db.trait_data(trait_).associated_type_by_name(&N![Item]) + self.db.trait_data(trait_).associated_type_by_name(&name![Item]) } fn resolve_ops_try_ok(&self) -> Option { let path = known::std_ops_try(); let trait_ = self.resolver.resolve_known_trait(self.db, &path)?; - self.db.trait_data(trait_).associated_type_by_name(&N![Ok]) + self.db.trait_data(trait_).associated_type_by_name(&name![Ok]) } fn resolve_ops_neg_output(&self) -> Option { let path = known::std_ops_neg(); let trait_ = self.resolver.resolve_known_trait(self.db, &path)?; - self.db.trait_data(trait_).associated_type_by_name(&N![Output]) + self.db.trait_data(trait_).associated_type_by_name(&name![Output]) } fn resolve_ops_not_output(&self) -> Option { let path = known::std_ops_not(); let trait_ = self.resolver.resolve_known_trait(self.db, &path)?; - self.db.trait_data(trait_).associated_type_by_name(&N![Output]) + self.db.trait_data(trait_).associated_type_by_name(&name![Output]) } fn resolve_future_future_output(&self) -> Option { let path = known::std_future_future(); let trait_ = self.resolver.resolve_known_trait(self.db, &path)?; - self.db.trait_data(trait_).associated_type_by_name(&N![Output]) + self.db.trait_data(trait_).associated_type_by_name(&name![Output]) } fn resolve_boxed_box(&self) -> Option { diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index a6f5c6ec3..2e3cdd53a 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs @@ -10,7 +10,7 @@ use hir_def::{ resolver::resolver_for_expr, AdtId, ContainerId, Lookup, StructFieldId, }; -use hir_expand::name::{Name, N}; +use hir_expand::name::{name, Name}; use ra_syntax::ast::RangeOp; use crate::{ @@ -631,7 +631,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { // Parent arguments are unknown, except for the receiver type if let Some(parent_generics) = def_generics.as_ref().map(|p| p.iter_parent()) { for (_id, param) in parent_generics { - if param.name == N![Self] { + if param.name == name![Self] { substs.push(receiver_ty.clone()); } else { substs.push(Ty::Unknown); diff --git a/crates/ra_hir_ty/src/traits/builtin.rs b/crates/ra_hir_ty/src/traits/builtin.rs index 27c475a3c..cd587a338 100644 --- a/crates/ra_hir_ty/src/traits/builtin.rs +++ b/crates/ra_hir_ty/src/traits/builtin.rs @@ -1,7 +1,7 @@ //! This module provides the built-in trait implementations, e.g. to make //! closures implement `Fn`. use hir_def::{expr::Expr, lang_item::LangItemTarget, TraitId, TypeAliasId}; -use hir_expand::name::N; +use hir_expand::name::name; use ra_db::CrateId; use super::{AssocTyValue, Impl}; @@ -79,7 +79,7 @@ fn closure_fn_trait_impl_datum( // and don't want to return a valid value only to find out later that FnOnce // is broken let fn_once_trait = get_fn_trait(db, krate, super::FnTrait::FnOnce)?; - let _output = db.trait_data(fn_once_trait).associated_type_by_name(&N![Output])?; + let _output = db.trait_data(fn_once_trait).associated_type_by_name(&name![Output])?; let num_args: u16 = match &db.body(data.def.into())[data.expr] { Expr::Lambda { args, .. } => args.len() as u16, @@ -137,7 +137,7 @@ fn closure_fn_trait_output_assoc_ty_value( let output_ty_id = db .trait_data(fn_once_trait) - .associated_type_by_name(&N![Output]) + .associated_type_by_name(&name![Output]) .expect("assoc ty value should not exist"); BuiltinImplAssocTyValueData { diff --git a/crates/ra_hir_ty/src/utils.rs b/crates/ra_hir_ty/src/utils.rs index fabf45b53..0049d3c6f 100644 --- a/crates/ra_hir_ty/src/utils.rs +++ b/crates/ra_hir_ty/src/utils.rs @@ -10,7 +10,7 @@ use hir_def::{ type_ref::TypeRef, ContainerId, GenericDefId, Lookup, TraitId, TypeAliasId, TypeParamId, VariantId, }; -use hir_expand::name::{Name, N}; +use hir_expand::name::{name, Name}; fn direct_super_traits(db: &impl DefDatabase, trait_: TraitId) -> Vec { let resolver = trait_.resolver(db); @@ -22,7 +22,7 @@ fn direct_super_traits(db: &impl DefDatabase, trait_: TraitId) -> Vec { .where_predicates .iter() .filter_map(|pred| match &pred.type_ref { - TypeRef::Path(p) if p.as_ident() == Some(&N![Self]) => pred.bound.as_path(), + TypeRef::Path(p) if p.as_ident() == Some(&name![Self]) => pred.bound.as_path(), _ => None, }) .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path) { -- cgit v1.2.3