mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
This commit is contained in:
commit
e847822cec
9 changed files with 33 additions and 22 deletions
|
@ -23,7 +23,7 @@ use crate::{
|
|||
adt::VariantDef,
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
expr::{validation::ExprValidator, BindingAnnotation, Body, BodySourceMap, Pat, PatId},
|
||||
generics::HasGenericParams,
|
||||
generics::{GenericDef, HasGenericParams},
|
||||
ids::{
|
||||
AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
|
||||
TypeAliasId,
|
||||
|
@ -1121,3 +1121,9 @@ impl Local {
|
|||
src.map(|ast| ast.map(|it| it.cast().unwrap().to_node(&root), |it| it.to_node(&root)))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct GenericParam {
|
||||
pub(crate) parent: GenericDef,
|
||||
pub(crate) idx: u32,
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ mod ty;
|
|||
mod impl_block;
|
||||
mod expr;
|
||||
mod lang_item;
|
||||
mod generics;
|
||||
pub mod generics;
|
||||
mod resolve;
|
||||
pub mod diagnostics;
|
||||
mod util;
|
||||
|
@ -65,12 +65,12 @@ pub use crate::{
|
|||
docs::{DocDef, Docs, Documentation},
|
||||
src::{HasBodySource, HasSource},
|
||||
Adt, AssocItem, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
|
||||
EnumVariant, FieldSource, FnData, Function, HasBody, Local, MacroDef, Module, ModuleDef,
|
||||
ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
EnumVariant, FieldSource, FnData, Function, GenericParam, HasBody, Local, MacroDef, Module,
|
||||
ModuleDef, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
},
|
||||
expr::ExprScopes,
|
||||
from_source::FromSource,
|
||||
generics::{GenericDef, GenericParam, GenericParams, HasGenericParams},
|
||||
generics::GenericDef,
|
||||
ids::{HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile},
|
||||
impl_block::ImplBlock,
|
||||
resolve::ScopeDef,
|
||||
|
|
|
@ -28,8 +28,8 @@ use crate::{
|
|||
ids::LocationCtx,
|
||||
resolve::{ScopeDef, TypeNs, ValueNs},
|
||||
ty::method_resolution::{self, implements_trait},
|
||||
AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, HasBody, HirFileId, Local,
|
||||
MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty,
|
||||
AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, GenericParam, HasBody,
|
||||
HirFileId, Local, MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty,
|
||||
};
|
||||
|
||||
fn try_get_resolver_for_node(
|
||||
|
@ -107,7 +107,7 @@ pub enum PathResolution {
|
|||
/// A local binding (only value namespace)
|
||||
Local(Local),
|
||||
/// A generic parameter
|
||||
GenericParam(u32),
|
||||
GenericParam(GenericParam),
|
||||
SelfType(crate::ImplBlock),
|
||||
Macro(MacroDef),
|
||||
AssocItem(crate::AssocItem),
|
||||
|
@ -227,7 +227,10 @@ impl SourceAnalyzer {
|
|||
) -> Option<PathResolution> {
|
||||
let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty {
|
||||
TypeNs::SelfType(it) => PathResolution::SelfType(it),
|
||||
TypeNs::GenericParam(it) => PathResolution::GenericParam(it),
|
||||
TypeNs::GenericParam(idx) => PathResolution::GenericParam(GenericParam {
|
||||
parent: self.resolver.generic_def().unwrap(),
|
||||
idx,
|
||||
}),
|
||||
TypeNs::AdtSelfType(it) | TypeNs::Adt(it) => PathResolution::Def(it.into()),
|
||||
TypeNs::EnumVariant(it) => PathResolution::Def(it.into()),
|
||||
TypeNs::TypeAlias(it) => PathResolution::Def(it.into()),
|
||||
|
|
|
@ -17,8 +17,11 @@ use std::sync::Arc;
|
|||
use std::{fmt, iter, mem};
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, DefWithBody, GenericParams,
|
||||
HasGenericParams, Mutability, Name, Trait, TypeAlias,
|
||||
db::HirDatabase,
|
||||
expr::ExprId,
|
||||
generics::{GenericParams, HasGenericParams},
|
||||
util::make_mut_slice,
|
||||
Adt, Crate, DefWithBody, Mutability, Name, Trait, TypeAlias,
|
||||
};
|
||||
use display::{HirDisplay, HirFormatter};
|
||||
|
||||
|
@ -342,10 +345,7 @@ impl Substs {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn build_for_def(
|
||||
db: &impl HirDatabase,
|
||||
def: impl crate::HasGenericParams,
|
||||
) -> SubstsBuilder {
|
||||
pub fn build_for_def(db: &impl HirDatabase, def: impl HasGenericParams) -> SubstsBuilder {
|
||||
let params = def.generic_params(db);
|
||||
let param_count = params.count_params_including_parent();
|
||||
Substs::builder(param_count)
|
||||
|
|
|
@ -9,7 +9,7 @@ use hir_expand::name;
|
|||
use log::{info, warn};
|
||||
|
||||
use super::{traits::Solution, Canonical, Substs, Ty, TypeWalk};
|
||||
use crate::{db::HirDatabase, HasGenericParams, Resolver};
|
||||
use crate::{db::HirDatabase, generics::HasGenericParams, Resolver};
|
||||
|
||||
const AUTODEREF_RECURSION_LIMIT: usize = 10;
|
||||
|
||||
|
|
|
@ -5,9 +5,10 @@ use hir_def::path::PathSegment;
|
|||
use super::{ExprOrPatId, InferenceContext, TraitRef};
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
generics::HasGenericParams,
|
||||
resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs},
|
||||
ty::{method_resolution, Namespace, Substs, Ty, TypableDef, TypeWalk},
|
||||
AssocItem, Container, HasGenericParams, Name, Path,
|
||||
AssocItem, Container, Name, Path,
|
||||
};
|
||||
|
||||
impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||
|
|
|
@ -16,13 +16,13 @@ use ra_db::salsa::{InternId, InternKey};
|
|||
use super::{Canonical, ChalkContext, Impl, Obligation};
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
generics::GenericDef,
|
||||
generics::{GenericDef, HasGenericParams},
|
||||
ty::display::HirDisplay,
|
||||
ty::{
|
||||
ApplicationTy, GenericPredicate, Namespace, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
|
||||
TypeWalk,
|
||||
},
|
||||
AssocItem, Crate, HasGenericParams, ImplBlock, Trait, TypeAlias,
|
||||
AssocItem, Crate, ImplBlock, Trait, TypeAlias,
|
||||
};
|
||||
|
||||
/// This represents a trait whose name we could not resolve.
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
//! Note that the reference search is possible for not all of the classified items.
|
||||
|
||||
use hir::{
|
||||
Adt, AssocItem, HasSource, Local, MacroDef, Module, ModuleDef, StructField, Ty, VariantDef,
|
||||
Adt, AssocItem, GenericParam, HasSource, Local, MacroDef, Module, ModuleDef, StructField, Ty,
|
||||
VariantDef,
|
||||
};
|
||||
use ra_syntax::{ast, ast::VisibilityOwner};
|
||||
|
||||
|
@ -18,7 +19,7 @@ pub enum NameKind {
|
|||
Def(ModuleDef),
|
||||
SelfType(Ty),
|
||||
Local(Local),
|
||||
GenericParam(u32),
|
||||
GenericParam(GenericParam),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
|
|
|
@ -179,7 +179,7 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
|
|||
|
||||
Cmd { unix: r"npm ci", windows: r"cmd.exe /c npm.cmd ci", work_dir: "./editors/code" }.run()?;
|
||||
Cmd {
|
||||
unix: r"npm run package",
|
||||
unix: r"npm run package --scripts-prepend-node-path",
|
||||
windows: r"cmd.exe /c npm.cmd run package",
|
||||
work_dir: "./editors/code",
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue