cargo fmt

This commit is contained in:
BenjaminBrienen 2025-03-10 12:42:27 +01:00
parent 87f837cec7
commit 7535bb4661
571 changed files with 2210 additions and 2458 deletions

View file

@ -6,28 +6,28 @@ use base_db::Crate;
use cfg::{CfgExpr, CfgOptions};
use either::Either;
use hir_expand::{
attrs::{collect_attrs, Attr, AttrId, RawAttrs},
HirFileId, InFile,
attrs::{Attr, AttrId, RawAttrs, collect_attrs},
};
use intern::{sym, Symbol};
use intern::{Symbol, sym};
use la_arena::{ArenaMap, Idx, RawIdx};
use mbe::DelimiterKind;
use rustc_abi::ReprOptions;
use syntax::{
ast::{self, HasAttrs},
AstPtr,
ast::{self, HasAttrs},
};
use triomphe::Arc;
use tt::iter::{TtElement, TtIter};
use crate::{
AdtId, AttrDefId, GenericParamId, HasModule, ItemTreeLoc, LocalFieldId, Lookup, MacroId,
VariantId,
db::DefDatabase,
item_tree::{AttrOwner, FieldParent, ItemTreeNode},
lang_item::LangItem,
nameres::{ModuleOrigin, ModuleSource},
src::{HasChildSource, HasSource},
AdtId, AttrDefId, GenericParamId, HasModule, ItemTreeLoc, LocalFieldId, Lookup, MacroId,
VariantId,
};
/// Desugared attributes of an item post `cfg_attr` expansion.
@ -770,8 +770,8 @@ mod tests {
use hir_expand::span_map::{RealSpanMap, SpanMap};
use span::FileId;
use syntax::{ast, AstNode, TextRange};
use syntax_bridge::{syntax_node_to_token_tree, DocCommentDesugarMode};
use syntax::{AstNode, TextRange, ast};
use syntax_bridge::{DocCommentDesugarMode, syntax_node_to_token_tree};
use crate::attr::{DocAtom, DocExpr};

View file

@ -6,7 +6,7 @@
use std::fmt;
use hir_expand::name::{AsName, Name};
use intern::{sym, Symbol};
use intern::{Symbol, sym};
/// Different signed int types.
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum BuiltinInt {

View file

@ -4,19 +4,19 @@ pub mod adt;
use base_db::Crate;
use hir_expand::name::Name;
use intern::{sym, Symbol};
use intern::{Symbol, sym};
use la_arena::{Idx, RawIdx};
use triomphe::Arc;
use crate::{
ConstId, ExternCrateId, FunctionId, HasModule, ImplId, ItemContainerId, ItemLoc, Lookup,
Macro2Id, MacroRulesId, ProcMacroId, StaticId, TraitAliasId, TraitId, TypeAliasId,
db::DefDatabase,
item_tree::{self, FnFlags, ModItem},
nameres::proc_macro::{parse_macro_name_and_helper_attrs, ProcMacroKind},
nameres::proc_macro::{ProcMacroKind, parse_macro_name_and_helper_attrs},
path::ImportAlias,
type_ref::{TraitRef, TypeBound, TypeRefId, TypesMap},
visibility::RawVisibility,
ConstId, ExternCrateId, FunctionId, HasModule, ImplId, ItemContainerId, ItemLoc, Lookup,
Macro2Id, MacroRulesId, ProcMacroId, StaticId, TraitAliasId, TraitId, TypeAliasId,
};
#[derive(Debug, Clone, PartialEq, Eq)]
@ -431,11 +431,7 @@ impl ExternCrateDeclData {
Some(krate)
} else {
krate.data(db).dependencies.iter().find_map(|dep| {
if dep.name.symbol() == name.symbol() {
Some(dep.crate_id)
} else {
None
}
if dep.name.symbol() == name.symbol() { Some(dep.crate_id) } else { None }
})
};

View file

@ -11,6 +11,7 @@ use rustc_abi::{IntegerType, ReprOptions};
use triomphe::Arc;
use crate::{
EnumId, EnumVariantId, LocalFieldId, LocalModuleId, Lookup, StructId, UnionId, VariantId,
db::DefDatabase,
hir::Expr,
item_tree::{
@ -20,7 +21,6 @@ use crate::{
nameres::diagnostics::{DefDiagnostic, DefDiagnostics},
type_ref::{TypeRefId, TypesMap},
visibility::RawVisibility,
EnumId, EnumVariantId, LocalFieldId, LocalModuleId, Lookup, StructId, UnionId, VariantId,
};
/// Note that we use `StructData` for unions as well!

View file

@ -1,33 +1,14 @@
//! Defines database & queries for name resolution.
use base_db::{Crate, RootQueryDb, SourceDatabase, Upcast};
use either::Either;
use hir_expand::{db::ExpandDatabase, HirFileId, MacroDefId};
use hir_expand::{HirFileId, MacroDefId, db::ExpandDatabase};
use intern::sym;
use la_arena::ArenaMap;
use span::{EditionedFileId, MacroCallId};
use syntax::{ast, AstPtr};
use syntax::{AstPtr, ast};
use triomphe::Arc;
use crate::{
attr::{Attrs, AttrsWithOwner},
data::{
adt::{EnumData, EnumVariantData, EnumVariants, StructData, VariantData},
ConstData, ExternCrateDeclData, FunctionData, ImplData, Macro2Data, MacroRulesData,
ProcMacroData, StaticData, TraitAliasData, TraitData, TypeAliasData,
},
expr_store::{scope::ExprScopes, Body, BodySourceMap},
generics::GenericParams,
import_map::ImportMap,
item_tree::{AttrOwner, ItemTree, ItemTreeSourceMaps},
lang_item::{self, LangItem, LangItemTarget, LangItems},
nameres::{
assoc::{ImplItems, TraitItems},
diagnostics::DefDiagnostics,
DefMap, LocalDefMap,
},
tt,
type_ref::TypesSourceMap,
visibility::{self, Visibility},
AttrDefId, BlockId, BlockLoc, ConstBlockId, ConstBlockLoc, ConstId, ConstLoc, DefWithBodyId,
EnumId, EnumLoc, EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId,
ExternCrateLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, InTypeConstId,
@ -35,6 +16,25 @@ use crate::{
MacroRulesLocFlags, ProcMacroId, ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc,
TraitAliasId, TraitAliasLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc,
UseId, UseLoc, VariantId,
attr::{Attrs, AttrsWithOwner},
data::{
ConstData, ExternCrateDeclData, FunctionData, ImplData, Macro2Data, MacroRulesData,
ProcMacroData, StaticData, TraitAliasData, TraitData, TypeAliasData,
adt::{EnumData, EnumVariantData, EnumVariants, StructData, VariantData},
},
expr_store::{Body, BodySourceMap, scope::ExprScopes},
generics::GenericParams,
import_map::ImportMap,
item_tree::{AttrOwner, ItemTree, ItemTreeSourceMaps},
lang_item::{self, LangItem, LangItemTarget, LangItems},
nameres::{
DefMap, LocalDefMap,
assoc::{ImplItems, TraitItems},
diagnostics::DefDiagnostics,
},
tt,
type_ref::TypesSourceMap,
visibility::{self, Visibility},
};
use salsa::plumbing::AsId;
@ -337,7 +337,7 @@ fn crate_supports_no_std(db: &dyn DefDatabase, crate_id: Crate) -> bool {
for output in segments.skip(1) {
match output.flat_tokens() {
[tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] if ident.sym == sym::no_std => {
return true
return true;
}
_ => {}
}

View file

@ -27,15 +27,15 @@
pub mod keys {
use std::marker::PhantomData;
use hir_expand::{attrs::AttrId, MacroCallId};
use hir_expand::{MacroCallId, attrs::AttrId};
use rustc_hash::FxHashMap;
use syntax::{ast, AstNode, AstPtr};
use syntax::{AstNode, AstPtr, ast};
use crate::{
dyn_map::{DynMap, Policy},
BlockId, ConstId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId, FieldId, FunctionId,
ImplId, LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId, StaticId, StructId,
TraitAliasId, TraitId, TypeAliasId, TypeOrConstParamId, UnionId, UseId,
dyn_map::{DynMap, Policy},
};
pub type Key<K, V> = crate::dyn_map::Key<AstPtr<K>, V, AstPtrPolicy<K, V>>;

View file

@ -6,17 +6,17 @@ use base_db::Crate;
use cfg::CfgOptions;
use drop_bomb::DropBomb;
use hir_expand::{
attrs::RawAttrs, mod_path::ModPath, span_map::SpanMap, ExpandError, ExpandErrorKind,
ExpandResult, HirFileId, InFile, Lookup, MacroCallId,
ExpandError, ExpandErrorKind, ExpandResult, HirFileId, InFile, Lookup, MacroCallId,
attrs::RawAttrs, mod_path::ModPath, span_map::SpanMap,
};
use span::{Edition, SyntaxContext};
use syntax::{ast, Parse};
use syntax::{Parse, ast};
use triomphe::Arc;
use crate::type_ref::{TypesMap, TypesSourceMap};
use crate::{
attr::Attrs, db::DefDatabase, lower::LowerCtx, path::Path, AsMacroCall, MacroId, ModuleId,
UnresolvedMacro,
AsMacroCall, MacroId, ModuleId, UnresolvedMacro, attr::Attrs, db::DefDatabase, lower::LowerCtx,
path::Path,
};
#[derive(Debug)]
@ -84,11 +84,7 @@ impl Expander {
}
});
if let Some(err) = unresolved_macro_err {
Err(err)
} else {
Ok(result)
}
if let Some(err) = unresolved_macro_err { Err(err) } else { Ok(result) }
}
pub fn enter_expand_id<T: ast::AstNode>(

View file

@ -12,16 +12,17 @@ use std::ops::{Deref, Index};
use cfg::{CfgExpr, CfgOptions};
use either::Either;
use hir_expand::{name::Name, ExpandError, InFile};
use hir_expand::{ExpandError, InFile, name::Name};
use la_arena::{Arena, ArenaMap};
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use span::{Edition, MacroFileId, SyntaxContext};
use syntax::{ast, AstPtr, SyntaxNodePtr};
use syntax::{AstPtr, SyntaxNodePtr, ast};
use triomphe::Arc;
use tt::TextRange;
use crate::{
BlockId, DefWithBodyId, Lookup, SyntheticSyntax,
db::DefDatabase,
hir::{
Array, AsmOperand, Binding, BindingId, Expr, ExprId, ExprOrPatId, Label, LabelId, Pat,
@ -30,7 +31,6 @@ use crate::{
nameres::DefMap,
path::{ModPath, Path},
type_ref::{TypeRef, TypeRefId, TypesMap, TypesSourceMap},
BlockId, DefWithBodyId, Lookup, SyntheticSyntax,
};
pub use self::body::{Body, BodySourceMap};

View file

@ -9,13 +9,13 @@ use syntax::ast;
use triomphe::Arc;
use crate::{
DefWithBodyId, HasModule,
db::DefDatabase,
expander::Expander,
expr_store::{lower, pretty, ExpressionStore, ExpressionStoreSourceMap, SelfParamPtr},
expr_store::{ExpressionStore, ExpressionStoreSourceMap, SelfParamPtr, lower, pretty},
hir::{BindingId, ExprId, PatId},
item_tree::AttrOwner,
src::HasSource,
DefWithBodyId, HasModule,
};
/// The body of an item (function, const etc.).

View file

@ -8,26 +8,27 @@ use std::mem;
use base_db::Crate;
use either::Either;
use hir_expand::{
InFile, MacroDefId,
mod_path::tool_path,
name::{AsName, Name},
span_map::{ExpansionSpanMap, SpanMap},
InFile, MacroDefId,
};
use intern::{sym, Symbol};
use intern::{Symbol, sym};
use rustc_hash::FxHashMap;
use span::AstIdMap;
use stdx::never;
use syntax::{
AstNode, AstPtr, AstToken as _, SyntaxNodePtr,
ast::{
self, ArrayExprKind, AstChildren, BlockExpr, HasArgList, HasAttrs, HasGenericArgs,
HasLoopBody, HasName, RangeItem, SlicePatComponents,
},
AstNode, AstPtr, AstToken as _, SyntaxNodePtr,
};
use text_size::TextSize;
use triomphe::Arc;
use crate::{
AdtId, BlockId, BlockLoc, ConstBlockLoc, DefWithBodyId, MacroId, ModuleDefId, UnresolvedMacro,
attr::Attrs,
builtin_type::BuiltinUint,
data::adt::StructKind,
@ -38,14 +39,14 @@ use crate::{
ExpressionStoreDiagnostics, ExpressionStoreSourceMap, HygieneId, LabelPtr, PatPtr,
},
hir::{
Array, Binding, BindingAnnotation, BindingId, BindingProblems, CaptureBy, ClosureKind,
Expr, ExprId, Item, Label, LabelId, Literal, MatchArm, Movability, OffsetOf, Pat, PatId,
RecordFieldPat, RecordLitField, Statement,
format_args::{
self, FormatAlignment, FormatArgs, FormatArgsPiece, FormatArgument, FormatArgumentKind,
FormatArgumentsCollector, FormatCount, FormatDebugHex, FormatOptions,
FormatPlaceholder, FormatSign, FormatTrait,
},
Array, Binding, BindingAnnotation, BindingId, BindingProblems, CaptureBy, ClosureKind,
Expr, ExprId, Item, Label, LabelId, Literal, MatchArm, Movability, OffsetOf, Pat, PatId,
RecordFieldPat, RecordLitField, Statement,
},
item_scope::BuiltinShadowMode,
lang_item::LangItem,
@ -53,7 +54,6 @@ use crate::{
nameres::{DefMap, LocalDefMap, MacroSubNs},
path::{GenericArgs, Path},
type_ref::{Mutability, Rawness, TypeRef},
AdtId, BlockId, BlockLoc, ConstBlockLoc, DefWithBodyId, MacroId, ModuleDefId, UnresolvedMacro,
};
type FxIndexSet<K> = indexmap::IndexSet<K, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
@ -641,11 +641,7 @@ impl ExprCollector<'_> {
let expr = self.collect_expr_opt(e.expr());
let raw_tok = e.raw_token().is_some();
let mutability = if raw_tok {
if e.mut_token().is_some() {
Mutability::Mut
} else {
Mutability::Shared
}
if e.mut_token().is_some() { Mutability::Mut } else { Mutability::Shared }
} else {
Mutability::from_mutable(e.mut_token().is_some())
};
@ -2041,7 +2037,7 @@ impl ExprCollector<'_> {
return match l.kind() {
ast::LiteralKind::String(s) => Some((s, true)),
_ => None,
}
};
}
_ => return None,
};

View file

@ -3,8 +3,8 @@ use hir_expand::name::Name;
use intern::Symbol;
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::{
ast::{self, HasName, IsString},
AstNode, AstPtr, AstToken, T,
ast::{self, HasName, IsString},
};
use tt::TextRange;

View file

@ -1,13 +1,13 @@
//! Name resolution for expressions.
use hir_expand::{name::Name, MacroDefId};
use hir_expand::{MacroDefId, name::Name};
use la_arena::{Arena, ArenaMap, Idx, IdxRange, RawIdx};
use triomphe::Arc;
use crate::{
BlockId, ConstBlockId, DefWithBodyId,
db::DefDatabase,
expr_store::{Body, ExpressionStore, HygieneId},
hir::{Binding, BindingId, Expr, ExprId, Item, LabelId, Pat, PatId, Statement},
BlockId, ConstBlockId, DefWithBodyId,
};
pub type ScopeId = Idx<ScopeData>;
@ -325,14 +325,14 @@ fn compute_expr_scopes(
#[cfg(test)]
mod tests {
use base_db::RootQueryDb;
use hir_expand::{name::AsName, InFile};
use hir_expand::{InFile, name::AsName};
use salsa::AsDynDatabase;
use span::FileId;
use syntax::{algo::find_node_at_offset, ast, AstNode};
use syntax::{AstNode, algo::find_node_at_offset, ast};
use test_fixture::WithFixture;
use test_utils::{assert_eq_text, extract_offset};
use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
use crate::{FunctionId, ModuleDefId, db::DefDatabase, test_db::TestDB};
fn find_function(db: &TestDB, file_id: FileId) -> FunctionId {
let krate = db.test_crate();

View file

@ -1,7 +1,7 @@
mod block;
use crate::{hir::MatchArm, test_db::TestDB, ModuleDefId};
use expect_test::{expect, Expect};
use crate::{ModuleDefId, hir::MatchArm, test_db::TestDB};
use expect_test::{Expect, expect};
use la_arena::RawIdx;
use test_fixture::WithFixture;

View file

@ -4,19 +4,19 @@ use std::{cell::Cell, cmp::Ordering, iter};
use base_db::{Crate, CrateOrigin, LangCrateOrigin};
use hir_expand::{
name::{AsName, Name},
Lookup,
name::{AsName, Name},
};
use intern::sym;
use rustc_hash::FxHashSet;
use crate::{
ImportPathConfig, ModuleDefId, ModuleId,
db::DefDatabase,
item_scope::ItemInNs,
nameres::DefMap,
path::{ModPath, PathKind},
visibility::{Visibility, VisibilityExplicitness},
ImportPathConfig, ModuleDefId, ModuleId,
};
/// Find a path that can be used to refer to a certain item. This can depend on
@ -651,7 +651,7 @@ fn find_local_import_locations(
#[cfg(test)]
mod tests {
use expect_test::{expect, Expect};
use expect_test::{Expect, expect};
use hir_expand::db::ExpandDatabase;
use itertools::Itertools;
use span::Edition;

View file

@ -7,8 +7,8 @@ use std::{ops, sync::LazyLock};
use either::Either;
use hir_expand::{
name::{AsName, Name},
ExpandResult,
name::{AsName, Name},
};
use intern::sym;
use la_arena::{Arena, RawIdx};
@ -20,6 +20,8 @@ use syntax::ast::{self, HasGenericParams, HasName, HasTypeBounds};
use triomphe::Arc;
use crate::{
AdtId, ConstParamId, GenericDefId, HasModule, ItemTreeLoc, LifetimeParamId,
LocalLifetimeParamId, LocalTypeOrConstParamId, Lookup, TypeOrConstParamId, TypeParamId,
db::DefDatabase,
expander::Expander,
item_tree::{AttrOwner, FileItemTreeId, GenericModItem, GenericsItemTreeNode, ItemTree},
@ -30,8 +32,6 @@ use crate::{
ArrayType, ConstRef, FnType, LifetimeRef, PathId, RefType, TypeBound, TypeRef, TypeRefId,
TypesMap, TypesSourceMap,
},
AdtId, ConstParamId, GenericDefId, HasModule, ItemTreeLoc, LifetimeParamId,
LocalLifetimeParamId, LocalTypeOrConstParamId, Lookup, TypeOrConstParamId, TypeParamId,
};
/// The index of the self param in the generic of the non-parent definition.
@ -292,11 +292,7 @@ impl GenericParams {
parent: GenericDefId,
) -> Option<LifetimeParamId> {
self.lifetimes.iter().find_map(|(id, p)| {
if &p.name == name {
Some(LifetimeParamId { local_id: id, parent })
} else {
None
}
if &p.name == name { Some(LifetimeParamId { local_id: id, parent }) } else { None }
})
}

View file

@ -17,7 +17,7 @@ pub mod type_ref;
use std::fmt;
use hir_expand::{name::Name, MacroDefId};
use hir_expand::{MacroDefId, name::Name};
use intern::Symbol;
use la_arena::Idx;
use rustc_apfloat::ieee::{Half as f16, Quad as f128};
@ -25,10 +25,10 @@ use syntax::ast;
use type_ref::TypeRefId;
use crate::{
BlockId, ConstBlockId,
builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint},
path::{GenericArgs, Path},
type_ref::{Mutability, Rawness},
BlockId, ConstBlockId,
};
pub use syntax::ast::{ArithOp, BinaryOp, CmpOp, LogicOp, Ordering, RangeOp, UnaryOp};
@ -137,11 +137,7 @@ pub enum LiteralOrConst {
impl Literal {
pub fn negate(self) -> Option<Self> {
if let Literal::Int(i, k) = self {
Some(Literal::Int(-i, k))
} else {
None
}
if let Literal::Int(i, k) = self { Some(Literal::Int(-i, k)) } else { None }
}
}

View file

@ -7,8 +7,8 @@ use rustc_parse_format as parse;
use span::SyntaxContext;
use stdx::TupleExt;
use syntax::{
ast::{self, IsString},
TextRange,
ast::{self, IsString},
};
use crate::hir::ExprId;

View file

@ -5,25 +5,25 @@ use core::fmt;
use std::{fmt::Write, ops::Index};
use hir_expand::{
AstId, InFile,
db::ExpandDatabase,
name::{AsName, Name},
AstId, InFile,
};
use intern::{sym, Symbol};
use intern::{Symbol, sym};
use la_arena::{Arena, ArenaMap, Idx};
use span::Edition;
use stdx::thin_vec::{thin_vec_with_header_struct, EmptyOptimizedThinVec, ThinVec};
use stdx::thin_vec::{EmptyOptimizedThinVec, ThinVec, thin_vec_with_header_struct};
use syntax::{
ast::{self, HasGenericArgs, HasName, IsString},
AstPtr,
ast::{self, HasGenericArgs, HasName, IsString},
};
use crate::{
SyntheticSyntax,
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
hir::Literal,
lower::LowerCtx,
path::{GenericArg, Path},
SyntheticSyntax,
};
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
@ -34,11 +34,7 @@ pub enum Mutability {
impl Mutability {
pub fn from_mutable(mutable: bool) -> Mutability {
if mutable {
Mutability::Mut
} else {
Mutability::Shared
}
if mutable { Mutability::Mut } else { Mutability::Shared }
}
pub fn as_keyword_for_ref(self) -> &'static str {
@ -80,11 +76,7 @@ pub enum Rawness {
impl Rawness {
pub fn from_raw(is_raw: bool) -> Rawness {
if is_raw {
Rawness::RawPtr
} else {
Rawness::Ref
}
if is_raw { Rawness::RawPtr } else { Rawness::Ref }
}
pub fn is_raw(&self) -> bool {

View file

@ -3,21 +3,21 @@
use std::fmt;
use base_db::Crate;
use fst::{raw::IndexedValue, Automaton, Streamer};
use fst::{Automaton, Streamer, raw::IndexedValue};
use hir_expand::name::Name;
use itertools::Itertools;
use rustc_hash::FxHashSet;
use smallvec::SmallVec;
use span::Edition;
use stdx::{format_to, TupleExt};
use stdx::{TupleExt, format_to};
use triomphe::Arc;
use crate::{
AssocItemId, FxIndexMap, ModuleDefId, ModuleId, TraitId,
db::DefDatabase,
item_scope::{ImportOrExternCrate, ItemInNs},
nameres::DefMap,
visibility::Visibility,
AssocItemId, FxIndexMap, ModuleDefId, ModuleId, TraitId,
};
/// Item import details stored in the `ImportMap`.
@ -155,11 +155,7 @@ impl ImportMap {
let visible_items = mod_data.scope.entries().filter_map(|(name, per_ns)| {
let per_ns = per_ns.filter_visibility(|vis| vis == Visibility::Public);
if per_ns.is_none() {
None
} else {
Some((name, per_ns))
}
if per_ns.is_none() { None } else { Some((name, per_ns)) }
});
for (name, per_ns) in visible_items {
@ -474,10 +470,10 @@ fn search_maps(
#[cfg(test)]
mod tests {
use base_db::{RootQueryDb, Upcast};
use expect_test::{expect, Expect};
use expect_test::{Expect, expect};
use test_fixture::WithFixture;
use crate::{test_db::TestDB, ItemContainerId, Lookup};
use crate::{ItemContainerId, Lookup, test_db::TestDB};
use super::*;

View file

@ -4,22 +4,22 @@
use std::sync::LazyLock;
use base_db::Crate;
use hir_expand::{attrs::AttrId, db::ExpandDatabase, name::Name, AstId, MacroCallId};
use hir_expand::{AstId, MacroCallId, attrs::AttrId, db::ExpandDatabase, name::Name};
use indexmap::map::Entry;
use itertools::Itertools;
use la_arena::Idx;
use rustc_hash::{FxHashMap, FxHashSet};
use smallvec::{smallvec, SmallVec};
use smallvec::{SmallVec, smallvec};
use span::Edition;
use stdx::format_to;
use syntax::ast;
use crate::{
AdtId, BuiltinType, ConstId, ExternBlockId, ExternCrateId, FxIndexMap, HasModule, ImplId,
LocalModuleId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId, UseId,
db::DefDatabase,
per_ns::{Item, MacrosItem, PerNs, TypesItem, ValuesItem},
visibility::{Visibility, VisibilityExplicitness},
AdtId, BuiltinType, ConstId, ExternBlockId, ExternCrateId, FxIndexMap, HasModule, ImplId,
LocalModuleId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId, UseId,
};
#[derive(Debug, Default)]

View file

@ -46,24 +46,24 @@ use std::{
use ast::{AstNode, StructKind};
use base_db::Crate;
use either::Either;
use hir_expand::{attrs::RawAttrs, name::Name, ExpandTo, HirFileId, InFile};
use hir_expand::{ExpandTo, HirFileId, InFile, attrs::RawAttrs, name::Name};
use intern::{Interned, Symbol};
use la_arena::{Arena, Idx, RawIdx};
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use span::{AstIdNode, Edition, FileAstId, SyntaxContext};
use stdx::never;
use syntax::{ast, match_ast, SyntaxKind};
use syntax::{SyntaxKind, ast, match_ast};
use triomphe::Arc;
use crate::{
BlockId, LocalLifetimeParamId, LocalTypeOrConstParamId, Lookup,
attr::Attrs,
db::DefDatabase,
generics::GenericParams,
path::{GenericArgs, ImportAlias, ModPath, Path, PathKind},
type_ref::{Mutability, TraitRef, TypeBound, TypeRefId, TypesMap, TypesSourceMap},
visibility::{RawVisibility, VisibilityExplicitness},
BlockId, LocalLifetimeParamId, LocalTypeOrConstParamId, Lookup,
};
#[derive(Copy, Clone, Eq, PartialEq)]

View file

@ -3,23 +3,24 @@
use std::{cell::OnceCell, collections::hash_map::Entry};
use hir_expand::{
HirFileId,
mod_path::path,
name::AsName,
span_map::{SpanMap, SpanMapRef},
HirFileId,
};
use intern::{sym, Symbol};
use intern::{Symbol, sym};
use la_arena::Arena;
use rustc_hash::FxHashMap;
use span::{AstIdMap, SyntaxContext};
use stdx::thin_vec::ThinVec;
use syntax::{
ast::{self, HasModuleItem, HasName, HasTypeBounds, IsString},
AstNode,
ast::{self, HasModuleItem, HasName, HasTypeBounds, IsString},
};
use triomphe::Arc;
use crate::{
LocalLifetimeParamId, LocalTypeOrConstParamId,
db::DefDatabase,
generics::{GenericParams, GenericParamsCollector},
item_tree::{
@ -38,7 +39,6 @@ use crate::{
TypesMap, TypesSourceMap,
},
visibility::RawVisibility,
LocalLifetimeParamId, LocalTypeOrConstParamId,
};
fn id<N>(index: Idx<N>) -> FileItemTreeId<N> {
@ -931,8 +931,7 @@ impl<'a> Ctx<'a> {
fn desugar_future_path(ctx: &mut LowerCtx<'_>, orig: TypeRefId) -> PathId {
let path = path![core::future::Future];
let mut generic_args: Vec<_> =
std::iter::repeat_n(None, path.segments().len() - 1).collect();
let mut generic_args: Vec<_> = std::iter::repeat_n(None, path.segments().len() - 1).collect();
let binding = AssociatedTypeBinding {
name: Name::new_symbol_root(sym::Output.clone()),
args: None,

View file

@ -1,4 +1,4 @@
use expect_test::{expect, Expect};
use expect_test::{Expect, expect};
use span::Edition;
use test_fixture::WithFixture;

View file

@ -3,13 +3,13 @@
//! This attribute to tell the compiler about semi built-in std library
//! features, such as Fn family of traits.
use hir_expand::name::Name;
use intern::{sym, Symbol};
use intern::{Symbol, sym};
use rustc_hash::FxHashMap;
use triomphe::Arc;
use crate::{
db::DefDatabase, path::Path, AdtId, AssocItemId, AttrDefId, Crate, EnumId, EnumVariantId,
FunctionId, ImplId, ModuleDefId, StaticId, StructId, TraitId, TypeAliasId, UnionId,
AdtId, AssocItemId, AttrDefId, Crate, EnumId, EnumVariantId, FunctionId, ImplId, ModuleDefId,
StaticId, StructId, TraitId, TypeAliasId, UnionId, db::DefDatabase, path::Path,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -164,11 +164,7 @@ impl LangItems {
}
}
if lang_items.items.is_empty() {
None
} else {
Some(Arc::new(lang_items))
}
if lang_items.items.is_empty() { None } else { Some(Arc::new(lang_items)) }
}
/// Salsa query. Look for a lang item, starting from the specified crate and recursively
@ -230,11 +226,7 @@ pub(crate) fn crate_notable_traits(db: &dyn DefDatabase, krate: Crate) -> Option
}
}
if traits.is_empty() {
None
} else {
Some(traits.into_iter().collect())
}
if traits.is_empty() { None } else { Some(traits.into_iter().collect()) }
}
pub enum GenericRequirement {

View file

@ -71,25 +71,25 @@ mod test_db;
use std::hash::{Hash, Hasher};
use base_db::{impl_intern_key, Crate};
use base_db::{Crate, impl_intern_key};
use hir_expand::{
AstId, ExpandError, ExpandResult, ExpandTo, HirFileId, InFile, MacroCallId, MacroCallKind,
MacroDefId, MacroDefKind,
builtin::{BuiltinAttrExpander, BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerExpander},
db::ExpandDatabase,
eager::expand_eager_macro_input,
impl_intern_lookup,
name::Name,
proc_macro::{CustomProcMacroExpander, ProcMacroKind},
AstId, ExpandError, ExpandResult, ExpandTo, HirFileId, InFile, MacroCallId, MacroCallKind,
MacroDefId, MacroDefKind,
};
use item_tree::ExternBlock;
use la_arena::Idx;
use nameres::DefMap;
use span::{AstIdNode, Edition, FileAstId, SyntaxContext};
use stdx::impl_from;
use syntax::{ast, AstNode};
use syntax::{AstNode, ast};
pub use hir_expand::{tt, Intern, Lookup};
pub use hir_expand::{Intern, Lookup, tt};
use crate::{
builtin_type::BuiltinType,
@ -438,11 +438,7 @@ impl ModuleId {
let def_map = self.def_map(db);
let parent = def_map[self.local_id].parent?;
def_map[parent].children.iter().find_map(|(name, module_id)| {
if *module_id == self.local_id {
Some(name.clone())
} else {
None
}
if *module_id == self.local_id { Some(name.clone()) } else { None }
})
}

View file

@ -1,7 +1,7 @@
//! Context for lowering paths.
use std::{cell::OnceCell, mem};
use hir_expand::{span_map::SpanMap, AstId, HirFileId, InFile};
use hir_expand::{AstId, HirFileId, InFile, span_map::SpanMap};
use span::{AstIdMap, AstIdNode, Edition, EditionedFileId, FileId, RealSpanMap};
use stdx::thin_vec::ThinVec;
use syntax::ast;

View file

@ -19,10 +19,10 @@ use std::{iter, ops::Range, sync};
use base_db::RootQueryDb;
use expect_test::Expect;
use hir_expand::{
InFile, MacroCallKind, MacroFileId, MacroFileIdExt, MacroKind,
db::ExpandDatabase,
proc_macro::{ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind},
span_map::SpanMapRef,
InFile, MacroCallKind, MacroFileId, MacroFileIdExt, MacroKind,
};
use intern::Symbol;
use itertools::Itertools;
@ -30,21 +30,21 @@ use salsa::AsDynDatabase;
use span::{Edition, Span};
use stdx::{format_to, format_to_acc};
use syntax::{
ast::{self, edit::IndentLevel},
AstNode,
SyntaxKind::{COMMENT, EOF, IDENT, LIFETIME_IDENT},
SyntaxNode, T,
ast::{self, edit::IndentLevel},
};
use test_fixture::WithFixture;
use crate::{
AdtId, AsMacroCall, Lookup, ModuleDefId,
db::DefDatabase,
nameres::{DefMap, MacroSubNs, ModuleSource},
resolver::HasResolver,
src::HasSource,
test_db::TestDB,
tt::TopSubtree,
AdtId, AsMacroCall, Lookup, ModuleDefId,
};
#[track_caller]

View file

@ -62,7 +62,7 @@ use std::ops::Deref;
use base_db::Crate;
use hir_expand::{
name::Name, proc_macro::ProcMacroKind, ErasedAstId, HirFileId, InFile, MacroCallId, MacroDefId,
ErasedAstId, HirFileId, InFile, MacroCallId, MacroDefId, name::Name, proc_macro::ProcMacroKind,
};
use intern::Symbol;
use itertools::Itertools;
@ -70,11 +70,13 @@ use la_arena::Arena;
use rustc_hash::{FxHashMap, FxHashSet};
use span::{Edition, EditionedFileId, FileAstId, FileId, ROOT_ERASED_FILE_AST_ID};
use stdx::format_to;
use syntax::{ast, AstNode, SmolStr, SyntaxNode, ToSmolStr};
use syntax::{AstNode, SmolStr, SyntaxNode, ToSmolStr, ast};
use triomphe::Arc;
use tt::TextRange;
use crate::{
AstId, BlockId, BlockLoc, CrateRootModuleId, EnumId, EnumVariantId, ExternCrateId, FunctionId,
FxIndexMap, LocalModuleId, Lookup, MacroExpander, MacroId, ModuleId, ProcMacroId, UseId,
db::DefDatabase,
item_scope::{BuiltinShadowMode, ItemScope},
item_tree::{ItemTreeId, Mod, TreeId},
@ -82,8 +84,6 @@ use crate::{
path::ModPath,
per_ns::PerNs,
visibility::{Visibility, VisibilityExplicitness},
AstId, BlockId, BlockLoc, CrateRootModuleId, EnumId, EnumVariantId, ExternCrateId, FunctionId,
FxIndexMap, LocalModuleId, Lookup, MacroExpander, MacroId, ModuleId, ProcMacroId, UseId,
};
pub use self::path_resolution::ResolvePathResultPrefixInfo;

View file

@ -1,25 +1,25 @@
//! Expansion of associated items
use hir_expand::{
name::Name, AstId, ExpandResult, InFile, Intern, Lookup, MacroCallKind, MacroDefKind,
AstId, ExpandResult, InFile, Intern, Lookup, MacroCallKind, MacroDefKind, name::Name,
};
use smallvec::SmallVec;
use span::{HirFileId, MacroCallId};
use syntax::{ast, Parse};
use syntax::{Parse, ast};
use triomphe::Arc;
use crate::{
AssocItemId, AstIdWithPath, ConstLoc, FunctionId, FunctionLoc, ImplId, ItemContainerId,
ItemLoc, ModuleId, TraitId, TypeAliasId, TypeAliasLoc,
db::DefDatabase,
expander::{Expander, Mark},
item_tree::{self, AssocItem, ItemTree, ItemTreeId, MacroCall, ModItem, TreeId},
macro_call_as_call_id,
nameres::{
DefMap, LocalDefMap, MacroSubNs,
attr_resolution::ResolvedAttr,
diagnostics::{DefDiagnostic, DefDiagnostics},
DefMap, LocalDefMap, MacroSubNs,
},
AssocItemId, AstIdWithPath, ConstLoc, FunctionId, FunctionLoc, ImplId, ItemContainerId,
ItemLoc, ModuleId, TraitId, TypeAliasId, TypeAliasLoc,
};
#[derive(Debug, Clone, PartialEq, Eq)]

View file

@ -2,20 +2,20 @@
use base_db::Crate;
use hir_expand::{
MacroCallId, MacroCallKind, MacroDefId,
attrs::{Attr, AttrId, AttrInput},
inert_attr_macro::find_builtin_attr_idx,
MacroCallId, MacroCallKind, MacroDefId,
};
use span::SyntaxContext;
use syntax::ast;
use triomphe::Arc;
use crate::{
AstIdWithPath, LocalModuleId, MacroId, UnresolvedMacro,
db::DefDatabase,
item_scope::BuiltinShadowMode,
nameres::{path_resolution::ResolveMode, LocalDefMap},
nameres::{LocalDefMap, path_resolution::ResolveMode},
path::{self, ModPath, PathKind},
AstIdWithPath, LocalModuleId, MacroId, UnresolvedMacro,
};
use super::{DefMap, MacroSubNs};

View file

@ -9,15 +9,15 @@ use base_db::{BuiltDependency, Crate, CrateOrigin, LangCrateOrigin};
use cfg::{CfgAtom, CfgExpr, CfgOptions};
use either::Either;
use hir_expand::{
ExpandTo, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
MacroFileIdExt,
attrs::{Attr, AttrId},
builtin::{find_builtin_attr, find_builtin_derive, find_builtin_macro},
name::{AsName, Name},
proc_macro::CustomProcMacroExpander,
ExpandTo, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
MacroFileIdExt,
};
use intern::{sym, Interned};
use itertools::{izip, Itertools};
use intern::{Interned, sym};
use itertools::{Itertools, izip};
use la_arena::Idx;
use rustc_hash::{FxHashMap, FxHashSet};
use span::{Edition, EditionedFileId, FileAstId, SyntaxContext};
@ -25,6 +25,12 @@ use syntax::ast;
use triomphe::Arc;
use crate::{
AdtId, AstId, AstIdWithPath, ConstLoc, CrateRootModuleId, EnumLoc, EnumVariantLoc,
ExternBlockLoc, ExternCrateId, ExternCrateLoc, FunctionId, FunctionLoc, ImplLoc, Intern,
ItemContainerId, LocalModuleId, Lookup, Macro2Id, Macro2Loc, MacroExpander, MacroId,
MacroRulesId, MacroRulesLoc, MacroRulesLocFlags, ModuleDefId, ModuleId, ProcMacroId,
ProcMacroLoc, StaticLoc, StructLoc, TraitAliasLoc, TraitLoc, TypeAliasLoc, UnionLoc,
UnresolvedMacro, UseId, UseLoc,
attr::Attrs,
db::DefDatabase,
item_scope::{GlobId, ImportId, ImportOrExternCrate, PerNsGlobImports},
@ -34,24 +40,18 @@ use crate::{
},
macro_call_as_call_id, macro_call_as_call_id_with_eager,
nameres::{
BuiltinShadowMode, DefMap, LocalDefMap, MacroSubNs, ModuleData, ModuleOrigin, ResolveMode,
attr_resolution::{attr_macro_as_call_id, derive_macro_as_call_id},
diagnostics::DefDiagnostic,
mod_resolution::ModDir,
path_resolution::ReachedFixedPoint,
proc_macro::{parse_macro_name_and_helper_attrs, ProcMacroDef, ProcMacroKind},
sub_namespace_match, BuiltinShadowMode, DefMap, LocalDefMap, MacroSubNs, ModuleData,
ModuleOrigin, ResolveMode,
proc_macro::{ProcMacroDef, ProcMacroKind, parse_macro_name_and_helper_attrs},
sub_namespace_match,
},
path::{ImportAlias, ModPath, PathKind},
per_ns::{Item, PerNs},
tt,
visibility::{RawVisibility, Visibility},
AdtId, AstId, AstIdWithPath, ConstLoc, CrateRootModuleId, EnumLoc, EnumVariantLoc,
ExternBlockLoc, ExternCrateId, ExternCrateLoc, FunctionId, FunctionLoc, ImplLoc, Intern,
ItemContainerId, LocalModuleId, Lookup, Macro2Id, Macro2Loc, MacroExpander, MacroId,
MacroRulesId, MacroRulesLoc, MacroRulesLocFlags, ModuleDefId, ModuleId, ProcMacroId,
ProcMacroLoc, StaticLoc, StructLoc, TraitAliasLoc, TraitLoc, TypeAliasLoc, UnionLoc,
UnresolvedMacro, UseId, UseLoc,
};
const GLOB_RECURSION_LIMIT: usize = 100;

View file

@ -3,15 +3,15 @@
use std::ops::Not;
use cfg::{CfgExpr, CfgOptions};
use hir_expand::{attrs::AttrId, ExpandErrorKind, MacroCallKind};
use hir_expand::{ExpandErrorKind, MacroCallKind, attrs::AttrId};
use la_arena::Idx;
use syntax::ast;
use crate::{
AstId,
item_tree::{self, AttrOwner, ItemTreeId, TreeId},
nameres::LocalModuleId,
path::ModPath,
AstId,
};
#[derive(Debug, PartialEq, Eq)]

View file

@ -1,10 +1,10 @@
//! This module resolves `mod foo;` declaration to file.
use arrayvec::ArrayVec;
use base_db::{AnchoredPath, RootQueryDb};
use hir_expand::{name::Name, HirFileIdExt};
use hir_expand::{HirFileIdExt, name::Name};
use span::EditionedFileId;
use crate::{db::DefDatabase, HirFileId};
use crate::{HirFileId, db::DefDatabase};
const MOD_DEPTH_LIMIT: usize = 32;

View file

@ -11,19 +11,19 @@
//! `ReachedFixedPoint` signals about this.
use either::Either;
use hir_expand::{name::Name, Lookup};
use hir_expand::{Lookup, name::Name};
use span::Edition;
use triomphe::Arc;
use crate::{
AdtId, LocalModuleId, ModuleDefId,
db::DefDatabase,
item_scope::{ImportOrExternCrate, BUILTIN_SCOPE},
item_scope::{BUILTIN_SCOPE, ImportOrExternCrate},
item_tree::FieldsShape,
nameres::{sub_namespace_match, BlockInfo, BuiltinShadowMode, DefMap, LocalDefMap, MacroSubNs},
nameres::{BlockInfo, BuiltinShadowMode, DefMap, LocalDefMap, MacroSubNs, sub_namespace_match},
path::{ModPath, PathKind},
per_ns::PerNs,
visibility::{RawVisibility, Visibility},
AdtId, LocalModuleId, ModuleDefId,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -356,7 +356,7 @@ impl DefMap {
PathKind::Abs => match self.resolve_path_abs(local_def_map, &mut segments, path) {
Either::Left(it) => it,
Either::Right(reached_fixed_point) => {
return ResolvePathResult::empty(reached_fixed_point)
return ResolvePathResult::empty(reached_fixed_point);
}
},
};
@ -402,11 +402,11 @@ impl DefMap {
PathKind::Abs => match self.resolve_path_abs(local_def_map, &mut segments, path) {
Either::Left(it) => it,
Either::Right(reached_fixed_point) => {
return ResolvePathResult::empty(reached_fixed_point)
return ResolvePathResult::empty(reached_fixed_point);
}
},
PathKind::DollarCrate(_) | PathKind::Crate | PathKind::Super(_) => {
return ResolvePathResult::empty(ReachedFixedPoint::Yes)
return ResolvePathResult::empty(ReachedFixedPoint::Yes);
}
};

View file

@ -5,7 +5,7 @@ mod mod_resolution;
mod primitives;
use base_db::RootQueryDb;
use expect_test::{expect, Expect};
use expect_test::{Expect, expect};
use test_fixture::WithFixture;
use triomphe::Arc;

View file

@ -7,7 +7,7 @@ use span::Edition;
use test_fixture::WithFixture;
use triomphe::Arc;
use crate::{db::DefDatabase, nameres::tests::TestDB, AdtId, ModuleDefId};
use crate::{AdtId, ModuleDefId, db::DefDatabase, nameres::tests::TestDB};
fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change: &str) {
let (mut db, pos) = TestDB::with_position(ra_fixture_initial);

View file

@ -19,7 +19,7 @@ use span::Edition;
use stdx::thin_vec::thin_vec_with_header_struct;
use syntax::ast;
pub use hir_expand::mod_path::{path, ModPath, PathKind};
pub use hir_expand::mod_path::{ModPath, PathKind, path};
pub use lower::hir_segment_to_ast_segment;

View file

@ -8,7 +8,7 @@ use hir_expand::{
mod_path::resolve_crate_root,
name::{AsName, Name},
};
use intern::{sym, Interned};
use intern::{Interned, sym};
use stdx::thin_vec::EmptyOptimizedThinVec;
use syntax::ast::{self, AstNode, HasGenericArgs, HasTypeBounds};

View file

@ -1,4 +1,4 @@
use expect_test::{expect, Expect};
use expect_test::{Expect, expect};
use span::Edition;
use syntax::ast::{self, make};
use test_fixture::WithFixture;
@ -6,8 +6,8 @@ use test_fixture::WithFixture;
use crate::{
lower::LowerCtx,
path::{
lower::{hir_segment_to_ast_segment, SEGMENT_LOWERING_MAP},
Path,
lower::{SEGMENT_LOWERING_MAP, hir_segment_to_ast_segment},
},
pretty,
test_db::TestDB,

View file

@ -6,9 +6,9 @@
use bitflags::bitflags;
use crate::{
MacroId, ModuleDefId,
item_scope::{ImportId, ImportOrExternCrate, ImportOrGlob, ItemInNs},
visibility::Visibility,
MacroId, ModuleDefId,
};
#[derive(PartialEq, Eq, Hash, Copy, Clone, Debug)]
@ -146,11 +146,7 @@ impl PerNs {
}
pub fn or_else(self, f: impl FnOnce() -> PerNs) -> PerNs {
if self.is_full() {
self
} else {
self.or(f())
}
if self.is_full() { self } else { self.or(f()) }
}
pub fn iter_items(self) -> impl Iterator<Item = (ItemInNs, Option<ImportOrExternCrate>)> {

View file

@ -2,36 +2,36 @@
use std::{fmt, iter, mem};
use base_db::Crate;
use hir_expand::{name::Name, MacroDefId};
use intern::{sym, Symbol};
use hir_expand::{MacroDefId, name::Name};
use intern::{Symbol, sym};
use itertools::Itertools as _;
use rustc_hash::FxHashSet;
use smallvec::{smallvec, SmallVec};
use smallvec::{SmallVec, smallvec};
use span::SyntaxContext;
use triomphe::Arc;
use crate::{
AdtId, ConstId, ConstParamId, CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId,
ExternBlockId, ExternCrateId, FunctionId, FxIndexMap, GenericDefId, GenericParamId, HasModule,
ImplId, ItemContainerId, ItemTreeLoc, LifetimeParamId, LocalModuleId, Lookup, Macro2Id,
MacroId, MacroRulesId, ModuleDefId, ModuleId, ProcMacroId, StaticId, StructId, TraitAliasId,
TraitId, TypeAliasId, TypeOrConstParamId, TypeOwnerId, TypeParamId, UseId, VariantId,
builtin_type::BuiltinType,
data::ExternCrateDeclData,
db::DefDatabase,
expr_store::{
scope::{ExprScopes, ScopeId},
HygieneId,
scope::{ExprScopes, ScopeId},
},
generics::{GenericParams, TypeOrConstParamData},
hir::{BindingId, ExprId, LabelId},
item_scope::{BuiltinShadowMode, ImportOrExternCrate, ImportOrGlob, BUILTIN_SCOPE},
item_scope::{BUILTIN_SCOPE, BuiltinShadowMode, ImportOrExternCrate, ImportOrGlob},
lang_item::LangItemTarget,
nameres::{DefMap, LocalDefMap, MacroSubNs, ResolvePathResultPrefixInfo},
path::{ModPath, Path, PathKind},
per_ns::PerNs,
type_ref::{LifetimeRef, TypesMap},
visibility::{RawVisibility, Visibility},
AdtId, ConstId, ConstParamId, CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId,
ExternBlockId, ExternCrateId, FunctionId, FxIndexMap, GenericDefId, GenericParamId, HasModule,
ImplId, ItemContainerId, ItemTreeLoc, LifetimeParamId, LocalModuleId, Lookup, Macro2Id,
MacroId, MacroRulesId, ModuleDefId, ModuleId, ProcMacroId, StaticId, StructId, TraitAliasId,
TraitId, TypeAliasId, TypeOrConstParamId, TypeOwnerId, TypeParamId, UseId, VariantId,
};
#[derive(Debug, Clone)]
@ -209,11 +209,7 @@ impl Resolver {
}
let remaining_idx = || {
if path.segments().len() == 1 {
None
} else {
Some(1)
}
if path.segments().len() == 1 { None } else { Some(1) }
};
for scope in self.scopes() {

View file

@ -3,13 +3,13 @@
use either::Either;
use hir_expand::InFile;
use la_arena::ArenaMap;
use syntax::{ast, AstNode, AstPtr};
use syntax::{AstNode, AstPtr, ast};
use crate::{
db::DefDatabase,
item_tree::{AttrOwner, FieldParent, ItemTreeNode},
GenericDefId, ItemTreeLoc, LocalFieldId, LocalLifetimeParamId, LocalTypeOrConstParamId, Lookup,
UseId, VariantId,
db::DefDatabase,
item_tree::{AttrOwner, FieldParent, ItemTreeNode},
};
pub trait HasSource {

View file

@ -6,17 +6,17 @@ use base_db::{
Crate, CrateGraphBuilder, CratesMap, FileSourceRootInput, FileText, RootQueryDb,
SourceDatabase, SourceRoot, SourceRootId, SourceRootInput, Upcast,
};
use hir_expand::{db::ExpandDatabase, files::FilePosition, InFile};
use hir_expand::{InFile, db::ExpandDatabase, files::FilePosition};
use salsa::{AsDynDatabase, Durability};
use span::{EditionedFileId, FileId};
use syntax::{algo, ast, AstNode};
use syntax::{AstNode, algo, ast};
use triomphe::Arc;
use crate::{
LocalModuleId, Lookup, ModuleDefId, ModuleId,
db::DefDatabase,
nameres::{DefMap, ModuleSource},
src::HasSource,
LocalModuleId, Lookup, ModuleDefId, ModuleId,
};
#[salsa::db]

View file

@ -9,11 +9,11 @@ use syntax::ast;
use triomphe::Arc;
use crate::{
ConstId, FunctionId, HasModule, LocalFieldId, LocalModuleId, ModuleId, VariantId,
db::DefDatabase,
nameres::DefMap,
path::{ModPath, PathKind},
resolver::HasResolver,
ConstId, FunctionId, HasModule, LocalFieldId, LocalModuleId, ModuleId, VariantId,
};
/// Visibility of an item, not yet resolved.