Skip to content

Commit 7535bb4

Browse files
cargo fmt
1 parent 87f837c commit 7535bb4

File tree

571 files changed

+2182
-2430
lines changed

Some content is hidden

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

571 files changed

+2182
-2430
lines changed

Diff for: crates/base-db/src/change.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,5 @@ impl FileChange {
8282
}
8383

8484
fn durability(source_root: &SourceRoot) -> Durability {
85-
if source_root.is_library {
86-
Durability::HIGH
87-
} else {
88-
Durability::LOW
89-
}
85+
if source_root.is_library { Durability::HIGH } else { Durability::LOW }
9086
}

Diff for: crates/base-db/src/input.rs

+48-36
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ use std::hash::BuildHasherDefault;
1010
use std::{fmt, mem, ops};
1111

1212
use cfg::{CfgOptions, HashableCfgOptions};
13-
use dashmap::mapref::entry::Entry;
1413
use dashmap::DashMap;
14+
use dashmap::mapref::entry::Entry;
1515
use intern::Symbol;
1616
use la_arena::{Arena, Idx, RawIdx};
1717
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
1818
use salsa::{Durability, Setter};
1919
use span::{Edition, EditionedFileId};
2020
use triomphe::Arc;
21-
use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath};
21+
use vfs::{AbsPathBuf, AnchoredPath, FileId, VfsPath, file_set::FileSet};
2222

2323
use crate::{CrateWorkspaceData, RootQueryDb};
2424

@@ -110,11 +110,7 @@ impl CrateName {
110110
/// Dashes are not allowed in the crate names,
111111
/// hence the input string is returned as `Err` for those cases.
112112
pub fn new(name: &str) -> Result<CrateName, &str> {
113-
if name.contains('-') {
114-
Err(name)
115-
} else {
116-
Ok(Self(Symbol::intern(name)))
117-
}
113+
if name.contains('-') { Err(name) } else { Ok(Self(Symbol::intern(name))) }
118114
}
119115

120116
/// Creates a crate name, unconditionally replacing the dashes with underscores.
@@ -922,15 +918,21 @@ mod tests {
922918
None,
923919
empty_ws_data(),
924920
);
925-
assert!(graph
926-
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
927-
.is_ok());
928-
assert!(graph
929-
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate3").unwrap(), crate3,))
930-
.is_ok());
931-
assert!(graph
932-
.add_dep(crate3, DependencyBuilder::new(CrateName::new("crate1").unwrap(), crate1,))
933-
.is_err());
921+
assert!(
922+
graph
923+
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
924+
.is_ok()
925+
);
926+
assert!(
927+
graph
928+
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate3").unwrap(), crate3,))
929+
.is_ok()
930+
);
931+
assert!(
932+
graph
933+
.add_dep(crate3, DependencyBuilder::new(CrateName::new("crate1").unwrap(), crate1,))
934+
.is_err()
935+
);
934936
}
935937

936938
#[test]
@@ -962,12 +964,16 @@ mod tests {
962964
None,
963965
empty_ws_data(),
964966
);
965-
assert!(graph
966-
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
967-
.is_ok());
968-
assert!(graph
969-
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
970-
.is_err());
967+
assert!(
968+
graph
969+
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
970+
.is_ok()
971+
);
972+
assert!(
973+
graph
974+
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
975+
.is_err()
976+
);
971977
}
972978

973979
#[test]
@@ -1012,12 +1018,16 @@ mod tests {
10121018
None,
10131019
empty_ws_data(),
10141020
);
1015-
assert!(graph
1016-
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
1017-
.is_ok());
1018-
assert!(graph
1019-
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate3").unwrap(), crate3,))
1020-
.is_ok());
1021+
assert!(
1022+
graph
1023+
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
1024+
.is_ok()
1025+
);
1026+
assert!(
1027+
graph
1028+
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate3").unwrap(), crate3,))
1029+
.is_ok()
1030+
);
10211031
}
10221032

10231033
#[test]
@@ -1049,15 +1059,17 @@ mod tests {
10491059
None,
10501060
empty_ws_data(),
10511061
);
1052-
assert!(graph
1053-
.add_dep(
1054-
crate1,
1055-
DependencyBuilder::new(
1056-
CrateName::normalize_dashes("crate-name-with-dashes"),
1057-
crate2,
1062+
assert!(
1063+
graph
1064+
.add_dep(
1065+
crate1,
1066+
DependencyBuilder::new(
1067+
CrateName::normalize_dashes("crate-name-with-dashes"),
1068+
crate2,
1069+
)
10581070
)
1059-
)
1060-
.is_ok());
1071+
.is_ok()
1072+
);
10611073
assert_eq!(
10621074
graph.arena[crate1].basic.dependencies,
10631075
vec![

Diff for: crates/base-db/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ pub use crate::{
1414
SourceRoot, SourceRootId, TargetLayoutLoadResult, UniqueCrateData,
1515
},
1616
};
17-
use dashmap::{mapref::entry::Entry, DashMap};
17+
use dashmap::{DashMap, mapref::entry::Entry};
1818
pub use query_group::{self};
1919
use rustc_hash::{FxHashSet, FxHasher};
2020
pub use salsa::{self};
2121
use salsa::{Durability, Setter};
2222
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
23-
use syntax::{ast, Parse, SyntaxError};
23+
use syntax::{Parse, SyntaxError, ast};
2424
use triomphe::Arc;
25-
pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, FileId, VfsPath};
25+
pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet};
2626

2727
#[macro_export]
2828
macro_rules! impl_intern_key {

Diff for: crates/cfg/src/lib.rs

+1-1
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;

Diff for: crates/cfg/src/tests.rs

+5-4
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};

Diff for: crates/hir-def/src/attr.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ use base_db::Crate;
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 rustc_abi::ReprOptions;
1616
use syntax::{
17-
ast::{self, HasAttrs},
1817
AstPtr,
18+
ast::{self, HasAttrs},
1919
};
2020
use triomphe::Arc;
2121
use tt::iter::{TtElement, TtIter};
2222

2323
use crate::{
24+
AdtId, AttrDefId, GenericParamId, HasModule, ItemTreeLoc, LocalFieldId, Lookup, MacroId,
25+
VariantId,
2426
db::DefDatabase,
2527
item_tree::{AttrOwner, FieldParent, ItemTreeNode},
2628
lang_item::LangItem,
2729
nameres::{ModuleOrigin, ModuleSource},
2830
src::{HasChildSource, HasSource},
29-
AdtId, AttrDefId, GenericParamId, HasModule, ItemTreeLoc, LocalFieldId, Lookup, MacroId,
30-
VariantId,
3131
};
3232

3333
/// Desugared attributes of an item post `cfg_attr` expansion.
@@ -770,8 +770,8 @@ mod tests {
770770

771771
use hir_expand::span_map::{RealSpanMap, SpanMap};
772772
use span::FileId;
773-
use syntax::{ast, AstNode, TextRange};
774-
use syntax_bridge::{syntax_node_to_token_tree, DocCommentDesugarMode};
773+
use syntax::{AstNode, TextRange, ast};
774+
use syntax_bridge::{DocCommentDesugarMode, syntax_node_to_token_tree};
775775

776776
use crate::attr::{DocAtom, DocExpr};
777777

Diff for: crates/hir-def/src/builtin_type.rs

+1-1
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 {

Diff for: crates/hir-def/src/data.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ pub mod adt;
44

55
use base_db::Crate;
66
use hir_expand::name::Name;
7-
use intern::{sym, Symbol};
7+
use intern::{Symbol, sym};
88
use la_arena::{Idx, RawIdx};
99
use triomphe::Arc;
1010

1111
use crate::{
12+
ConstId, ExternCrateId, FunctionId, HasModule, ImplId, ItemContainerId, ItemLoc, Lookup,
13+
Macro2Id, MacroRulesId, ProcMacroId, StaticId, TraitAliasId, TraitId, TypeAliasId,
1214
db::DefDatabase,
1315
item_tree::{self, FnFlags, ModItem},
14-
nameres::proc_macro::{parse_macro_name_and_helper_attrs, ProcMacroKind},
16+
nameres::proc_macro::{ProcMacroKind, parse_macro_name_and_helper_attrs},
1517
path::ImportAlias,
1618
type_ref::{TraitRef, TypeBound, TypeRefId, TypesMap},
1719
visibility::RawVisibility,
18-
ConstId, ExternCrateId, FunctionId, HasModule, ImplId, ItemContainerId, ItemLoc, Lookup,
19-
Macro2Id, MacroRulesId, ProcMacroId, StaticId, TraitAliasId, TraitId, TypeAliasId,
2020
};
2121

2222
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -431,11 +431,7 @@ impl ExternCrateDeclData {
431431
Some(krate)
432432
} else {
433433
krate.data(db).dependencies.iter().find_map(|dep| {
434-
if dep.name.symbol() == name.symbol() {
435-
Some(dep.crate_id)
436-
} else {
437-
None
438-
}
434+
if dep.name.symbol() == name.symbol() { Some(dep.crate_id) } else { None }
439435
})
440436
};
441437

Diff for: crates/hir-def/src/data/adt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_abi::{IntegerType, ReprOptions};
1111
use triomphe::Arc;
1212

1313
use crate::{
14+
EnumId, EnumVariantId, LocalFieldId, LocalModuleId, Lookup, StructId, UnionId, VariantId,
1415
db::DefDatabase,
1516
hir::Expr,
1617
item_tree::{
@@ -20,7 +21,6 @@ use crate::{
2021
nameres::diagnostics::{DefDiagnostic, DefDiagnostics},
2122
type_ref::{TypeRefId, TypesMap},
2223
visibility::RawVisibility,
23-
EnumId, EnumVariantId, LocalFieldId, LocalModuleId, Lookup, StructId, UnionId, VariantId,
2424
};
2525

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

Diff for: crates/hir-def/src/db.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
//! Defines database & queries for name resolution.
22
use base_db::{Crate, RootQueryDb, SourceDatabase, Upcast};
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, EnumVariants, StructData, VariantData},
1521
ConstData, ExternCrateDeclData, FunctionData, ImplData, Macro2Data, MacroRulesData,
1622
ProcMacroData, StaticData, TraitAliasData, TraitData, TypeAliasData,
23+
adt::{EnumData, EnumVariantData, EnumVariants, 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},
2330
nameres::{
31+
DefMap, LocalDefMap,
2432
assoc::{ImplItems, TraitItems},
2533
diagnostics::DefDiagnostics,
26-
DefMap, LocalDefMap,
2734
},
2835
tt,
2936
type_ref::TypesSourceMap,
3037
visibility::{self, Visibility},
31-
AttrDefId, BlockId, BlockLoc, ConstBlockId, ConstBlockLoc, ConstId, ConstLoc, DefWithBodyId,
32-
EnumId, EnumLoc, EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId,
33-
ExternCrateLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, InTypeConstId,
34-
InTypeConstLoc, LocalFieldId, Macro2Id, Macro2Loc, MacroId, MacroRulesId, MacroRulesLoc,
35-
MacroRulesLocFlags, ProcMacroId, ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc,
36-
TraitAliasId, TraitAliasLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc,
37-
UseId, UseLoc, VariantId,
3838
};
3939

4040
use salsa::plumbing::AsId;
@@ -337,7 +337,7 @@ fn crate_supports_no_std(db: &dyn DefDatabase, crate_id: Crate) -> bool {
337337
for output in segments.skip(1) {
338338
match output.flat_tokens() {
339339
[tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] if ident.sym == sym::no_std => {
340-
return true
340+
return true;
341341
}
342342
_ => {}
343343
}

Diff for: crates/hir-def/src/dyn_map.rs

+3-3
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)