diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-17 08:12:34 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-17 08:12:34 +0000 |
commit | f7fbea509f1e5f840e715c912ee38aa997d1bfbc (patch) | |
tree | 2b4932678fc83624c278ca93cdf0f1d3a28346c2 /crates/hir_expand/src | |
parent | 6fcb5d772f16af0d1f62dad55fbde75072fb9e89 (diff) | |
parent | ff5f90d8ae2da8e4856d5c78f55e5cd02b178325 (diff) |
Merge #8063
8063: couple clippy::complexity fixes r=matklad a=matthiaskrgr
avoid redundant `.into()` calls to convert T into identical T (`let x: String = String::from("hello").into();`)
use `if let Some(x)` instead of `.is_some()` + `.unwrap()`
don't clone Copy types
remove redundant wrapped ?s: `Some(Some(3)?)` can just be `Some(3)`
use `.map(|x| y)` instead of `and_then(|x| Some(y)` on `Option`s
Co-authored-by: Matthias Krüger <[email protected]>
Diffstat (limited to 'crates/hir_expand/src')
-rw-r--r-- | crates/hir_expand/src/hygiene.rs | 7 | ||||
-rw-r--r-- | crates/hir_expand/src/lib.rs | 4 |
2 files changed, 4 insertions, 7 deletions
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs index c8ea81210..87cad326d 100644 --- a/crates/hir_expand/src/hygiene.rs +++ b/crates/hir_expand/src/hygiene.rs | |||
@@ -23,7 +23,7 @@ pub struct Hygiene { | |||
23 | 23 | ||
24 | impl Hygiene { | 24 | impl Hygiene { |
25 | pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene { | 25 | pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene { |
26 | Hygiene { frames: Some(HygieneFrames::new(db, file_id.clone())) } | 26 | Hygiene { frames: Some(HygieneFrames::new(db, file_id)) } |
27 | } | 27 | } |
28 | 28 | ||
29 | pub fn new_unhygienic() -> Hygiene { | 29 | pub fn new_unhygienic() -> Hygiene { |
@@ -129,10 +129,7 @@ impl HygieneInfo { | |||
129 | mbe::Origin::Call => (&self.macro_arg.1, self.arg_start), | 129 | mbe::Origin::Call => (&self.macro_arg.1, self.arg_start), |
130 | mbe::Origin::Def => ( | 130 | mbe::Origin::Def => ( |
131 | &self.macro_def.1, | 131 | &self.macro_def.1, |
132 | self.def_start | 132 | *self.def_start.as_ref().expect("`Origin::Def` used with non-`macro_rules!` macro"), |
133 | .as_ref() | ||
134 | .expect("`Origin::Def` used with non-`macro_rules!` macro") | ||
135 | .clone(), | ||
136 | ), | 133 | ), |
137 | }; | 134 | }; |
138 | 135 | ||
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index eee430af1..7532d00b8 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs | |||
@@ -475,7 +475,7 @@ fn original_range_opt( | |||
475 | let single = skip_trivia_token(node.value.first_token()?, Direction::Next)? | 475 | let single = skip_trivia_token(node.value.first_token()?, Direction::Next)? |
476 | == skip_trivia_token(node.value.last_token()?, Direction::Prev)?; | 476 | == skip_trivia_token(node.value.last_token()?, Direction::Prev)?; |
477 | 477 | ||
478 | Some(node.value.descendants().find_map(|it| { | 478 | node.value.descendants().find_map(|it| { |
479 | let first = skip_trivia_token(it.first_token()?, Direction::Next)?; | 479 | let first = skip_trivia_token(it.first_token()?, Direction::Next)?; |
480 | let first = ascend_call_token(db, &expansion, node.with_value(first))?; | 480 | let first = ascend_call_token(db, &expansion, node.with_value(first))?; |
481 | 481 | ||
@@ -487,7 +487,7 @@ fn original_range_opt( | |||
487 | } | 487 | } |
488 | 488 | ||
489 | Some(first.with_value(first.value.text_range().cover(last.value.text_range()))) | 489 | Some(first.with_value(first.value.text_range().cover(last.value.text_range()))) |
490 | })?) | 490 | }) |
491 | } | 491 | } |
492 | 492 | ||
493 | fn ascend_call_token( | 493 | fn ascend_call_token( |