mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Rename N! to name!
This commit is contained in:
parent
259c42f00e
commit
6911bc89a7
16 changed files with 60 additions and 60 deletions
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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),
|
||||
(name![char], BuiltinType::Char),
|
||||
(name![bool], BuiltinType::Bool),
|
||||
(name![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)),
|
||||
(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)),
|
||||
|
||||
(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)),
|
||||
(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)),
|
||||
|
||||
(N![f32], BuiltinType::Float(BuiltinFloat::F32)),
|
||||
(N![f64], BuiltinType::Float(BuiltinFloat::F64)),
|
||||
(name![f32], BuiltinType::Float(BuiltinFloat::F32)),
|
||||
(name![f64], BuiltinType::Float(BuiltinFloat::F64)),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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<Name> 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 {
|
||||
|
|
|
@ -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| {
|
||||
|
|
|
@ -34,7 +34,7 @@ macro_rules! register_builtin {
|
|||
|
||||
pub fn find_builtin_derive(ident: &name::Name) -> Option<MacroDefId> {
|
||||
let kind = match ident {
|
||||
$( id if id == &name::N![$trait] => BuiltinDeriveExpander::$trait, )*
|
||||
$( id if id == &name::name![$trait] => BuiltinDeriveExpander::$trait, )*
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ macro_rules! register_builtin {
|
|||
ast_id: AstId<ast::MacroCall>,
|
||||
) -> Option<MacroDefId> {
|
||||
let kind = match ident {
|
||||
$( id if id == &name::N![$name] => BuiltinFnLikeExpander::$kind, )*
|
||||
$( id if id == &name::name![$name] => BuiltinFnLikeExpander::$kind, )*
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<TypeAliasId> {
|
||||
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<TypeAliasId> {
|
||||
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<TypeAliasId> {
|
||||
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<TypeAliasId> {
|
||||
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<TypeAliasId> {
|
||||
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<AdtId> {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<TraitId> {
|
||||
let resolver = trait_.resolver(db);
|
||||
|
@ -22,7 +22,7 @@ fn direct_super_traits(db: &impl DefDatabase, trait_: TraitId) -> Vec<TraitId> {
|
|||
.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) {
|
||||
|
|
Loading…
Reference in a new issue