5699: Fix clippy warnings r=matklad a=popzxc

Currently clippy spawns a bunch of warnings on the `rust-analyzer` project. Nothing critical, but easy to fix, so I guess it won't harm.

Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
This commit is contained in:
bors[bot] 2020-08-12 11:51:53 +00:00 committed by GitHub
commit 4b3d99f98f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 10 deletions

View File

@ -74,7 +74,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Expect { impl Expect {
pub fn assert_eq(&self, actual: &str) { pub fn assert_eq(&self, actual: &str) {
let trimmed = self.trimmed(); let trimmed = self.trimmed();
if &trimmed == actual { if trimmed == actual {
return; return;
} }
Runtime::fail_expect(self, &trimmed, actual); Runtime::fail_expect(self, &trimmed, actual);

View File

@ -276,7 +276,7 @@ pub(crate) fn expect_lifetime(&mut self) -> Result<tt::TokenTree, ()> {
Ok(tt::Subtree { Ok(tt::Subtree {
delimiter: None, delimiter: None,
token_trees: vec![ token_trees: vec![
tt::Leaf::Punct(punct.clone()).into(), tt::Leaf::Punct(*punct).into(),
tt::Leaf::Ident(ident.clone()).into(), tt::Leaf::Ident(ident.clone()).into(),
], ],
} }

View File

@ -90,7 +90,7 @@ pub fn send_task<R>(&self, req: Request) -> Result<R, ra_tt::ExpansionError>
} }
Some(it) => it, Some(it) => it,
}; };
sender.send(Task { req: req.into(), result_tx }).unwrap(); sender.send(Task { req, result_tx }).unwrap();
let res = result_rx let res = result_rx
.recv() .recv()
.map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?;

View File

@ -76,10 +76,6 @@ pub fn iter(&self) -> slice::Iter<'_, Indel> {
self.indels.iter() self.indels.iter()
} }
pub fn into_iter(self) -> vec::IntoIter<Indel> {
self.indels.into_iter()
}
pub fn apply(&self, text: &mut String) { pub fn apply(&self, text: &mut String) {
match self.len() { match self.len() {
0 => return, 0 => return,
@ -141,6 +137,15 @@ pub fn apply_to_offset(&self, offset: TextSize) -> Option<TextSize> {
} }
} }
impl IntoIterator for TextEdit {
type Item = Indel;
type IntoIter = vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.indels.into_iter()
}
}
impl TextEditBuilder { impl TextEditBuilder {
pub fn replace(&mut self, range: TextRange, replace_with: String) { pub fn replace(&mut self, range: TextRange, replace_with: String) {
self.indels.push(Indel::replace(range, replace_with)) self.indels.push(Indel::replace(range, replace_with))

View File

@ -107,7 +107,7 @@ fn print_debug_subtree(f: &mut fmt::Formatter<'_>, subtree: &Subtree, level: usi
for (idx, child) in subtree.token_trees.iter().enumerate() { for (idx, child) in subtree.token_trees.iter().enumerate() {
print_debug_token(f, child, level + 1)?; print_debug_token(f, child, level + 1)?;
if idx != subtree.token_trees.len() - 1 { if idx != subtree.token_trees.len() - 1 {
writeln!(f, "")?; writeln!(f)?;
} }
} }
} }

View File

@ -10,7 +10,7 @@ pub fn is_ci() -> bool {
pub trait SepBy: Sized { pub trait SepBy: Sized {
/// Returns an `impl fmt::Display`, which joins elements via a separator. /// Returns an `impl fmt::Display`, which joins elements via a separator.
fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self>; fn sep_by(self, sep: &str) -> SepByBuilder<'_, Self>;
} }
impl<I> SepBy for I impl<I> SepBy for I
@ -18,7 +18,7 @@ impl<I> SepBy for I
I: Iterator, I: Iterator,
I::Item: fmt::Display, I::Item: fmt::Display,
{ {
fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self> { fn sep_by(self, sep: &str) -> SepByBuilder<'_, Self> {
SepByBuilder::new(sep, self) SepByBuilder::new(sep, self)
} }
} }