mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
This commit is contained in:
parent
83e6940efb
commit
966c23f529
24 changed files with 56 additions and 61 deletions
|
@ -120,7 +120,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt
|
|||
Some("pat") => parent.token_trees.push(make_ident("foo")),
|
||||
Some("path") => parent.token_trees.push(make_ident("foo")),
|
||||
Some("literal") => parent.token_trees.push(make_literal("1")),
|
||||
Some("expr") => parent.token_trees.push(make_ident("foo").into()),
|
||||
Some("expr") => parent.token_trees.push(make_ident("foo")),
|
||||
Some("lifetime") => {
|
||||
parent.token_trees.push(make_punct('\''));
|
||||
parent.token_trees.push(make_ident("a"));
|
||||
|
@ -157,17 +157,15 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt
|
|||
if i + 1 != cnt {
|
||||
if let Some(sep) = separator {
|
||||
match sep {
|
||||
Separator::Literal(it) => parent
|
||||
.token_trees
|
||||
.push(tt::Leaf::Literal(it.clone().into()).into()),
|
||||
Separator::Ident(it) => parent
|
||||
.token_trees
|
||||
.push(tt::Leaf::Ident(it.clone().into()).into()),
|
||||
Separator::Literal(it) => {
|
||||
parent.token_trees.push(tt::Leaf::Literal(it.clone()).into())
|
||||
}
|
||||
Separator::Ident(it) => {
|
||||
parent.token_trees.push(tt::Leaf::Ident(it.clone()).into())
|
||||
}
|
||||
Separator::Puncts(puncts) => {
|
||||
for it in puncts {
|
||||
parent
|
||||
.token_trees
|
||||
.push(tt::Leaf::Punct(it.clone().into()).into())
|
||||
parent.token_trees.push(tt::Leaf::Punct(it.clone()).into())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -722,7 +722,7 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
|
|||
input
|
||||
.expect_literal()
|
||||
.map(|literal| {
|
||||
let lit = tt::Leaf::from(literal.clone());
|
||||
let lit = literal.clone();
|
||||
match neg {
|
||||
None => Some(lit.into()),
|
||||
Some(neg) => Some(tt::TokenTree::Subtree(tt::Subtree {
|
||||
|
|
|
@ -130,7 +130,7 @@ pub fn parse_exprs_with_sep(tt: &tt::Subtree, sep: char) -> Vec<tt::Subtree> {
|
|||
res.push(match expanded.value {
|
||||
None => break,
|
||||
Some(tt @ tt::TokenTree::Leaf(_)) => {
|
||||
tt::Subtree { delimiter: None, token_trees: vec![tt.into()] }
|
||||
tt::Subtree { delimiter: None, token_trees: vec![tt] }
|
||||
}
|
||||
Some(tt::TokenTree::Subtree(tt)) => tt,
|
||||
});
|
||||
|
@ -727,7 +727,7 @@ impl<'a> TreeSink for TtTreeSink<'a> {
|
|||
// Note: We always assume the semi-colon would be the last token in
|
||||
// other parts of RA such that we don't add whitespace here.
|
||||
if curr.spacing == tt::Spacing::Alone && curr.char != ';' {
|
||||
self.inner.token(WHITESPACE, " ".into());
|
||||
self.inner.token(WHITESPACE, " ");
|
||||
self.text_pos += TextSize::of(' ');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ mod rule_parsing {
|
|||
fn test_invalid_arms() {
|
||||
fn check(macro_body: &str, err: ParseError) {
|
||||
let m = parse_macro_arm(macro_body);
|
||||
assert_eq!(m, Err(err.into()));
|
||||
assert_eq!(m, Err(err));
|
||||
}
|
||||
check("invalid", ParseError::Expected("expected subtree".into()));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue