mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
cargo fmt
This commit is contained in:
parent
87f837cec7
commit
7535bb4661
571 changed files with 2210 additions and 2458 deletions
|
|
@ -3,12 +3,12 @@
|
|||
use std::ops::ControlFlow;
|
||||
|
||||
use hir_def::{
|
||||
AssocItemId, AttrDefId, ModuleDefId,
|
||||
attr::AttrsWithOwner,
|
||||
item_scope::ItemInNs,
|
||||
path::{ModPath, Path},
|
||||
per_ns::Namespace,
|
||||
resolver::{HasResolver, Resolver, TypeNs},
|
||||
AssocItemId, AttrDefId, ModuleDefId,
|
||||
};
|
||||
use hir_expand::{mod_path::PathKind, name::Name};
|
||||
use hir_ty::{db::HirDatabase, method_resolution};
|
||||
|
|
@ -273,11 +273,7 @@ fn resolve_impl_trait_item(
|
|||
// disambiguation) so we just pick the first one we find as well.
|
||||
result = as_module_def_if_namespace_matches(assoc_item_id.into(), ns);
|
||||
|
||||
if result.is_some() {
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
if result.is_some() { ControlFlow::Break(()) } else { ControlFlow::Continue(()) }
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,22 +6,23 @@
|
|||
use cfg::{CfgExpr, CfgOptions};
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
DefWithBodyId, SyntheticSyntax,
|
||||
expr_store::ExprOrPatPtr,
|
||||
hir::ExprOrPatId,
|
||||
path::{hir_segment_to_ast_segment, ModPath},
|
||||
path::{ModPath, hir_segment_to_ast_segment},
|
||||
type_ref::TypesSourceMap,
|
||||
DefWithBodyId, SyntheticSyntax,
|
||||
};
|
||||
use hir_expand::{name::Name, HirFileId, InFile};
|
||||
use hir_expand::{HirFileId, InFile, name::Name};
|
||||
use hir_ty::{
|
||||
db::HirDatabase,
|
||||
diagnostics::{BodyValidationDiagnostic, UnsafetyReason},
|
||||
CastError, InferenceDiagnostic, InferenceTyDiagnosticSource, PathLoweringDiagnostic,
|
||||
TyLoweringDiagnostic, TyLoweringDiagnosticKind,
|
||||
db::HirDatabase,
|
||||
diagnostics::{BodyValidationDiagnostic, UnsafetyReason},
|
||||
};
|
||||
use syntax::{
|
||||
AstNode, AstPtr, SyntaxError, SyntaxNodePtr, TextRange,
|
||||
ast::{self, HasGenericArgs},
|
||||
match_ast, AstNode, AstPtr, SyntaxError, SyntaxNodePtr, TextRange,
|
||||
match_ast,
|
||||
};
|
||||
use triomphe::Arc;
|
||||
|
||||
|
|
@ -29,8 +30,8 @@ use crate::{AssocItem, Field, Function, Local, Trait, Type};
|
|||
|
||||
pub use hir_def::VariantId;
|
||||
pub use hir_ty::{
|
||||
diagnostics::{CaseType, IncorrectCase},
|
||||
GenericArgsProhibitedReason,
|
||||
diagnostics::{CaseType, IncorrectCase},
|
||||
};
|
||||
|
||||
macro_rules! diagnostics {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
//! HirDisplay implementations for various hir types.
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
AdtId, GenericDefId,
|
||||
data::{
|
||||
adt::{StructKind, VariantData},
|
||||
TraitFlags,
|
||||
adt::{StructKind, VariantData},
|
||||
},
|
||||
generics::{
|
||||
GenericParams, TypeOrConstParamData, TypeParamProvenance, WherePredicate,
|
||||
|
|
@ -11,14 +12,13 @@ use hir_def::{
|
|||
},
|
||||
lang_item::LangItem,
|
||||
type_ref::{TypeBound, TypeRef},
|
||||
AdtId, GenericDefId,
|
||||
};
|
||||
use hir_ty::{
|
||||
display::{
|
||||
hir_display_with_types_map, write_bounds_like_dyn_trait_with_prefix, write_visibility,
|
||||
HirDisplay, HirDisplayError, HirDisplayWithTypesMap, HirFormatter, SizedByDefault,
|
||||
},
|
||||
AliasEq, AliasTy, Interner, ProjectionTyExt, TraitRefExt, TyKind, WhereClause,
|
||||
display::{
|
||||
HirDisplay, HirDisplayError, HirDisplayWithTypesMap, HirFormatter, SizedByDefault,
|
||||
hir_display_with_types_map, write_bounds_like_dyn_trait_with_prefix, write_visibility,
|
||||
},
|
||||
};
|
||||
use itertools::Itertools;
|
||||
|
||||
|
|
@ -854,7 +854,7 @@ impl HirDisplay for Module {
|
|||
return match self.krate(f.db).display_name(f.db) {
|
||||
Some(name) => write!(f, "extern crate {name}"),
|
||||
None => f.write_str("extern crate {unknown}"),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
match self.name(f.db) {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
//! are splitting the hir.
|
||||
|
||||
use hir_def::{
|
||||
hir::{BindingId, LabelId},
|
||||
AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, GenericDefId, GenericParamId,
|
||||
ModuleDefId, VariantId,
|
||||
hir::{BindingId, LabelId},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
CallableDefId, Lookup, MacroId, VariantId,
|
||||
nameres::{ModuleOrigin, ModuleSource},
|
||||
src::{HasChildSource, HasSource as _},
|
||||
CallableDefId, Lookup, MacroId, VariantId,
|
||||
};
|
||||
use hir_expand::{HirFileId, InFile};
|
||||
use hir_ty::db::InternedClosure;
|
||||
|
|
@ -13,9 +13,10 @@ use syntax::ast;
|
|||
use tt::TextRange;
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase, Adt, Callee, Const, Enum, ExternCrateDecl, Field, FieldSource, Function, Impl,
|
||||
Adt, Callee, Const, Enum, ExternCrateDecl, Field, FieldSource, Function, Impl,
|
||||
InlineAsmOperand, Label, LifetimeParam, LocalSource, Macro, Module, Param, SelfParam, Static,
|
||||
Struct, Trait, TraitAlias, TypeAlias, TypeOrConstParam, Union, Variant, VariantDef,
|
||||
db::HirDatabase,
|
||||
};
|
||||
|
||||
pub trait HasSource {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,12 @@ use arrayvec::ArrayVec;
|
|||
use base_db::{CrateDisplayName, CrateOrigin, LangCrateOrigin};
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
data::{adt::VariantData, TraitFlags},
|
||||
AdtId, AssocItemId, AssocItemLoc, AttrDefId, CallableDefId, ConstId, ConstParamId,
|
||||
CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId,
|
||||
FunctionId, GenericDefId, GenericParamId, HasModule, ImplId, InTypeConstId, ItemContainerId,
|
||||
LifetimeParamId, LocalFieldId, Lookup, MacroExpander, MacroId, ModuleId, StaticId, StructId,
|
||||
SyntheticSyntax, TraitAliasId, TupleId, TypeAliasId, TypeOrConstParamId, TypeParamId, UnionId,
|
||||
data::{TraitFlags, adt::VariantData},
|
||||
expr_store::ExpressionStoreDiagnostics,
|
||||
generics::{LifetimeParamData, TypeOrConstParamData, TypeParamProvenance},
|
||||
hir::{BindingAnnotation, BindingId, Expr, ExprId, ExprOrPatId, LabelId, Pat},
|
||||
|
|
@ -54,30 +59,24 @@ use hir_def::{
|
|||
per_ns::PerNs,
|
||||
resolver::{HasResolver, Resolver},
|
||||
type_ref::TypesSourceMap,
|
||||
AdtId, AssocItemId, AssocItemLoc, AttrDefId, CallableDefId, ConstId, ConstParamId,
|
||||
CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId,
|
||||
FunctionId, GenericDefId, GenericParamId, HasModule, ImplId, InTypeConstId, ItemContainerId,
|
||||
LifetimeParamId, LocalFieldId, Lookup, MacroExpander, MacroId, ModuleId, StaticId, StructId,
|
||||
SyntheticSyntax, TraitAliasId, TupleId, TypeAliasId, TypeOrConstParamId, TypeParamId, UnionId,
|
||||
};
|
||||
use hir_expand::{
|
||||
attrs::collect_attrs, proc_macro::ProcMacroKind, AstId, MacroCallKind, RenderedExpandError,
|
||||
ValueResult,
|
||||
AstId, MacroCallKind, RenderedExpandError, ValueResult, attrs::collect_attrs,
|
||||
proc_macro::ProcMacroKind,
|
||||
};
|
||||
use hir_ty::{
|
||||
all_super_traits, autoderef, check_orphan_rules,
|
||||
consteval::{try_const_usize, unknown_const_as_generic, ConstExt},
|
||||
AliasTy, CallableSig, Canonical, CanonicalVarKinds, Cast, ClosureId, GenericArg,
|
||||
GenericArgData, Interner, ParamKind, QuantifiedWhereClause, Scalar, Substitution,
|
||||
TraitEnvironment, TraitRefExt, Ty, TyBuilder, TyDefId, TyExt, TyKind, TyLoweringDiagnostic,
|
||||
ValueTyDefId, WhereClause, all_super_traits, autoderef, check_orphan_rules,
|
||||
consteval::{ConstExt, try_const_usize, unknown_const_as_generic},
|
||||
diagnostics::BodyValidationDiagnostic,
|
||||
direct_super_traits, error_lifetime, known_const_to_ast,
|
||||
layout::{Layout as TyLayout, RustcEnumVariantIdx, RustcFieldIdx, TagEncoding},
|
||||
method_resolution,
|
||||
mir::{interpret_mir, MutBorrowKind},
|
||||
mir::{MutBorrowKind, interpret_mir},
|
||||
primitive::UintTy,
|
||||
traits::FnTrait,
|
||||
AliasTy, CallableSig, Canonical, CanonicalVarKinds, Cast, ClosureId, GenericArg,
|
||||
GenericArgData, Interner, ParamKind, QuantifiedWhereClause, Scalar, Substitution,
|
||||
TraitEnvironment, TraitRefExt, Ty, TyBuilder, TyDefId, TyExt, TyKind, TyLoweringDiagnostic,
|
||||
ValueTyDefId, WhereClause,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use nameres::diagnostics::DefDiagnosticKind;
|
||||
|
|
@ -86,15 +85,16 @@ use smallvec::SmallVec;
|
|||
use span::{Edition, EditionedFileId, FileId, MacroCallId};
|
||||
use stdx::{format_to, impl_from, never};
|
||||
use syntax::{
|
||||
AstNode, AstPtr, SmolStr, SyntaxNode, SyntaxNodePtr, T, TextRange, ToSmolStr,
|
||||
ast::{self, HasAttrs as _, HasGenericParams, HasName},
|
||||
format_smolstr, AstNode, AstPtr, SmolStr, SyntaxNode, SyntaxNodePtr, TextRange, ToSmolStr, T,
|
||||
format_smolstr,
|
||||
};
|
||||
use triomphe::{Arc, ThinArc};
|
||||
|
||||
use crate::db::{DefDatabase, HirDatabase};
|
||||
|
||||
pub use crate::{
|
||||
attrs::{resolve_doc_path_on, HasAttrs},
|
||||
attrs::{HasAttrs, resolve_doc_path_on},
|
||||
diagnostics::*,
|
||||
has_source::HasSource,
|
||||
semantics::{
|
||||
|
|
@ -114,6 +114,7 @@ pub use crate::{
|
|||
pub use {
|
||||
cfg::{CfgAtom, CfgExpr, CfgOptions},
|
||||
hir_def::{
|
||||
ImportPathConfig,
|
||||
attr::{AttrSourceMap, Attrs, AttrsWithOwner},
|
||||
data::adt::StructKind,
|
||||
find_path::PrefixKind,
|
||||
|
|
@ -124,12 +125,12 @@ pub use {
|
|||
per_ns::Namespace,
|
||||
type_ref::{Mutability, TypeRef},
|
||||
visibility::Visibility,
|
||||
ImportPathConfig,
|
||||
// FIXME: This is here since some queries take it as input that are used
|
||||
// outside of hir.
|
||||
{ModuleDefId, TraitId},
|
||||
},
|
||||
hir_expand::{
|
||||
ExpandResult, HirFileId, HirFileIdExt, MacroFileId, MacroFileIdExt, MacroKind,
|
||||
attrs::{Attr, AttrId},
|
||||
change::ChangeWithProcMacros,
|
||||
files::{
|
||||
|
|
@ -137,15 +138,16 @@ pub use {
|
|||
HirFileRange, InFile, InFileWrapper, InMacroFile, InRealFile, MacroFilePosition,
|
||||
MacroFileRange,
|
||||
},
|
||||
hygiene::{marks_rev, SyntaxContextExt},
|
||||
hygiene::{SyntaxContextExt, marks_rev},
|
||||
inert_attr_macro::AttributeTemplate,
|
||||
mod_path::tool_path,
|
||||
name::Name,
|
||||
prettify_macro_expansion,
|
||||
proc_macro::{ProcMacros, ProcMacrosBuilder},
|
||||
tt, ExpandResult, HirFileId, HirFileIdExt, MacroFileId, MacroFileIdExt, MacroKind,
|
||||
tt,
|
||||
},
|
||||
hir_ty::{
|
||||
CastError, DropGlue, FnAbi, PointerCast, Safety, Variance,
|
||||
consteval::ConstEvalError,
|
||||
diagnostics::UnsafetyReason,
|
||||
display::{ClosureStyle, DisplayTarget, HirDisplay, HirDisplayError, HirWrite},
|
||||
|
|
@ -153,11 +155,10 @@ pub use {
|
|||
layout::LayoutError,
|
||||
method_resolution::TyFingerprint,
|
||||
mir::{MirEvalError, MirLowerError},
|
||||
CastError, DropGlue, FnAbi, PointerCast, Safety, Variance,
|
||||
},
|
||||
// FIXME: Properly encapsulate mir
|
||||
hir_ty::{mir, Interner as ChalkTyInterner},
|
||||
intern::{sym, Symbol},
|
||||
hir_ty::{Interner as ChalkTyInterner, mir},
|
||||
intern::{Symbol, sym},
|
||||
};
|
||||
|
||||
// These are negative re-exports: pub using these names is forbidden, they
|
||||
|
|
@ -587,11 +588,7 @@ impl Module {
|
|||
if let Some(m) = visible_from {
|
||||
let filtered =
|
||||
def.filter_visibility(|vis| vis.is_visible_from(db.upcast(), m.id));
|
||||
if filtered.is_none() && !def.is_none() {
|
||||
None
|
||||
} else {
|
||||
Some((name, filtered))
|
||||
}
|
||||
if filtered.is_none() && !def.is_none() { None } else { Some((name, filtered)) }
|
||||
} else {
|
||||
Some((name, def))
|
||||
}
|
||||
|
|
@ -1759,19 +1756,11 @@ impl Adt {
|
|||
}
|
||||
|
||||
pub fn as_struct(&self) -> Option<Struct> {
|
||||
if let Self::Struct(v) = self {
|
||||
Some(*v)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if let Self::Struct(v) = self { Some(*v) } else { None }
|
||||
}
|
||||
|
||||
pub fn as_enum(&self) -> Option<Enum> {
|
||||
if let Self::Enum(v) = self {
|
||||
Some(*v)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if let Self::Enum(v) = self { Some(*v) } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5080,11 +5069,7 @@ impl Type {
|
|||
let projection = TyBuilder::assoc_type_projection(db, alias.id, Some(parent_subst)).build();
|
||||
|
||||
let ty = db.normalize_projection(projection, self.env.clone());
|
||||
if ty.is_unknown() {
|
||||
None
|
||||
} else {
|
||||
Some(self.derived(ty))
|
||||
}
|
||||
if ty.is_unknown() { None } else { Some(self.derived(ty)) }
|
||||
}
|
||||
|
||||
pub fn is_copy(&self, db: &dyn HirDatabase) -> bool {
|
||||
|
|
@ -5261,7 +5246,10 @@ impl Type {
|
|||
|
||||
/// Returns types that this type dereferences to (including this type itself). The returned
|
||||
/// iterator won't yield the same type more than once even if the deref chain contains a cycle.
|
||||
pub fn autoderef<'db>(&self, db: &'db dyn HirDatabase) -> impl Iterator<Item = Type> + use<'_, 'db> {
|
||||
pub fn autoderef<'db>(
|
||||
&self,
|
||||
db: &'db dyn HirDatabase,
|
||||
) -> impl Iterator<Item = Type> + use<'_, 'db> {
|
||||
self.autoderef_(db).map(move |ty| self.derived(ty))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use std::{
|
|||
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
AsMacroCall, DefWithBodyId, FunctionId, MacroId, StructId, TraitId, VariantId,
|
||||
expr_store::{Body, ExprOrPatSource},
|
||||
hir::{BindingId, Expr, ExprId, ExprOrPatId, Pat},
|
||||
lower::LowerCtx,
|
||||
|
|
@ -19,9 +20,9 @@ use hir_def::{
|
|||
path::ModPath,
|
||||
resolver::{self, HasResolver, Resolver, TypeNs},
|
||||
type_ref::{Mutability, TypesMap, TypesSourceMap},
|
||||
AsMacroCall, DefWithBodyId, FunctionId, MacroId, StructId, TraitId, VariantId,
|
||||
};
|
||||
use hir_expand::{
|
||||
ExpandResult, FileRange, InMacroFile, MacroCallId, MacroFileId, MacroFileIdExt,
|
||||
attrs::collect_attrs,
|
||||
builtin::{BuiltinFnLikeExpander, EagerExpander},
|
||||
db::ExpandDatabase,
|
||||
|
|
@ -29,32 +30,31 @@ use hir_expand::{
|
|||
hygiene::SyntaxContextExt as _,
|
||||
inert_attr_macro::find_builtin_attr_idx,
|
||||
name::AsName,
|
||||
ExpandResult, FileRange, InMacroFile, MacroCallId, MacroFileId, MacroFileIdExt,
|
||||
};
|
||||
use hir_ty::diagnostics::unsafe_operations_for_body;
|
||||
use intern::{sym, Symbol};
|
||||
use intern::{Symbol, sym};
|
||||
use itertools::Itertools;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use span::{AstIdMap, EditionedFileId, FileId, HirFileIdRepr, SyntaxContext};
|
||||
use stdx::TupleExt;
|
||||
use syntax::{
|
||||
algo::skip_trivia_token,
|
||||
ast::{self, HasAttrs as _, HasGenericParams},
|
||||
AstNode, AstToken, Direction, SyntaxKind, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextRange,
|
||||
TextSize,
|
||||
algo::skip_trivia_token,
|
||||
ast::{self, HasAttrs as _, HasGenericParams},
|
||||
};
|
||||
use triomphe::Arc;
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
|
||||
source_analyzer::{name_hygiene, resolve_hir_path, SourceAnalyzer},
|
||||
Adjust, Adjustment, Adt, AutoBorrow, BindingMode, BuiltinAttr, Callable, Const, ConstParam,
|
||||
Crate, DefWithBody, DeriveHelper, Enum, Field, Function, GenericSubstitution, HasSource,
|
||||
HirFileId, Impl, InFile, InlineAsmOperand, ItemInNs, Label, LifetimeParam, Local, Macro,
|
||||
Module, ModuleDef, Name, OverloadedDeref, Path, ScopeDef, Static, Struct, ToolModule, Trait,
|
||||
TraitAlias, TupleField, Type, TypeAlias, TypeParam, Union, Variant, VariantDef,
|
||||
db::HirDatabase,
|
||||
semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
|
||||
source_analyzer::{SourceAnalyzer, name_hygiene, resolve_hir_path},
|
||||
};
|
||||
|
||||
const CONTINUE_NO_BREAKS: ControlFlow<Infallible, ()> = ControlFlow::Continue(());
|
||||
|
|
@ -963,11 +963,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
|| kind.is_any_identifier() && value.kind().is_any_identifier();
|
||||
let matches =
|
||||
(kind == mapped_kind || any_ident_match()) && text == value.text();
|
||||
if matches {
|
||||
ControlFlow::Break(value)
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
if matches { ControlFlow::Break(value) } else { ControlFlow::Continue(()) }
|
||||
},
|
||||
)
|
||||
} else {
|
||||
|
|
@ -1780,7 +1776,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
SourceAnalyzer::new_for_body(self.db, def, node, offset)
|
||||
} else {
|
||||
SourceAnalyzer::new_for_body_no_infer(self.db, def, node, offset)
|
||||
})
|
||||
});
|
||||
}
|
||||
ChildContainer::TraitId(it) => it.resolver(self.db.upcast()),
|
||||
ChildContainer::TraitAliasId(it) => it.resolver(self.db.upcast()),
|
||||
|
|
|
|||
|
|
@ -5,22 +5,22 @@
|
|||
//! node for a *child*, and get its hir.
|
||||
|
||||
use either::Either;
|
||||
use hir_expand::{attrs::collect_attrs, HirFileId};
|
||||
use syntax::{ast, AstPtr};
|
||||
use hir_expand::{HirFileId, attrs::collect_attrs};
|
||||
use syntax::{AstPtr, ast};
|
||||
|
||||
use hir_def::{
|
||||
AdtId, AssocItemId, DefWithBodyId, EnumId, FieldId, GenericDefId, ImplId, ItemTreeLoc,
|
||||
LifetimeParamId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId, TypeOrConstParamId,
|
||||
VariantId,
|
||||
db::DefDatabase,
|
||||
dyn_map::{
|
||||
keys::{self, Key},
|
||||
DynMap,
|
||||
keys::{self, Key},
|
||||
},
|
||||
item_scope::ItemScope,
|
||||
item_tree::ItemTreeNode,
|
||||
nameres::DefMap,
|
||||
src::{HasChildSource, HasSource},
|
||||
AdtId, AssocItemId, DefWithBodyId, EnumId, FieldId, GenericDefId, ImplId, ItemTreeLoc,
|
||||
LifetimeParamId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId, TypeOrConstParamId,
|
||||
VariantId,
|
||||
};
|
||||
|
||||
pub(crate) trait ChildBySource {
|
||||
|
|
|
|||
|
|
@ -88,30 +88,30 @@
|
|||
use base_db::{RootQueryDb, Upcast};
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
dyn_map::{
|
||||
keys::{self, Key},
|
||||
DynMap,
|
||||
},
|
||||
hir::{BindingId, Expr, LabelId},
|
||||
AdtId, BlockId, ConstId, ConstParamId, DefWithBodyId, EnumId, EnumVariantId, ExternBlockId,
|
||||
ExternCrateId, FieldId, FunctionId, GenericDefId, GenericParamId, ImplId, LifetimeParamId,
|
||||
Lookup, MacroId, ModuleId, StaticId, StructId, TraitAliasId, TraitId, TypeAliasId, TypeParamId,
|
||||
UnionId, UseId, VariantId,
|
||||
dyn_map::{
|
||||
DynMap,
|
||||
keys::{self, Key},
|
||||
},
|
||||
hir::{BindingId, Expr, LabelId},
|
||||
};
|
||||
use hir_expand::{
|
||||
attrs::AttrId, name::AsName, ExpansionInfo, HirFileId, HirFileIdExt, InMacroFile, MacroCallId,
|
||||
MacroFileId, MacroFileIdExt,
|
||||
ExpansionInfo, HirFileId, HirFileIdExt, InMacroFile, MacroCallId, MacroFileId, MacroFileIdExt,
|
||||
attrs::AttrId, name::AsName,
|
||||
};
|
||||
use rustc_hash::FxHashMap;
|
||||
use smallvec::SmallVec;
|
||||
use span::{EditionedFileId, FileId};
|
||||
use stdx::impl_from;
|
||||
use syntax::{
|
||||
ast::{self, HasName},
|
||||
AstNode, AstPtr, SyntaxNode,
|
||||
ast::{self, HasName},
|
||||
};
|
||||
|
||||
use crate::{db::HirDatabase, semantics::child_by_source::ChildBySource, InFile, InlineAsmOperand};
|
||||
use crate::{InFile, InlineAsmOperand, db::HirDatabase, semantics::child_by_source::ChildBySource};
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct SourceToDefCache {
|
||||
|
|
|
|||
|
|
@ -8,48 +8,49 @@
|
|||
use std::iter::{self, once};
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase, semantics::PathResolution, Adt, AssocItem, BindingMode, BuiltinAttr,
|
||||
BuiltinType, Callable, Const, DeriveHelper, Field, Function, GenericSubstitution, Local, Macro,
|
||||
ModuleDef, Static, Struct, ToolModule, Trait, TraitAlias, TupleField, Type, TypeAlias, Variant,
|
||||
Adt, AssocItem, BindingMode, BuiltinAttr, BuiltinType, Callable, Const, DeriveHelper, Field,
|
||||
Function, GenericSubstitution, Local, Macro, ModuleDef, Static, Struct, ToolModule, Trait,
|
||||
TraitAlias, TupleField, Type, TypeAlias, Variant, db::HirDatabase, semantics::PathResolution,
|
||||
};
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
AsMacroCall, AssocItemId, CallableDefId, ConstId, DefWithBodyId, FieldId, FunctionId,
|
||||
ItemContainerId, LocalFieldId, Lookup, ModuleDefId, StructId, TraitId, VariantId,
|
||||
expr_store::{
|
||||
scope::{ExprScopes, ScopeId},
|
||||
Body, BodySourceMap, HygieneId,
|
||||
scope::{ExprScopes, ScopeId},
|
||||
},
|
||||
hir::{BindingId, Expr, ExprId, ExprOrPatId, Pat},
|
||||
lang_item::LangItem,
|
||||
lower::LowerCtx,
|
||||
nameres::MacroSubNs,
|
||||
path::{ModPath, Path, PathKind},
|
||||
resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs},
|
||||
resolver::{Resolver, TypeNs, ValueNs, resolver_for_scope},
|
||||
type_ref::{Mutability, TypesMap, TypesSourceMap},
|
||||
AsMacroCall, AssocItemId, CallableDefId, ConstId, DefWithBodyId, FieldId, FunctionId,
|
||||
ItemContainerId, LocalFieldId, Lookup, ModuleDefId, StructId, TraitId, VariantId,
|
||||
};
|
||||
use hir_expand::{
|
||||
HirFileId, InFile, InMacroFile, MacroFileId, MacroFileIdExt,
|
||||
mod_path::path,
|
||||
name::{AsName, Name},
|
||||
HirFileId, InFile, InMacroFile, MacroFileId, MacroFileIdExt,
|
||||
};
|
||||
use hir_ty::{
|
||||
Adjustment, InferenceResult, Interner, Substitution, TraitEnvironment, Ty, TyExt, TyKind,
|
||||
TyLoweringContext,
|
||||
diagnostics::{
|
||||
record_literal_missing_fields, record_pattern_missing_fields, unsafe_operations,
|
||||
InsideUnsafeBlock,
|
||||
InsideUnsafeBlock, record_literal_missing_fields, record_pattern_missing_fields,
|
||||
unsafe_operations,
|
||||
},
|
||||
from_assoc_type_id,
|
||||
lang_items::lang_items_for_bin_op,
|
||||
method_resolution, Adjustment, InferenceResult, Interner, Substitution, TraitEnvironment, Ty,
|
||||
TyExt, TyKind, TyLoweringContext,
|
||||
method_resolution,
|
||||
};
|
||||
use intern::sym;
|
||||
use itertools::Itertools;
|
||||
use smallvec::SmallVec;
|
||||
use syntax::ast::{RangeItem, RangeOp};
|
||||
use syntax::{
|
||||
ast::{self, AstNode},
|
||||
SyntaxKind, SyntaxNode, TextRange, TextSize,
|
||||
ast::{self, AstNode},
|
||||
};
|
||||
use triomphe::Arc;
|
||||
|
||||
|
|
@ -147,11 +148,7 @@ impl SourceAnalyzer {
|
|||
|
||||
fn binding_id_of_pat(&self, pat: &ast::IdentPat) -> Option<BindingId> {
|
||||
let pat_id = self.pat_id(&pat.clone().into())?;
|
||||
if let Pat::Bind { id, .. } = self.body()?.pats[pat_id.as_pat()?] {
|
||||
Some(id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if let Pat::Bind { id, .. } = self.body()?.pats[pat_id.as_pat()?] { Some(id) } else { None }
|
||||
}
|
||||
|
||||
fn expand_expr(
|
||||
|
|
@ -504,11 +501,7 @@ impl SourceAnalyzer {
|
|||
LangItem::DerefMut,
|
||||
&Name::new_symbol_root(sym::deref_mut.clone()),
|
||||
)?;
|
||||
if func == deref_mut {
|
||||
Some((deref_mut_trait, deref_mut))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if func == deref_mut { Some((deref_mut_trait, deref_mut)) } else { None }
|
||||
})
|
||||
.unwrap_or((deref_trait, deref))
|
||||
}
|
||||
|
|
@ -550,11 +543,7 @@ impl SourceAnalyzer {
|
|||
LangItem::IndexMut,
|
||||
&Name::new_symbol_root(sym::index_mut.clone()),
|
||||
)?;
|
||||
if func == index_mut_fn {
|
||||
Some((index_mut_trait, index_mut_fn))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if func == index_mut_fn { Some((index_mut_trait, index_mut_fn)) } else { None }
|
||||
})
|
||||
.unwrap_or((index_trait, index_fn));
|
||||
// HACK: subst for all methods coincides with that for their trait because the methods
|
||||
|
|
|
|||
|
|
@ -2,22 +2,22 @@
|
|||
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
AdtId, AssocItemId, DefWithBodyId, ExternCrateId, HasModule, ImplId, Lookup, MacroId,
|
||||
ModuleDefId, ModuleId, TraitId,
|
||||
db::DefDatabase,
|
||||
item_scope::{ImportId, ImportOrExternCrate, ImportOrGlob},
|
||||
per_ns::Item,
|
||||
src::{HasChildSource, HasSource},
|
||||
visibility::{Visibility, VisibilityExplicitness},
|
||||
AdtId, AssocItemId, DefWithBodyId, ExternCrateId, HasModule, ImplId, Lookup, MacroId,
|
||||
ModuleDefId, ModuleId, TraitId,
|
||||
};
|
||||
use hir_expand::{name::Name, HirFileId};
|
||||
use hir_expand::{HirFileId, name::Name};
|
||||
use hir_ty::{
|
||||
db::HirDatabase,
|
||||
display::{hir_display_with_types_map, DisplayTarget, HirDisplay},
|
||||
display::{DisplayTarget, HirDisplay, hir_display_with_types_map},
|
||||
};
|
||||
use intern::Symbol;
|
||||
use rustc_hash::FxHashMap;
|
||||
use syntax::{ast::HasName, AstNode, AstPtr, SmolStr, SyntaxNode, SyntaxNodePtr, ToSmolStr};
|
||||
use syntax::{AstNode, AstPtr, SmolStr, SyntaxNode, SyntaxNodePtr, ToSmolStr, ast::HasName};
|
||||
|
||||
use crate::{Module, ModuleDef, Semantics};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
use std::iter;
|
||||
|
||||
use hir_ty::TyBuilder;
|
||||
use hir_ty::db::HirDatabase;
|
||||
use hir_ty::mir::BorrowKind;
|
||||
use hir_ty::TyBuilder;
|
||||
use itertools::Itertools;
|
||||
use rustc_hash::FxHashSet;
|
||||
use span::Edition;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue