mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-19 01:50:32 +00:00
Moar linting: needless_borrow, let_unit_value, ...
* There are a few needless borrows that don't seem to be needed. I even did a quick assembly comparison and posted a q to stackoveflow on it. See [here](https://stackoverflow.com/questions/74910196/advantages-of-pass-by-ref-val-with-impl-intoiteratoritem-impl-asrefstr) * removed several `let _ = ...` when they don't look necessary (even a few ones that were not suggested by clippy (?)) * there were a few `then(|| ctor{})` that clippy suggested to replace with `then_some(ctor{})` -- seems reasonable? * some unneeded assignment+return - keep the code a bit leaner * a few `writeln!` instead of `write!`, or even consolidate write! * a nice optimization to use `ch.is_ascii_digit` instead of `ch.is_digit(10)`
This commit is contained in:
parent
2872e05589
commit
d3dbf9c194
15 changed files with 22 additions and 26 deletions
|
@ -51,7 +51,7 @@ pub(crate) mod entry {
|
|||
use super::*;
|
||||
|
||||
pub(crate) fn vis(p: &mut Parser<'_>) {
|
||||
let _ = opt_visibility(p, false);
|
||||
opt_visibility(p, false);
|
||||
}
|
||||
|
||||
pub(crate) fn block(p: &mut Parser<'_>) {
|
||||
|
@ -70,10 +70,10 @@ pub(crate) mod entry {
|
|||
types::type_(p);
|
||||
}
|
||||
pub(crate) fn expr(p: &mut Parser<'_>) {
|
||||
let _ = expressions::expr(p);
|
||||
expressions::expr(p);
|
||||
}
|
||||
pub(crate) fn path(p: &mut Parser<'_>) {
|
||||
let _ = paths::type_path(p);
|
||||
paths::type_path(p);
|
||||
}
|
||||
pub(crate) fn item(p: &mut Parser<'_>) {
|
||||
items::item_or_macro(p, true);
|
||||
|
|
|
@ -80,8 +80,8 @@ impl<'a> LexedStr<'a> {
|
|||
State::PendingEnter | State::Normal => unreachable!(),
|
||||
}
|
||||
|
||||
let is_eof = builder.pos == builder.lexed.len();
|
||||
is_eof
|
||||
// is_eof?
|
||||
builder.pos == builder.lexed.len()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,14 +93,12 @@ fn parse(entry: TopEntryPoint, text: &str) -> (String, bool) {
|
|||
crate::StrStep::Token { kind, text } => {
|
||||
assert!(depth > 0);
|
||||
len += text.len();
|
||||
write!(buf, "{indent}").unwrap();
|
||||
write!(buf, "{kind:?} {text:?}\n").unwrap();
|
||||
writeln!(buf, "{indent}{kind:?} {text:?}").unwrap();
|
||||
}
|
||||
crate::StrStep::Enter { kind } => {
|
||||
assert!(depth > 0 || len == 0);
|
||||
depth += 1;
|
||||
write!(buf, "{indent}").unwrap();
|
||||
write!(buf, "{kind:?}\n").unwrap();
|
||||
writeln!(buf, "{indent}{kind:?}").unwrap();
|
||||
indent.push_str(" ");
|
||||
}
|
||||
crate::StrStep::Exit => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue