From d651fa78cefecefa87fa3d7dc1e1389d275afb63 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 9 Jan 2021 16:48:58 +0100 Subject: Allow #[rustc_builtin_macro = "name"]. This makes it possible to have both std::panic and core::panic as a builtin macro, by using different builtin macro names for each. Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g. sym::Copy) is now tracked and provides that information directly. --- compiler/rustc_resolve/src/macros.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_resolve/src/macros.rs') diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index e6360cccf3b..60a1fc88631 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -285,7 +285,7 @@ impl<'a> ResolverExpand for Resolver<'a> { helper_attrs.extend( ext.helper_attrs.iter().map(|name| Ident::new(*name, span)), ); - if ext.is_derive_copy { + if ext.builtin_name == Some(sym::Copy) { self.containers_deriving_copy.insert(invoc_id); } ext @@ -1089,9 +1089,9 @@ impl<'a> Resolver<'a> { edition, ); - if result.is_builtin { + if let Some(builtin_name) = result.builtin_name { // The macro was marked with `#[rustc_builtin_macro]`. - if let Some(builtin_macro) = self.builtin_macros.get_mut(&item.ident.name) { + if let Some(builtin_macro) = self.builtin_macros.get_mut(&builtin_name) { // The macro is a built-in, replace its expander function // while still taking everything else from the source code. // If we already loaded this builtin macro, give a better error message than 'no such builtin macro'. -- cgit 1.4.1-3-g733a5