Skip to content

Commit 1dd3d9b

Browse files
bors[bot]kjeremy
andcommitted
Merge #1212
1212: Clippy cleanups r=matklad a=kjeremy Co-authored-by: kjeremy <[email protected]>
2 parents 42c4e0f + d8649c1 commit 1dd3d9b

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

crates/ra_arena/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,15 @@ impl<ID: ArenaId, T> Arena<ID, T> {
7171
pub fn len(&self) -> usize {
7272
self.data.len()
7373
}
74+
pub fn is_empty(&self) -> bool {
75+
self.data.is_empty()
76+
}
7477
pub fn alloc(&mut self, value: T) -> ID {
7578
let id = RawId(self.data.len() as u32);
7679
self.data.push(value);
7780
ID::from_raw(id)
7881
}
79-
pub fn iter<'a>(&'a self) -> impl Iterator<Item = (ID, &'a T)> {
82+
pub fn iter(&self) -> impl Iterator<Item = (ID, &T)> {
8083
self.data.iter().enumerate().map(|(idx, value)| (ID::from_raw(RawId(idx as u32)), value))
8184
}
8285
}

crates/ra_parser/src/grammar/expressions.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,12 @@ fn expr_bp(
252252
// `newly_dollar_open` is a flag indicated that dollar is just closed after lhs, e.g.
253253
// `$1$ + a`
254254
// We use this flag to skip handling it.
255-
let mut newly_dollar_open = false;
256-
257-
if p.at_l_dollar() {
255+
let mut newly_dollar_open = if p.at_l_dollar() {
258256
*dollar_lvl += p.eat_l_dollars();
259-
newly_dollar_open = true;
260-
}
257+
true
258+
} else {
259+
false
260+
};
261261

262262
let mut lhs = match lhs(p, r, dollar_lvl) {
263263
Some((lhs, blocklike)) => {
@@ -535,7 +535,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
535535
}
536536
EXCL => {
537537
let block_like = items::macro_call_after_excl(p);
538-
return (m.complete(p, MACRO_CALL), block_like);
538+
(m.complete(p, MACRO_CALL), block_like)
539539
}
540540
_ => (m.complete(p, PATH_EXPR), BlockLike::NotBlock),
541541
}

crates/ra_prof/src/lib.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,11 @@ pub fn profile(desc: &str) -> Profiler {
6767

6868
PROFILE_STACK.with(|stack| {
6969
let mut stack = stack.borrow_mut();
70-
if stack.starts.len() == 0 {
71-
match FILTER.try_read() {
72-
Ok(f) => {
73-
if f.version > stack.filter_data.version {
74-
stack.filter_data = f.clone();
75-
}
70+
if stack.starts.is_empty() {
71+
if let Ok(f) = FILTER.try_read() {
72+
if f.version > stack.filter_data.version {
73+
stack.filter_data = f.clone();
7674
}
77-
Err(_) => (),
7875
};
7976
}
8077

@@ -107,23 +104,23 @@ impl Filter {
107104
// env RA_PROFILE=foo|bar|baz // enabled only selected entries
108105
// env RA_PROFILE=*@3>10 // dump everything, up to depth 3, if it takes more than 10 ms
109106
pub fn from_spec(mut spec: &str) -> Filter {
110-
let longer_than = if let Some(idx) = spec.rfind(">") {
107+
let longer_than = if let Some(idx) = spec.rfind('>') {
111108
let longer_than = spec[idx + 1..].parse().expect("invalid profile longer_than");
112109
spec = &spec[..idx];
113110
Duration::from_millis(longer_than)
114111
} else {
115112
Duration::new(0, 0)
116113
};
117114

118-
let depth = if let Some(idx) = spec.rfind("@") {
115+
let depth = if let Some(idx) = spec.rfind('@') {
119116
let depth: usize = spec[idx + 1..].parse().expect("invalid profile depth");
120117
spec = &spec[..idx];
121118
depth
122119
} else {
123120
999
124121
};
125122
let allowed =
126-
if spec == "*" { Vec::new() } else { spec.split("|").map(String::from).collect() };
123+
if spec == "*" { Vec::new() } else { spec.split('|').map(String::from).collect() };
127124
Filter::new(depth, allowed, longer_than)
128125
}
129126

0 commit comments

Comments
 (0)