aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir/src/code_model.rs2
-rw-r--r--crates/hir/src/semantics/source_to_def.rs2
-rw-r--r--crates/hir_def/src/body/lower.rs2
-rw-r--r--crates/hir_def/src/item_scope.rs2
-rw-r--r--crates/hir_def/src/nameres/collector.rs18
-rw-r--r--crates/hir_def/src/nameres/tests/macros.rs31
-rw-r--r--crates/hir_expand/src/builtin_derive.rs40
-rw-r--r--crates/hir_expand/src/builtin_macro.rs8
-rw-r--r--crates/hir_expand/src/hygiene.rs4
-rw-r--r--crates/hir_expand/src/lib.rs8
-rw-r--r--crates/hir_ty/src/tests/macros.rs6
-rw-r--r--crates/ide/src/goto_implementation.rs2
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlighting.html5
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs3
14 files changed, 91 insertions, 42 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 42dc35b76..9bfcd215a 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -970,7 +970,7 @@ impl MacroDef {
970 /// defines this macro. The reasons for this is that macros are expanded 970 /// defines this macro. The reasons for this is that macros are expanded
971 /// early, in `hir_expand`, where modules simply do not exist yet. 971 /// early, in `hir_expand`, where modules simply do not exist yet.
972 pub fn module(self, db: &dyn HirDatabase) -> Option<Module> { 972 pub fn module(self, db: &dyn HirDatabase) -> Option<Module> {
973 let krate = self.id.krate?; 973 let krate = self.id.krate;
974 let module_id = db.crate_def_map(krate).root; 974 let module_id = db.crate_def_map(krate).root;
975 Some(Module::new(Crate { id: krate }, module_id)) 975 Some(Module::new(Crate { id: krate }, module_id))
976 } 976 }
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index d499ae340..3efca5baa 100644
--- a/crates/hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
@@ -158,7 +158,7 @@ impl SourceToDefCtx<'_, '_> {
158 let krate = self.file_to_def(file_id)?.krate; 158 let krate = self.file_to_def(file_id)?.krate;
159 let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value); 159 let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value);
160 let ast_id = Some(AstId::new(src.file_id, file_ast_id.upcast())); 160 let ast_id = Some(AstId::new(src.file_id, file_ast_id.upcast()));
161 Some(MacroDefId { krate: Some(krate), ast_id, kind, local_inner: false }) 161 Some(MacroDefId { krate, ast_id, kind, local_inner: false })
162 } 162 }
163 163
164 pub(super) fn find_container(&mut self, src: InFile<&SyntaxNode>) -> Option<ChildContainer> { 164 pub(super) fn find_container(&mut self, src: InFile<&SyntaxNode>) -> Option<ChildContainer> {
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index e4bf5603c..23e2fd764 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -803,7 +803,7 @@ impl ExprCollector<'_> {
803 } 803 }
804 Either::Right(e) => { 804 Either::Right(e) => {
805 let mac = MacroDefId { 805 let mac = MacroDefId {
806 krate: Some(self.expander.module.krate), 806 krate: self.expander.module.krate,
807 ast_id: Some(self.expander.ast_id(&e)), 807 ast_id: Some(self.expander.ast_id(&e)),
808 kind: MacroDefKind::Declarative, 808 kind: MacroDefKind::Declarative,
809 local_inner: false, 809 local_inner: false,
diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs
index a8b3fe844..62ab3b2bd 100644
--- a/crates/hir_def/src/item_scope.rs
+++ b/crates/hir_def/src/item_scope.rs
@@ -363,7 +363,7 @@ impl ItemInNs {
363 ModuleDefId::TypeAliasId(id) => id.lookup(db).module(db).krate, 363 ModuleDefId::TypeAliasId(id) => id.lookup(db).module(db).krate,
364 ModuleDefId::BuiltinType(_) => return None, 364 ModuleDefId::BuiltinType(_) => return None,
365 }, 365 },
366 ItemInNs::Macros(id) => return id.krate, 366 ItemInNs::Macros(id) => return Some(id.krate),
367 }) 367 })
368 } 368 }
369} 369}
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index c2f741060..785895277 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -309,13 +309,13 @@ impl DefCollector<'_> {
309 let macro_def = match self.proc_macros.iter().find(|(n, _)| n == name) { 309 let macro_def = match self.proc_macros.iter().find(|(n, _)| n == name) {
310 Some((_, expander)) => MacroDefId { 310 Some((_, expander)) => MacroDefId {
311 ast_id: None, 311 ast_id: None,
312 krate: Some(self.def_map.krate), 312 krate: self.def_map.krate,
313 kind: MacroDefKind::ProcMacro(*expander), 313 kind: MacroDefKind::ProcMacro(*expander),
314 local_inner: false, 314 local_inner: false,
315 }, 315 },
316 None => MacroDefId { 316 None => MacroDefId {
317 ast_id: None, 317 ast_id: None,
318 krate: Some(self.def_map.krate), 318 krate: self.def_map.krate,
319 kind: MacroDefKind::ProcMacro(ProcMacroExpander::dummy(self.def_map.krate)), 319 kind: MacroDefKind::ProcMacro(ProcMacroExpander::dummy(self.def_map.krate)),
320 local_inner: false, 320 local_inner: false,
321 }, 321 },
@@ -784,14 +784,6 @@ impl DefCollector<'_> {
784 directive: &DeriveDirective, 784 directive: &DeriveDirective,
785 path: &ModPath, 785 path: &ModPath,
786 ) -> Option<MacroDefId> { 786 ) -> Option<MacroDefId> {
787 if let Some(name) = path.as_ident() {
788 // FIXME this should actually be handled with the normal name
789 // resolution; the std lib defines built-in stubs for the derives,
790 // but these are new-style `macro`s, which we don't support yet
791 if let Some(def_id) = find_builtin_derive(name) {
792 return Some(def_id);
793 }
794 }
795 let resolved_res = self.def_map.resolve_path_fp_with_macro( 787 let resolved_res = self.def_map.resolve_path_fp_with_macro(
796 self.db, 788 self.db,
797 ResolveMode::Other, 789 ResolveMode::Other,
@@ -984,7 +976,9 @@ impl ModCollector<'_, '_> {
984 // to define builtin macros, so we support at least that part. 976 // to define builtin macros, so we support at least that part.
985 if mac.is_builtin { 977 if mac.is_builtin {
986 let krate = self.def_collector.def_map.krate; 978 let krate = self.def_collector.def_map.krate;
987 if let Some(macro_id) = find_builtin_macro(&mac.name, krate, ast_id) { 979 let macro_id = find_builtin_macro(&mac.name, krate, ast_id)
980 .or_else(|| find_builtin_derive(&mac.name, krate, ast_id));
981 if let Some(macro_id) = macro_id {
988 let vis = self 982 let vis = self
989 .def_collector 983 .def_collector
990 .def_map 984 .def_map
@@ -1326,7 +1320,7 @@ impl ModCollector<'_, '_> {
1326 // Case 2: normal `macro_rules!` macro 1320 // Case 2: normal `macro_rules!` macro
1327 let macro_id = MacroDefId { 1321 let macro_id = MacroDefId {
1328 ast_id: Some(ast_id), 1322 ast_id: Some(ast_id),
1329 krate: Some(self.def_collector.def_map.krate), 1323 krate: self.def_collector.def_map.krate,
1330 kind: MacroDefKind::Declarative, 1324 kind: MacroDefKind::Declarative,
1331 local_inner: mac.is_local_inner, 1325 local_inner: mac.is_local_inner,
1332 }; 1326 };
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs
index 305fca0f9..6fe2ee78a 100644
--- a/crates/hir_def/src/nameres/tests/macros.rs
+++ b/crates/hir_def/src/nameres/tests/macros.rs
@@ -633,15 +633,44 @@ pub struct bar;
633fn expand_derive() { 633fn expand_derive() {
634 let map = compute_crate_def_map( 634 let map = compute_crate_def_map(
635 " 635 "
636 //- /main.rs 636 //- /main.rs crate:main deps:core
637 use core::*;
638
637 #[derive(Copy, Clone)] 639 #[derive(Copy, Clone)]
638 struct Foo; 640 struct Foo;
641
642 //- /core.rs crate:core
643 #[rustc_builtin_macro]
644 pub macro Copy {}
645
646 #[rustc_builtin_macro]
647 pub macro Clone {}
639 ", 648 ",
640 ); 649 );
641 assert_eq!(map.modules[map.root].scope.impls().len(), 2); 650 assert_eq!(map.modules[map.root].scope.impls().len(), 2);
642} 651}
643 652
644#[test] 653#[test]
654fn resolve_builtin_derive() {
655 check(
656 r#"
657//- /main.rs crate:main deps:core
658use core::*;
659
660//- /core.rs crate:core
661#[rustc_builtin_macro]
662pub macro Clone {}
663
664pub trait Clone {}
665"#,
666 expect![[r#"
667 crate
668 Clone: t m
669 "#]],
670 );
671}
672
673#[test]
645fn macro_expansion_overflow() { 674fn macro_expansion_overflow() {
646 mark::check!(macro_expansion_overflow); 675 mark::check!(macro_expansion_overflow);
647 check( 676 check(
diff --git a/crates/hir_expand/src/builtin_derive.rs b/crates/hir_expand/src/builtin_derive.rs
index 988a60d56..ad378762a 100644
--- a/crates/hir_expand/src/builtin_derive.rs
+++ b/crates/hir_expand/src/builtin_derive.rs
@@ -8,7 +8,7 @@ use syntax::{
8 match_ast, 8 match_ast,
9}; 9};
10 10
11use crate::{db::AstDatabase, name, quote, LazyMacroId, MacroDefId, MacroDefKind}; 11use crate::{db::AstDatabase, name, quote, AstId, CrateId, LazyMacroId, MacroDefId, MacroDefKind};
12 12
13macro_rules! register_builtin { 13macro_rules! register_builtin {
14 ( $($trait:ident => $expand:ident),* ) => { 14 ( $($trait:ident => $expand:ident),* ) => {
@@ -29,16 +29,15 @@ macro_rules! register_builtin {
29 }; 29 };
30 expander(db, id, tt) 30 expander(db, id, tt)
31 } 31 }
32 }
33
34 pub fn find_builtin_derive(ident: &name::Name) -> Option<MacroDefId> {
35 let kind = match ident {
36 $( id if id == &name::name![$trait] => BuiltinDeriveExpander::$trait, )*
37 _ => return None,
38 };
39 32
40 Some(MacroDefId { krate: None, ast_id: None, kind: MacroDefKind::BuiltInDerive(kind), local_inner: false }) 33 fn find_by_name(name: &name::Name) -> Option<Self> {
34 match name {
35 $( id if id == &name::name![$trait] => Some(BuiltinDeriveExpander::$trait), )*
36 _ => None,
37 }
38 }
41 } 39 }
40
42 }; 41 };
43} 42}
44 43
@@ -54,6 +53,20 @@ register_builtin! {
54 PartialEq => partial_eq_expand 53 PartialEq => partial_eq_expand
55} 54}
56 55
56pub fn find_builtin_derive(
57 ident: &name::Name,
58 krate: CrateId,
59 ast_id: AstId<ast::Macro>,
60) -> Option<MacroDefId> {
61 let expander = BuiltinDeriveExpander::find_by_name(ident)?;
62 Some(MacroDefId {
63 krate,
64 ast_id: Some(ast_id),
65 kind: MacroDefKind::BuiltInDerive(expander),
66 local_inner: false,
67 })
68}
69
57struct BasicAdtInfo { 70struct BasicAdtInfo {
58 name: tt::Ident, 71 name: tt::Ident,
59 type_params: usize, 72 type_params: usize,
@@ -261,7 +274,7 @@ mod tests {
261 use super::*; 274 use super::*;
262 275
263 fn expand_builtin_derive(s: &str, name: Name) -> String { 276 fn expand_builtin_derive(s: &str, name: Name) -> String {
264 let def = find_builtin_derive(&name).unwrap(); 277 let expander = BuiltinDeriveExpander::find_by_name(&name).unwrap();
265 let fixture = format!( 278 let fixture = format!(
266 r#"//- /main.rs crate:main deps:core 279 r#"//- /main.rs crate:main deps:core
267<|> 280<|>
@@ -283,7 +296,12 @@ mod tests {
283 let attr_id = AstId::new(file_id.into(), ast_id_map.ast_id(&items[0])); 296 let attr_id = AstId::new(file_id.into(), ast_id_map.ast_id(&items[0]));
284 297
285 let loc = MacroCallLoc { 298 let loc = MacroCallLoc {
286 def, 299 def: MacroDefId {
300 krate: CrateId(0),
301 ast_id: None,
302 kind: MacroDefKind::BuiltInDerive(expander),
303 local_inner: false,
304 },
287 krate: CrateId(0), 305 krate: CrateId(0),
288 kind: MacroCallKind::Attr(attr_id, name.to_string()), 306 kind: MacroCallKind::Attr(attr_id, name.to_string()),
289 }; 307 };
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index df82cf8e6..dddbbcdac 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -69,13 +69,13 @@ pub fn find_builtin_macro(
69 69
70 match kind { 70 match kind {
71 Either::Left(kind) => Some(MacroDefId { 71 Either::Left(kind) => Some(MacroDefId {
72 krate: Some(krate), 72 krate,
73 ast_id: Some(ast_id), 73 ast_id: Some(ast_id),
74 kind: MacroDefKind::BuiltIn(kind), 74 kind: MacroDefKind::BuiltIn(kind),
75 local_inner: false, 75 local_inner: false,
76 }), 76 }),
77 Either::Right(kind) => Some(MacroDefId { 77 Either::Right(kind) => Some(MacroDefId {
78 krate: Some(krate), 78 krate,
79 ast_id: Some(ast_id), 79 ast_id: Some(ast_id),
80 kind: MacroDefKind::BuiltInEager(kind), 80 kind: MacroDefKind::BuiltInEager(kind),
81 local_inner: false, 81 local_inner: false,
@@ -534,7 +534,7 @@ mod tests {
534 Either::Left(expander) => { 534 Either::Left(expander) => {
535 // the first one should be a macro_rules 535 // the first one should be a macro_rules
536 let def = MacroDefId { 536 let def = MacroDefId {
537 krate: Some(CrateId(0)), 537 krate: CrateId(0),
538 ast_id: Some(AstId::new(file_id.into(), ast_id_map.ast_id(&macro_rules))), 538 ast_id: Some(AstId::new(file_id.into(), ast_id_map.ast_id(&macro_rules))),
539 kind: MacroDefKind::BuiltIn(expander), 539 kind: MacroDefKind::BuiltIn(expander),
540 local_inner: false, 540 local_inner: false,
@@ -555,7 +555,7 @@ mod tests {
555 Either::Right(expander) => { 555 Either::Right(expander) => {
556 // the first one should be a macro_rules 556 // the first one should be a macro_rules
557 let def = MacroDefId { 557 let def = MacroDefId {
558 krate: Some(krate), 558 krate,
559 ast_id: Some(AstId::new(file_id.into(), ast_id_map.ast_id(&macro_rules))), 559 ast_id: Some(AstId::new(file_id.into(), ast_id_map.ast_id(&macro_rules))),
560 kind: MacroDefKind::BuiltInEager(expander), 560 kind: MacroDefKind::BuiltInEager(expander),
561 local_inner: false, 561 local_inner: false,
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs
index 5d3fa0518..7ab0a5e52 100644
--- a/crates/hir_expand/src/hygiene.rs
+++ b/crates/hir_expand/src/hygiene.rs
@@ -29,8 +29,8 @@ impl Hygiene {
29 MacroCallId::LazyMacro(id) => { 29 MacroCallId::LazyMacro(id) => {
30 let loc = db.lookup_intern_macro(id); 30 let loc = db.lookup_intern_macro(id);
31 match loc.def.kind { 31 match loc.def.kind {
32 MacroDefKind::Declarative => (loc.def.krate, loc.def.local_inner), 32 MacroDefKind::Declarative => (Some(loc.def.krate), loc.def.local_inner),
33 MacroDefKind::BuiltIn(_) => (loc.def.krate, false), 33 MacroDefKind::BuiltIn(_) => (Some(loc.def.krate), false),
34 MacroDefKind::BuiltInDerive(_) => (None, false), 34 MacroDefKind::BuiltInDerive(_) => (None, false),
35 MacroDefKind::BuiltInEager(_) => (None, false), 35 MacroDefKind::BuiltInEager(_) => (None, false),
36 MacroDefKind::ProcMacro(_) => (None, false), 36 MacroDefKind::ProcMacro(_) => (None, false),
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs
index 55f026c7b..d486186e5 100644
--- a/crates/hir_expand/src/lib.rs
+++ b/crates/hir_expand/src/lib.rs
@@ -224,13 +224,7 @@ impl From<EagerMacroId> for MacroCallId {
224 224
225#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 225#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
226pub struct MacroDefId { 226pub struct MacroDefId {
227 // FIXME: krate and ast_id are currently optional because we don't have a 227 pub krate: CrateId,
228 // definition location for built-in derives. There is one, though: the
229 // standard library defines them. The problem is that it uses the new
230 // `macro` syntax for this, which we don't support yet. As soon as we do
231 // (which will probably require touching this code), we can instead use
232 // that (and also remove the hacks for resolving built-in derives).
233 pub krate: Option<CrateId>,
234 pub ast_id: Option<AstId<ast::Macro>>, 228 pub ast_id: Option<AstId<ast::Macro>>,
235 pub kind: MacroDefKind, 229 pub kind: MacroDefKind,
236 230
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs
index de97ec3c2..a7656b864 100644
--- a/crates/hir_ty/src/tests/macros.rs
+++ b/crates/hir_ty/src/tests/macros.rs
@@ -686,6 +686,8 @@ mod clone {
686 trait Clone { 686 trait Clone {
687 fn clone(&self) -> Self; 687 fn clone(&self) -> Self;
688 } 688 }
689 #[rustc_builtin_macro]
690 macro Clone {}
689} 691}
690"#, 692"#,
691 ); 693 );
@@ -702,6 +704,8 @@ mod clone {
702 trait Clone { 704 trait Clone {
703 fn clone(&self) -> Self; 705 fn clone(&self) -> Self;
704 } 706 }
707 #[rustc_builtin_macro]
708 macro Clone {}
705} 709}
706#[derive(Clone)] 710#[derive(Clone)]
707pub struct S; 711pub struct S;
@@ -737,6 +741,8 @@ mod clone {
737 trait Clone { 741 trait Clone {
738 fn clone(&self) -> Self; 742 fn clone(&self) -> Self;
739 } 743 }
744 #[rustc_builtin_macro]
745 macro Clone {}
740} 746}
741"#, 747"#,
742 ); 748 );
diff --git a/crates/ide/src/goto_implementation.rs b/crates/ide/src/goto_implementation.rs
index 529004878..68c628d31 100644
--- a/crates/ide/src/goto_implementation.rs
+++ b/crates/ide/src/goto_implementation.rs
@@ -221,6 +221,8 @@ struct Foo<|>;
221mod marker { 221mod marker {
222 trait Copy {} 222 trait Copy {}
223} 223}
224#[rustc_builtin_macro]
225macro Copy {}
224"#, 226"#,
225 ); 227 );
226 } 228 }
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
index 0569cf1e5..3530a5fdb 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
@@ -38,6 +38,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
38<pre><code><span class="keyword">use</span> <span class="module">inner</span><span class="operator">::</span><span class="punctuation">{</span><span class="self_keyword">self</span> <span class="keyword">as</span> <span class="module declaration">inner_mod</span><span class="punctuation">}</span><span class="punctuation">;</span> 38<pre><code><span class="keyword">use</span> <span class="module">inner</span><span class="operator">::</span><span class="punctuation">{</span><span class="self_keyword">self</span> <span class="keyword">as</span> <span class="module declaration">inner_mod</span><span class="punctuation">}</span><span class="punctuation">;</span>
39<span class="keyword">mod</span> <span class="module declaration">inner</span> <span class="punctuation">{</span><span class="punctuation">}</span> 39<span class="keyword">mod</span> <span class="module declaration">inner</span> <span class="punctuation">{</span><span class="punctuation">}</span>
40 40
41<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="function attribute">rustc_builtin_macro</span><span class="attribute attribute">]</span>
42<span class="keyword">macro</span> <span class="unresolved_reference declaration">Copy</span> <span class="punctuation">{</span><span class="punctuation">}</span>
43
41<span class="comment">// Needed for function consuming vs normal</span> 44<span class="comment">// Needed for function consuming vs normal</span>
42<span class="keyword">pub</span> <span class="keyword">mod</span> <span class="module declaration">marker</span> <span class="punctuation">{</span> 45<span class="keyword">pub</span> <span class="keyword">mod</span> <span class="module declaration">marker</span> <span class="punctuation">{</span>
43 <span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="function attribute">lang</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"copy"</span><span class="attribute attribute">]</span> 46 <span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="function attribute">lang</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"copy"</span><span class="attribute attribute">]</span>
@@ -119,7 +122,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
119 <span class="value_param callable">f</span><span class="punctuation">(</span><span class="punctuation">)</span> 122 <span class="value_param callable">f</span><span class="punctuation">(</span><span class="punctuation">)</span>
120<span class="punctuation">}</span> 123<span class="punctuation">}</span>
121 124
122<span class="keyword">fn</span> <span class="function declaration">foobar</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-&gt;</span> <span class="keyword">impl</span> <span class="unresolved_reference">Copy</span> <span class="punctuation">{</span><span class="punctuation">}</span> 125<span class="keyword">fn</span> <span class="function declaration">foobar</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-&gt;</span> <span class="keyword">impl</span> <span class="macro">Copy</span> <span class="punctuation">{</span><span class="punctuation">}</span>
123 126
124<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> 127<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
125 <span class="keyword">let</span> <span class="variable declaration">bar</span> <span class="operator">=</span> <span class="function">foobar</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> 128 <span class="keyword">let</span> <span class="variable declaration">bar</span> <span class="operator">=</span> <span class="function">foobar</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 1dc018a16..f53d2c3ba 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -12,6 +12,9 @@ fn test_highlighting() {
12use inner::{self as inner_mod}; 12use inner::{self as inner_mod};
13mod inner {} 13mod inner {}
14 14
15#[rustc_builtin_macro]
16macro Copy {}
17
15// Needed for function consuming vs normal 18// Needed for function consuming vs normal
16pub mod marker { 19pub mod marker {
17 #[lang = "copy"] 20 #[lang = "copy"]