Some clippy fixes for 1.36

This commit is contained in:
Jeremy Kolb 2019-07-04 13:26:44 -04:00
parent c6a6e43372
commit 4ad9e986ad
31 changed files with 62 additions and 70 deletions

View file

@ -498,7 +498,7 @@ fn expand_tt(
tt::Leaf::from(tt::Ident { text: ident.text.clone(), id: TokenId::unspecified() })
.into()
}
crate::Leaf::Punct(punct) => tt::Leaf::from(punct.clone()).into(),
crate::Leaf::Punct(punct) => tt::Leaf::from(*punct).into(),
crate::Leaf::Var(v) => {
if v.text == "crate" {
// FIXME: Properly handle $crate token

View file

@ -56,7 +56,7 @@ fn parse_subtree(tt: &tt::Subtree, transcriber: bool) -> Result<crate::Subtree,
}
}
tt::Leaf::Punct(punct) => crate::Leaf::from(*punct).into(),
tt::Leaf::Ident(tt::Ident { text, id: _ }) => {
tt::Leaf::Ident(tt::Ident { text, .. }) => {
crate::Leaf::from(crate::Ident { text: text.clone() }).into()
}
tt::Leaf::Literal(tt::Literal { text }) => {

View file

@ -78,7 +78,7 @@ impl<'a> SubtreeTokenSource<'a> {
}
}
return cached[pos].clone();
cached[pos].clone()
}
}

View file

@ -107,7 +107,7 @@ pub fn token_tree_to_ast_item_list(tt: &tt::Subtree) -> TreeArc<ast::SourceFile>
impl TokenMap {
pub fn relative_range_of(&self, tt: tt::TokenId) -> Option<TextRange> {
let idx = tt.0 as usize;
self.tokens.get(idx).map(|&it| it)
self.tokens.get(idx).copied()
}
fn alloc(&mut self, relative_range: TextRange) -> tt::TokenId {

View file

@ -171,14 +171,14 @@ impl<'a> TtCursor<'a> {
}
fn eat_punct3(&mut self, p: &tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> {
let sec = self.eat_punct()?.clone();
let third = self.eat_punct()?.clone();
Some(smallvec![p.clone(), sec, third])
let sec = *self.eat_punct()?;
let third = *self.eat_punct()?;
Some(smallvec![*p, sec, third])
}
fn eat_punct2(&mut self, p: &tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> {
let sec = self.eat_punct()?.clone();
Some(smallvec![p.clone(), sec])
let sec = *self.eat_punct()?;
Some(smallvec![*p, sec])
}
fn eat_multi_char_punct<'b, I>(
@ -251,7 +251,7 @@ impl<'a> TtCursor<'a> {
// So we by pass that check here.
let mut peekable = TokenPeek::new(self.subtree.token_trees[self.pos..].iter());
let puncts = self.eat_multi_char_punct(punct, &mut peekable);
let puncts = puncts.unwrap_or_else(|| smallvec![punct.clone()]);
let puncts = puncts.unwrap_or_else(|| smallvec![*punct]);
Some(crate::Separator::Puncts(puncts))
}