Skip to content

Commit b653a0a

Browse files
cargo fmt
1 parent e121545 commit b653a0a

File tree

583 files changed

+2248
-2507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

583 files changed

+2248
-2507
lines changed

crates/base-db/src/change.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,5 @@ impl FileChange {
9090
}
9191

9292
fn durability(source_root: &SourceRoot) -> Durability {
93-
if source_root.is_library {
94-
Durability::HIGH
95-
} else {
96-
Durability::LOW
97-
}
93+
if source_root.is_library { Durability::HIGH } else { Durability::LOW }
9894
}

crates/base-db/src/input.rs

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use la_arena::{Arena, Idx, RawIdx};
1414
use rustc_hash::{FxHashMap, FxHashSet};
1515
use span::{Edition, EditionedFileId};
1616
use triomphe::Arc;
17-
use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath};
17+
use vfs::{AbsPathBuf, AnchoredPath, FileId, VfsPath, file_set::FileSet};
1818

1919
pub type ProcMacroPaths = FxHashMap<CrateId, Result<(String, AbsPathBuf), String>>;
2020

@@ -105,11 +105,7 @@ impl CrateName {
105105
/// Dashes are not allowed in the crate names,
106106
/// hence the input string is returned as `Err` for those cases.
107107
pub fn new(name: &str) -> Result<CrateName, &str> {
108-
if name.contains('-') {
109-
Err(name)
110-
} else {
111-
Ok(Self(Symbol::intern(name)))
112-
}
108+
if name.contains('-') { Err(name) } else { Ok(Self(Symbol::intern(name))) }
113109
}
114110

115111
/// Creates a crate name, unconditionally replacing the dashes with underscores.
@@ -731,15 +727,21 @@ mod tests {
731727
false,
732728
None,
733729
);
734-
assert!(graph
735-
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,))
736-
.is_ok());
737-
assert!(graph
738-
.add_dep(crate2, Dependency::new(CrateName::new("crate3").unwrap(), crate3,))
739-
.is_ok());
740-
assert!(graph
741-
.add_dep(crate3, Dependency::new(CrateName::new("crate1").unwrap(), crate1,))
742-
.is_err());
730+
assert!(
731+
graph
732+
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,))
733+
.is_ok()
734+
);
735+
assert!(
736+
graph
737+
.add_dep(crate2, Dependency::new(CrateName::new("crate3").unwrap(), crate3,))
738+
.is_ok()
739+
);
740+
assert!(
741+
graph
742+
.add_dep(crate3, Dependency::new(CrateName::new("crate1").unwrap(), crate1,))
743+
.is_err()
744+
);
743745
}
744746

745747
#[test]
@@ -769,12 +771,16 @@ mod tests {
769771
false,
770772
None,
771773
);
772-
assert!(graph
773-
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,))
774-
.is_ok());
775-
assert!(graph
776-
.add_dep(crate2, Dependency::new(CrateName::new("crate2").unwrap(), crate2,))
777-
.is_err());
774+
assert!(
775+
graph
776+
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,))
777+
.is_ok()
778+
);
779+
assert!(
780+
graph
781+
.add_dep(crate2, Dependency::new(CrateName::new("crate2").unwrap(), crate2,))
782+
.is_err()
783+
);
778784
}
779785

780786
#[test]
@@ -816,12 +822,16 @@ mod tests {
816822
false,
817823
None,
818824
);
819-
assert!(graph
820-
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,))
821-
.is_ok());
822-
assert!(graph
823-
.add_dep(crate2, Dependency::new(CrateName::new("crate3").unwrap(), crate3,))
824-
.is_ok());
825+
assert!(
826+
graph
827+
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2,))
828+
.is_ok()
829+
);
830+
assert!(
831+
graph
832+
.add_dep(crate2, Dependency::new(CrateName::new("crate3").unwrap(), crate3,))
833+
.is_ok()
834+
);
825835
}
826836

827837
#[test]
@@ -851,12 +861,14 @@ mod tests {
851861
false,
852862
None,
853863
);
854-
assert!(graph
855-
.add_dep(
856-
crate1,
857-
Dependency::new(CrateName::normalize_dashes("crate-name-with-dashes"), crate2,)
858-
)
859-
.is_ok());
864+
assert!(
865+
graph
866+
.add_dep(
867+
crate1,
868+
Dependency::new(CrateName::normalize_dashes("crate-name-with-dashes"), crate2,)
869+
)
870+
.is_ok()
871+
);
860872
assert_eq!(
861873
graph[crate1].dependencies,
862874
vec![Dependency::new(CrateName::new("crate_name_with_dashes").unwrap(), crate2,)]

crates/base-db/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::panic;
88
use ra_salsa::Durability;
99
use rustc_hash::FxHashMap;
1010
use span::EditionedFileId;
11-
use syntax::{ast, Parse, SourceFile, SyntaxError};
11+
use syntax::{Parse, SourceFile, SyntaxError, ast};
1212
use triomphe::Arc;
1313
use vfs::FileId;
1414

@@ -21,7 +21,7 @@ pub use crate::{
2121
},
2222
};
2323
pub use ra_salsa::{self, Cancelled};
24-
pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, VfsPath};
24+
pub use vfs::{AnchoredPath, AnchoredPathBuf, VfsPath, file_set::FileSet};
2525

2626
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
2727

crates/cfg/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::fmt;
99

1010
use rustc_hash::FxHashSet;
1111

12-
use intern::{sym, Symbol};
12+
use intern::{Symbol, sym};
1313

1414
pub use cfg_expr::{CfgAtom, CfgExpr};
1515
pub use dnf::DnfExpr;

crates/cfg/src/tests.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use arbitrary::{Arbitrary, Unstructured};
2-
use expect_test::{expect, Expect};
2+
use expect_test::{Expect, expect};
33
use intern::Symbol;
4-
use syntax::{ast, AstNode, Edition};
4+
use syntax::{AstNode, Edition, ast};
55
use syntax_bridge::{
6-
dummy_test_span_utils::{DummyTestSpanMap, DUMMY},
7-
syntax_node_to_token_tree, DocCommentDesugarMode,
6+
DocCommentDesugarMode,
7+
dummy_test_span_utils::{DUMMY, DummyTestSpanMap},
8+
syntax_node_to_token_tree,
89
};
910

1011
use crate::{CfgAtom, CfgExpr, CfgOptions, DnfExpr};

crates/hir-def/src/attr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ use base_db::CrateId;
66
use cfg::{CfgExpr, CfgOptions};
77
use either::Either;
88
use hir_expand::{
9-
attrs::{collect_attrs, Attr, AttrId, RawAttrs},
109
HirFileId, InFile,
10+
attrs::{Attr, AttrId, RawAttrs, collect_attrs},
1111
};
12-
use intern::{sym, Symbol};
12+
use intern::{Symbol, sym};
1313
use la_arena::{ArenaMap, Idx, RawIdx};
1414
use mbe::DelimiterKind;
1515
use syntax::{
16-
ast::{self, HasAttrs},
1716
AstPtr,
17+
ast::{self, HasAttrs},
1818
};
1919
use triomphe::Arc;
2020
use tt::iter::{TtElement, TtIter};
2121

2222
use crate::{
23+
AdtId, AttrDefId, GenericParamId, HasModule, ItemTreeLoc, LocalFieldId, Lookup, MacroId,
24+
VariantId,
2325
db::DefDatabase,
2426
item_tree::{AttrOwner, FieldParent, ItemTreeNode},
2527
lang_item::LangItem,
2628
nameres::{ModuleOrigin, ModuleSource},
2729
src::{HasChildSource, HasSource},
28-
AdtId, AttrDefId, GenericParamId, HasModule, ItemTreeLoc, LocalFieldId, Lookup, MacroId,
29-
VariantId,
3030
};
3131

3232
/// Desugared attributes of an item post `cfg_attr` expansion.
@@ -649,8 +649,8 @@ mod tests {
649649

650650
use hir_expand::span_map::{RealSpanMap, SpanMap};
651651
use span::FileId;
652-
use syntax::{ast, AstNode, TextRange};
653-
use syntax_bridge::{syntax_node_to_token_tree, DocCommentDesugarMode};
652+
use syntax::{AstNode, TextRange, ast};
653+
use syntax_bridge::{DocCommentDesugarMode, syntax_node_to_token_tree};
654654

655655
use crate::attr::{DocAtom, DocExpr};
656656

crates/hir-def/src/builtin_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use std::fmt;
77

88
use hir_expand::name::{AsName, Name};
9-
use intern::{sym, Symbol};
9+
use intern::{Symbol, sym};
1010
/// Different signed int types.
1111
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1212
pub enum BuiltinInt {

crates/hir-def/src/data.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ pub mod adt;
44

55
use base_db::CrateId;
66
use hir_expand::{
7-
name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefKind,
7+
AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefKind, name::Name,
88
};
9-
use intern::{sym, Symbol};
9+
use intern::{Symbol, sym};
1010
use la_arena::{Idx, RawIdx};
1111
use smallvec::SmallVec;
12-
use syntax::{ast, Parse};
12+
use syntax::{Parse, ast};
1313
use triomphe::Arc;
1414
use tt::iter::TtElement;
1515

1616
use crate::{
17+
AssocItemId, AstIdWithPath, ConstId, ConstLoc, ExternCrateId, FunctionId, FunctionLoc,
18+
HasModule, ImplId, Intern, ItemContainerId, ItemLoc, Lookup, Macro2Id, MacroRulesId, ModuleId,
19+
ProcMacroId, StaticId, TraitAliasId, TraitId, TypeAliasId, TypeAliasLoc,
1720
db::DefDatabase,
1821
expander::{Expander, Mark},
1922
item_tree::{self, AssocItem, FnFlags, ItemTree, ItemTreeId, MacroCall, ModItem, TreeId},
2023
macro_call_as_call_id,
2124
nameres::{
25+
DefMap, MacroSubNs,
2226
attr_resolution::ResolvedAttr,
2327
diagnostics::{DefDiagnostic, DefDiagnostics},
24-
proc_macro::{parse_macro_name_and_helper_attrs, ProcMacroKind},
25-
DefMap, MacroSubNs,
28+
proc_macro::{ProcMacroKind, parse_macro_name_and_helper_attrs},
2629
},
2730
path::ImportAlias,
2831
type_ref::{TraitRef, TypeBound, TypeRefId, TypesMap},
2932
visibility::RawVisibility,
30-
AssocItemId, AstIdWithPath, ConstId, ConstLoc, ExternCrateId, FunctionId, FunctionLoc,
31-
HasModule, ImplId, Intern, ItemContainerId, ItemLoc, Lookup, Macro2Id, MacroRulesId, ModuleId,
32-
ProcMacroId, StaticId, TraitAliasId, TraitId, TypeAliasId, TypeAliasLoc,
3333
};
3434

3535
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -543,11 +543,7 @@ impl ExternCrateDeclData {
543543
Some(krate)
544544
} else {
545545
db.crate_graph()[krate].dependencies.iter().find_map(|dep| {
546-
if dep.name.symbol() == name.symbol() {
547-
Some(dep.crate_id)
548-
} else {
549-
None
550-
}
546+
if dep.name.symbol() == name.symbol() { Some(dep.crate_id) } else { None }
551547
})
552548
};
553549

crates/hir-def/src/data/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use triomphe::Arc;
1414
use tt::iter::TtElement;
1515

1616
use crate::{
17+
EnumId, EnumVariantId, LocalFieldId, LocalModuleId, Lookup, StructId, UnionId, VariantId,
1718
builtin_type::{BuiltinInt, BuiltinUint},
1819
db::DefDatabase,
1920
hir::Expr,
@@ -25,7 +26,6 @@ use crate::{
2526
tt::{Delimiter, DelimiterKind, Leaf, TopSubtree},
2627
type_ref::{TypeRefId, TypesMap},
2728
visibility::RawVisibility,
28-
EnumId, EnumVariantId, LocalFieldId, LocalModuleId, Lookup, StructId, UnionId, VariantId,
2929
};
3030

3131
/// Note that we use `StructData` for unions as well!

crates/hir-def/src/db.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
//! Defines database & queries for name resolution.
2-
use base_db::{ra_salsa, CrateId, SourceDatabase, Upcast};
2+
use base_db::{CrateId, SourceDatabase, Upcast, ra_salsa};
33
use either::Either;
4-
use hir_expand::{db::ExpandDatabase, HirFileId, MacroDefId};
4+
use hir_expand::{HirFileId, MacroDefId, db::ExpandDatabase};
55
use intern::sym;
66
use la_arena::ArenaMap;
77
use span::{EditionedFileId, MacroCallId};
8-
use syntax::{ast, AstPtr};
8+
use syntax::{AstPtr, ast};
99
use triomphe::Arc;
1010

1111
use crate::{
12+
AttrDefId, BlockId, BlockLoc, ConstBlockId, ConstBlockLoc, ConstId, ConstLoc, DefWithBodyId,
13+
EnumId, EnumLoc, EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId,
14+
ExternCrateLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, InTypeConstId,
15+
InTypeConstLoc, LocalFieldId, Macro2Id, Macro2Loc, MacroId, MacroRulesId, MacroRulesLoc,
16+
MacroRulesLocFlags, ProcMacroId, ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc,
17+
TraitAliasId, TraitAliasLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc,
18+
UseId, UseLoc, VariantId,
1219
attr::{Attrs, AttrsWithOwner},
1320
data::{
14-
adt::{EnumData, EnumVariantData, StructData, VariantData},
1521
ConstData, ExternCrateDeclData, FunctionData, ImplData, Macro2Data, MacroRulesData,
1622
ProcMacroData, StaticData, TraitAliasData, TraitData, TypeAliasData,
23+
adt::{EnumData, EnumVariantData, StructData, VariantData},
1724
},
18-
expr_store::{scope::ExprScopes, Body, BodySourceMap},
25+
expr_store::{Body, BodySourceMap, scope::ExprScopes},
1926
generics::GenericParams,
2027
import_map::ImportMap,
2128
item_tree::{AttrOwner, ItemTree, ItemTreeSourceMaps},
2229
lang_item::{self, LangItem, LangItemTarget, LangItems},
23-
nameres::{diagnostics::DefDiagnostics, DefMap},
30+
nameres::{DefMap, diagnostics::DefDiagnostics},
2431
tt,
2532
type_ref::TypesSourceMap,
2633
visibility::{self, Visibility},
27-
AttrDefId, BlockId, BlockLoc, ConstBlockId, ConstBlockLoc, ConstId, ConstLoc, DefWithBodyId,
28-
EnumId, EnumLoc, EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId,
29-
ExternCrateLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, InTypeConstId,
30-
InTypeConstLoc, LocalFieldId, Macro2Id, Macro2Loc, MacroId, MacroRulesId, MacroRulesLoc,
31-
MacroRulesLocFlags, ProcMacroId, ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc,
32-
TraitAliasId, TraitAliasLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc,
33-
UseId, UseLoc, VariantId,
3434
};
3535

3636
#[ra_salsa::query_group(InternDatabaseStorage)]
@@ -304,7 +304,7 @@ fn crate_supports_no_std(db: &dyn DefDatabase, crate_id: CrateId) -> bool {
304304
for output in segments.skip(1) {
305305
match output.flat_tokens() {
306306
[tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] if ident.sym == sym::no_std => {
307-
return true
307+
return true;
308308
}
309309
_ => {}
310310
}

crates/hir-def/src/dyn_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
pub mod keys {
2828
use std::marker::PhantomData;
2929

30-
use hir_expand::{attrs::AttrId, MacroCallId};
30+
use hir_expand::{MacroCallId, attrs::AttrId};
3131
use rustc_hash::FxHashMap;
32-
use syntax::{ast, AstNode, AstPtr};
32+
use syntax::{AstNode, AstPtr, ast};
3333

3434
use crate::{
35-
dyn_map::{DynMap, Policy},
3635
BlockId, ConstId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId, FieldId, FunctionId,
3736
ImplId, LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId, StaticId, StructId,
3837
TraitAliasId, TraitId, TypeAliasId, TypeOrConstParamId, UnionId, UseId,
38+
dyn_map::{DynMap, Policy},
3939
};
4040

4141
pub type Key<K, V> = crate::dyn_map::Key<AstPtr<K>, V, AstPtrPolicy<K, V>>;

0 commit comments

Comments
 (0)