aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-03-23 19:32:06 +0000
committerEdwin Cheng <[email protected]>2020-03-25 11:50:12 +0000
commit7667aa6033b1a0307279d0a153ce0e90437b0b66 (patch)
treeddf5a147f4f58ce4b004bc83742e5c4447b5eeef /crates
parent519dc15cb149a08f4df6746f1e2cb6cd44e3a252 (diff)
Refactoring a bit
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_def/src/lib.rs7
-rw-r--r--crates/ra_hir_expand/src/builtin_derive.rs10
2 files changed, 10 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index b3e811671..bd32ac20a 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -476,8 +476,11 @@ impl AsMacroCall for AstIdWithPath<ast::ModuleItem> {
476 ) -> Option<MacroCallId> { 476 ) -> Option<MacroCallId> {
477 let def = resolver(self.path.clone())?; 477 let def = resolver(self.path.clone())?;
478 Some( 478 Some(
479 def.as_lazy_macro(db.upcast(), MacroCallKind::Attr(self.ast_id, self.path.to_string())) 479 def.as_lazy_macro(
480 .into(), 480 db.upcast(),
481 MacroCallKind::Attr(self.ast_id, self.path.segments.last()?.to_string()),
482 )
483 .into(),
481 ) 484 )
482 } 485 }
483} 486}
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs
index 7f753bbca..79aea5806 100644
--- a/crates/ra_hir_expand/src/builtin_derive.rs
+++ b/crates/ra_hir_expand/src/builtin_derive.rs
@@ -229,7 +229,7 @@ fn partial_ord_expand(
229mod tests { 229mod tests {
230 use super::*; 230 use super::*;
231 use crate::{test_db::TestDB, AstId, MacroCallId, MacroCallKind, MacroCallLoc}; 231 use crate::{test_db::TestDB, AstId, MacroCallId, MacroCallKind, MacroCallLoc};
232 use name::Name; 232 use name::{known, Name};
233 use ra_db::{fixture::WithFixture, SourceDatabase}; 233 use ra_db::{fixture::WithFixture, SourceDatabase};
234 234
235 fn expand_builtin_derive(s: &str, name: Name) -> String { 235 fn expand_builtin_derive(s: &str, name: Name) -> String {
@@ -261,7 +261,7 @@ mod tests {
261 #[derive(Copy)] 261 #[derive(Copy)]
262 struct Foo; 262 struct Foo;
263"#, 263"#,
264 name::known::Copy, 264 known::Copy,
265 ); 265 );
266 266
267 assert_eq!(expanded, "impl< >std::marker::CopyforFoo< >{}"); 267 assert_eq!(expanded, "impl< >std::marker::CopyforFoo< >{}");
@@ -274,7 +274,7 @@ mod tests {
274 #[derive(Copy)] 274 #[derive(Copy)]
275 struct Foo<A, B>; 275 struct Foo<A, B>;
276"#, 276"#,
277 name::known::Copy, 277 known::Copy,
278 ); 278 );
279 279
280 assert_eq!( 280 assert_eq!(
@@ -290,7 +290,7 @@ mod tests {
290 #[derive(Copy)] 290 #[derive(Copy)]
291 struct Foo<A, B, 'a, 'b>; 291 struct Foo<A, B, 'a, 'b>;
292"#, 292"#,
293 name::known::Copy, 293 known::Copy,
294 ); 294 );
295 295
296 // We currently just ignore lifetimes 296 // We currently just ignore lifetimes
@@ -308,7 +308,7 @@ mod tests {
308 #[derive(Clone)] 308 #[derive(Clone)]
309 struct Foo<A, B>; 309 struct Foo<A, B>;
310"#, 310"#,
311 name::known::Clone, 311 known::Clone,
312 ); 312 );
313 313
314 assert_eq!( 314 assert_eq!(