Skip to content

Commit 202b51b

Browse files
committed
a lot of clippy::style fixes
1 parent ae7e55c commit 202b51b

File tree

19 files changed

+52
-69
lines changed

19 files changed

+52
-69
lines changed

crates/base_db/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl CrateId {
410410

411411
impl CrateData {
412412
fn add_dep(&mut self, name: CrateName, crate_id: CrateId) {
413-
self.dependencies.push(Dependency { name, crate_id })
413+
self.dependencies.push(Dependency { crate_id, name })
414414
}
415415
}
416416

crates/cfg/src/dnf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ impl Builder {
255255
fn make_dnf(expr: CfgExpr) -> CfgExpr {
256256
match expr {
257257
CfgExpr::Invalid | CfgExpr::Atom(_) | CfgExpr::Not(_) => expr,
258-
CfgExpr::Any(e) => CfgExpr::Any(e.into_iter().map(|expr| make_dnf(expr)).collect()),
258+
CfgExpr::Any(e) => CfgExpr::Any(e.into_iter().map(make_dnf).collect()),
259259
CfgExpr::All(e) => {
260-
let e = e.into_iter().map(|expr| make_nnf(expr)).collect::<Vec<_>>();
260+
let e = e.into_iter().map(make_nnf).collect::<Vec<_>>();
261261

262262
CfgExpr::Any(distribute_conj(&e))
263263
}
@@ -300,8 +300,8 @@ fn distribute_conj(conj: &[CfgExpr]) -> Vec<CfgExpr> {
300300
fn make_nnf(expr: CfgExpr) -> CfgExpr {
301301
match expr {
302302
CfgExpr::Invalid | CfgExpr::Atom(_) => expr,
303-
CfgExpr::Any(expr) => CfgExpr::Any(expr.into_iter().map(|expr| make_nnf(expr)).collect()),
304-
CfgExpr::All(expr) => CfgExpr::All(expr.into_iter().map(|expr| make_nnf(expr)).collect()),
303+
CfgExpr::Any(expr) => CfgExpr::Any(expr.into_iter().map(make_nnf).collect()),
304+
CfgExpr::All(expr) => CfgExpr::All(expr.into_iter().map(make_nnf).collect()),
305305
CfgExpr::Not(operand) => match *operand {
306306
CfgExpr::Invalid | CfgExpr::Atom(_) => CfgExpr::Not(operand.clone()), // Original negated expr
307307
CfgExpr::Not(expr) => {

crates/mbe/src/expander/matcher.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl BindingsBuilder {
304304
link_nodes: &'a Vec<LinkNode<Rc<BindingKind>>>,
305305
nodes: &mut Vec<&'a Rc<BindingKind>>,
306306
) {
307-
link_nodes.into_iter().for_each(|it| match it {
307+
link_nodes.iter().for_each(|it| match it {
308308
LinkNode::Node(it) => nodes.push(it),
309309
LinkNode::Parent { idx, len } => self.collect_nodes_ref(*idx, *len, nodes),
310310
});
@@ -713,10 +713,9 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
713713
.map(|ident| Some(tt::Leaf::from(ident.clone()).into()))
714714
.map_err(|()| err!("expected ident")),
715715
"tt" => input.expect_tt().map(Some).map_err(|()| err!()),
716-
"lifetime" => input
717-
.expect_lifetime()
718-
.map(|tt| Some(tt))
719-
.map_err(|()| err!("expected lifetime")),
716+
"lifetime" => {
717+
input.expect_lifetime().map(Some).map_err(|()| err!("expected lifetime"))
718+
}
720719
"literal" => {
721720
let neg = input.eat_char('-');
722721
input

crates/mbe/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,6 @@ impl<T> ExpandResult<T> {
356356

357357
impl<T: Default> From<Result<T, ExpandError>> for ExpandResult<T> {
358358
fn from(result: Result<T, ExpandError>) -> Self {
359-
result.map_or_else(|e| Self::only_err(e), |it| Self::ok(it))
359+
result.map_or_else(Self::only_err, Self::ok)
360360
}
361361
}

crates/mbe/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'a> Iterator for OpDelimitedIter<'a> {
5757

5858
fn size_hint(&self) -> (usize, Option<usize>) {
5959
let len = self.inner.len() + if self.delimited.is_some() { 2 } else { 0 };
60-
let remain = len.checked_sub(self.idx).unwrap_or(0);
60+
let remain = len.saturating_sub(self.idx);
6161
(remain, Some(remain))
6262
}
6363
}

crates/mbe/src/syntax_bridge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ trait TokenConvertor {
362362
if let Some((kind, closed)) = delim {
363363
let mut subtree = tt::Subtree::default();
364364
let (id, idx) = self.id_alloc().open_delim(range);
365-
subtree.delimiter = Some(tt::Delimiter { kind, id });
365+
subtree.delimiter = Some(tt::Delimiter { id, kind });
366366

367367
while self.peek().map(|it| it.kind() != closed).unwrap_or(false) {
368368
self.collect_leaf(&mut subtree.token_trees);

crates/rust-analyzer/src/main_loop.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,8 @@ impl GlobalState {
242242
}
243243
BuildDataProgress::End(collector) => {
244244
self.fetch_build_data_completed();
245-
let workspaces = (*self.workspaces)
246-
.clone()
247-
.into_iter()
248-
.map(|it| Ok(it))
249-
.collect();
245+
let workspaces =
246+
(*self.workspaces).clone().into_iter().map(Ok).collect();
250247
self.switch_workspaces(workspaces, Some(collector));
251248
(Some(Progress::End), None)
252249
}

crates/rust-analyzer/src/reload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl GlobalState {
237237
None => None,
238238
};
239239

240-
if &*self.workspaces == &workspaces && self.workspace_build_data == workspace_build_data {
240+
if *self.workspaces == workspaces && self.workspace_build_data == workspace_build_data {
241241
return;
242242
}
243243

crates/rust-analyzer/tests/rust-analyzer/support.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a> Project<'a> {
5454
}
5555

5656
pub(crate) fn server(self) -> Server {
57-
let tmp_dir = self.tmp_dir.unwrap_or_else(|| TestDir::new());
57+
let tmp_dir = self.tmp_dir.unwrap_or_else(TestDir::new);
5858
static INIT: Once = Once::new();
5959
INIT.call_once(|| {
6060
env_logger::builder().is_test(true).parse_env("RA_LOG").try_init().unwrap();

crates/syntax/src/ast/edit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl IndentLevel {
595595
pub fn from_node(node: &SyntaxNode) -> IndentLevel {
596596
match node.first_token() {
597597
Some(it) => Self::from_token(&it),
598-
None => return IndentLevel(0),
598+
None => IndentLevel(0),
599599
}
600600
}
601601

0 commit comments

Comments
 (0)