aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src
diff options
context:
space:
mode:
authorMatthias Krüger <[email protected]>2021-03-17 00:27:56 +0000
committerMatthias Krüger <[email protected]>2021-03-17 00:27:56 +0000
commit966c23f5290275ce17564f6027a17ec20cd6078f (patch)
tree9e977a29eaf10d1733340563ef31fda064e37400 /crates/mbe/src
parent83e6940efb42675226adb8d2856c095b8dce36c5 (diff)
avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
Diffstat (limited to 'crates/mbe/src')
-rw-r--r--crates/mbe/src/benchmark.rs18
-rw-r--r--crates/mbe/src/expander/matcher.rs2
-rw-r--r--crates/mbe/src/syntax_bridge.rs4
-rw-r--r--crates/mbe/src/tests.rs2
4 files changed, 12 insertions, 14 deletions
diff --git a/crates/mbe/src/benchmark.rs b/crates/mbe/src/benchmark.rs
index 503ad1355..bd8ea6452 100644
--- a/crates/mbe/src/benchmark.rs
+++ b/crates/mbe/src/benchmark.rs
@@ -120,7 +120,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt
120 Some("pat") => parent.token_trees.push(make_ident("foo")), 120 Some("pat") => parent.token_trees.push(make_ident("foo")),
121 Some("path") => parent.token_trees.push(make_ident("foo")), 121 Some("path") => parent.token_trees.push(make_ident("foo")),
122 Some("literal") => parent.token_trees.push(make_literal("1")), 122 Some("literal") => parent.token_trees.push(make_literal("1")),
123 Some("expr") => parent.token_trees.push(make_ident("foo").into()), 123 Some("expr") => parent.token_trees.push(make_ident("foo")),
124 Some("lifetime") => { 124 Some("lifetime") => {
125 parent.token_trees.push(make_punct('\'')); 125 parent.token_trees.push(make_punct('\''));
126 parent.token_trees.push(make_ident("a")); 126 parent.token_trees.push(make_ident("a"));
@@ -157,17 +157,15 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt
157 if i + 1 != cnt { 157 if i + 1 != cnt {
158 if let Some(sep) = separator { 158 if let Some(sep) = separator {
159 match sep { 159 match sep {
160 Separator::Literal(it) => parent 160 Separator::Literal(it) => {
161 .token_trees 161 parent.token_trees.push(tt::Leaf::Literal(it.clone()).into())
162 .push(tt::Leaf::Literal(it.clone().into()).into()), 162 }
163 Separator::Ident(it) => parent 163 Separator::Ident(it) => {
164 .token_trees 164 parent.token_trees.push(tt::Leaf::Ident(it.clone()).into())
165 .push(tt::Leaf::Ident(it.clone().into()).into()), 165 }
166 Separator::Puncts(puncts) => { 166 Separator::Puncts(puncts) => {
167 for it in puncts { 167 for it in puncts {
168 parent 168 parent.token_trees.push(tt::Leaf::Punct(it.clone()).into())
169 .token_trees
170 .push(tt::Leaf::Punct(it.clone().into()).into())
171 } 169 }
172 } 170 }
173 }; 171 };
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index 2c69e8968..1bf7c2e81 100644
--- a/crates/mbe/src/expander/matcher.rs
+++ b/crates/mbe/src/expander/matcher.rs
@@ -722,7 +722,7 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
722 input 722 input
723 .expect_literal() 723 .expect_literal()
724 .map(|literal| { 724 .map(|literal| {
725 let lit = tt::Leaf::from(literal.clone()); 725 let lit = literal.clone();
726 match neg { 726 match neg {
727 None => Some(lit.into()), 727 None => Some(lit.into()),
728 Some(neg) => Some(tt::TokenTree::Subtree(tt::Subtree { 728 Some(neg) => Some(tt::TokenTree::Subtree(tt::Subtree {
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs
index b715ebfc4..85163c4b3 100644
--- a/crates/mbe/src/syntax_bridge.rs
+++ b/crates/mbe/src/syntax_bridge.rs
@@ -130,7 +130,7 @@ pub fn parse_exprs_with_sep(tt: &tt::Subtree, sep: char) -> Vec<tt::Subtree> {
130 res.push(match expanded.value { 130 res.push(match expanded.value {
131 None => break, 131 None => break,
132 Some(tt @ tt::TokenTree::Leaf(_)) => { 132 Some(tt @ tt::TokenTree::Leaf(_)) => {
133 tt::Subtree { delimiter: None, token_trees: vec![tt.into()] } 133 tt::Subtree { delimiter: None, token_trees: vec![tt] }
134 } 134 }
135 Some(tt::TokenTree::Subtree(tt)) => tt, 135 Some(tt::TokenTree::Subtree(tt)) => tt,
136 }); 136 });
@@ -727,7 +727,7 @@ impl<'a> TreeSink for TtTreeSink<'a> {
727 // Note: We always assume the semi-colon would be the last token in 727 // Note: We always assume the semi-colon would be the last token in
728 // other parts of RA such that we don't add whitespace here. 728 // other parts of RA such that we don't add whitespace here.
729 if curr.spacing == tt::Spacing::Alone && curr.char != ';' { 729 if curr.spacing == tt::Spacing::Alone && curr.char != ';' {
730 self.inner.token(WHITESPACE, " ".into()); 730 self.inner.token(WHITESPACE, " ");
731 self.text_pos += TextSize::of(' '); 731 self.text_pos += TextSize::of(' ');
732 } 732 }
733 } 733 }
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index eca0bcc18..25c374b9b 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -35,7 +35,7 @@ mod rule_parsing {
35 fn test_invalid_arms() { 35 fn test_invalid_arms() {
36 fn check(macro_body: &str, err: ParseError) { 36 fn check(macro_body: &str, err: ParseError) {
37 let m = parse_macro_arm(macro_body); 37 let m = parse_macro_arm(macro_body);
38 assert_eq!(m, Err(err.into())); 38 assert_eq!(m, Err(err));
39 } 39 }
40 check("invalid", ParseError::Expected("expected subtree".into())); 40 check("invalid", ParseError::Expected("expected subtree".into()));
41 41