aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-18 14:37:34 +0000
committerGitHub <[email protected]>2020-02-18 14:37:34 +0000
commitcecf25b72f2af84fc1535cf52d6f3c1b52802565 (patch)
tree37c8dde0a459caacae6629da08d86be270469ef5 /crates/ra_hir_expand
parenteab80cd961919b9321e1d34343ae3f3adb0502e5 (diff)
parentf6816c253b96e8436f1156d6bd6b0942ee9fb4d3 (diff)
Merge #3220
3220: Fix clippy warnings, update Cargo.toml versions r=matklad a=SomeoneToIgnore In the `cargo xtask lint` ouptut, there were two interesting Clippy warnings that might be interesting to investigate further: * warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) * warning: large size difference between variants Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/Cargo.toml4
-rw-r--r--crates/ra_hir_expand/src/builtin_derive.rs2
-rw-r--r--crates/ra_hir_expand/src/builtin_macro.rs13
-rw-r--r--crates/ra_hir_expand/src/quote.rs8
4 files changed, 11 insertions, 16 deletions
diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml
index 3ae4376dc..d6e3c1f76 100644
--- a/crates/ra_hir_expand/Cargo.toml
+++ b/crates/ra_hir_expand/Cargo.toml
@@ -8,8 +8,8 @@ authors = ["rust-analyzer developers"]
8doctest = false 8doctest = false
9 9
10[dependencies] 10[dependencies]
11log = "0.4.5" 11log = "0.4.8"
12either = "1.5" 12either = "1.5.3"
13 13
14ra_arena = { path = "../ra_arena" } 14ra_arena = { path = "../ra_arena" }
15ra_db = { path = "../ra_db" } 15ra_db = { path = "../ra_db" }
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs
index 62c60e336..d0e3eaf7e 100644
--- a/crates/ra_hir_expand/src/builtin_derive.rs
+++ b/crates/ra_hir_expand/src/builtin_derive.rs
@@ -235,7 +235,7 @@ mod tests {
235 let (db, file_id) = TestDB::with_single_file(&s); 235 let (db, file_id) = TestDB::with_single_file(&s);
236 let parsed = db.parse(file_id); 236 let parsed = db.parse(file_id);
237 let items: Vec<_> = 237 let items: Vec<_> =
238 parsed.syntax_node().descendants().filter_map(|it| ast::ModuleItem::cast(it)).collect(); 238 parsed.syntax_node().descendants().filter_map(ast::ModuleItem::cast).collect();
239 239
240 let ast_id_map = db.ast_id_map(file_id.into()); 240 let ast_id_map = db.ast_id_map(file_id.into());
241 241
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs
index f3f959ac6..f2bb0bddb 100644
--- a/crates/ra_hir_expand/src/builtin_macro.rs
+++ b/crates/ra_hir_expand/src/builtin_macro.rs
@@ -155,14 +155,11 @@ fn compile_error_expand(
155 tt: &tt::Subtree, 155 tt: &tt::Subtree,
156) -> Result<tt::Subtree, mbe::ExpandError> { 156) -> Result<tt::Subtree, mbe::ExpandError> {
157 if tt.count() == 1 { 157 if tt.count() == 1 {
158 match &tt.token_trees[0] { 158 if let tt::TokenTree::Leaf(tt::Leaf::Literal(it)) = &tt.token_trees[0] {
159 tt::TokenTree::Leaf(tt::Leaf::Literal(it)) => { 159 let s = it.text.as_str();
160 let s = it.text.as_str(); 160 if s.contains('"') {
161 if s.contains(r#"""#) { 161 return Ok(quote! { loop { #it }});
162 return Ok(quote! { loop { #it }});
163 }
164 } 162 }
165 _ => {}
166 }; 163 };
167 } 164 }
168 165
@@ -222,7 +219,7 @@ mod tests {
222 let (db, file_id) = TestDB::with_single_file(&s); 219 let (db, file_id) = TestDB::with_single_file(&s);
223 let parsed = db.parse(file_id); 220 let parsed = db.parse(file_id);
224 let macro_calls: Vec<_> = 221 let macro_calls: Vec<_> =
225 parsed.syntax_node().descendants().filter_map(|it| ast::MacroCall::cast(it)).collect(); 222 parsed.syntax_node().descendants().filter_map(ast::MacroCall::cast).collect();
226 223
227 let ast_id_map = db.ast_id_map(file_id.into()); 224 let ast_id_map = db.ast_id_map(file_id.into());
228 225
diff --git a/crates/ra_hir_expand/src/quote.rs b/crates/ra_hir_expand/src/quote.rs
index 4de219ce4..57e7eebf9 100644
--- a/crates/ra_hir_expand/src/quote.rs
+++ b/crates/ra_hir_expand/src/quote.rs
@@ -15,14 +15,13 @@ macro_rules! __quote {
15 ( @SUBTREE $delim:ident $($tt:tt)* ) => { 15 ( @SUBTREE $delim:ident $($tt:tt)* ) => {
16 { 16 {
17 let children = $crate::__quote!($($tt)*); 17 let children = $crate::__quote!($($tt)*);
18 let subtree = tt::Subtree { 18 tt::Subtree {
19 delimiter: Some(tt::Delimiter { 19 delimiter: Some(tt::Delimiter {
20 kind: tt::DelimiterKind::$delim, 20 kind: tt::DelimiterKind::$delim,
21 id: tt::TokenId::unspecified(), 21 id: tt::TokenId::unspecified(),
22 }), 22 }),
23 token_trees: $crate::quote::IntoTt::to_tokens(children), 23 token_trees: $crate::quote::IntoTt::to_tokens(children),
24 }; 24 }
25 subtree
26 } 25 }
27 }; 26 };
28 27
@@ -259,8 +258,7 @@ mod tests {
259 // } 258 // }
260 let struct_name = mk_ident("Foo"); 259 let struct_name = mk_ident("Foo");
261 let fields = [mk_ident("name"), mk_ident("id")]; 260 let fields = [mk_ident("name"), mk_ident("id")];
262 let fields = 261 let fields = fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees).flatten();
263 fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees.clone()).flatten();
264 262
265 let list = tt::Subtree { 263 let list = tt::Subtree {
266 delimiter: Some(tt::Delimiter { 264 delimiter: Some(tt::Delimiter {