about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-10-15 07:56:54 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-10-15 22:55:21 +0000
commitaac6dca21e6a78a8bdf3406f682e2b1a7a7bdc36 (patch)
tree2bea1d584079c06389fe2c454156715048a2d8c8
parent33e3da831c8b517c94d85599edf2bcd259128181 (diff)
Treat custom derive extern crates like empty modules.
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs6
-rw-r--r--src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-2.rs25
-rw-r--r--src/test/compile-fail-fulldeps/proc-macro/shadow.rs3
3 files changed, 7 insertions, 27 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index dac9e57be32..e0abe8da82b 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -250,6 +250,12 @@ impl<'b> Resolver<'b> {
                     self.define(parent, name, TypeNS, (module, sp, vis));
 
                     self.populate_module_if_necessary(module);
+                } else if custom_derive_crate {
+                    // Define an empty module
+                    let def = Def::Mod(self.definitions.local_def_id(item.id));
+                    let module = ModuleS::new(Some(parent), ModuleKind::Def(def, name));
+                    let module = self.arenas.alloc_module(module);
+                    self.define(parent, name, TypeNS, (module, sp, vis));
                 }
             }
 
diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-2.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-2.rs
deleted file mode 100644
index 4aa4238611d..00000000000
--- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-2.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// force-host
-// no-prefer-dynamic
-
-#![feature(proc_macro)]
-#![feature(proc_macro_lib)]
-#![crate_type = "proc-macro"]
-
-extern crate proc_macro;
-
-use proc_macro::TokenStream;
-
-#[proc_macro_derive(A)]
-pub fn derive_a(input: TokenStream) -> TokenStream {
-    input
-}
diff --git a/src/test/compile-fail-fulldeps/proc-macro/shadow.rs b/src/test/compile-fail-fulldeps/proc-macro/shadow.rs
index 7b1a73d50f6..a04756ca19b 100644
--- a/src/test/compile-fail-fulldeps/proc-macro/shadow.rs
+++ b/src/test/compile-fail-fulldeps/proc-macro/shadow.rs
@@ -9,13 +9,12 @@
 // except according to those terms.
 
 // aux-build:derive-a.rs
-// aux-build:derive-a-2.rs
 
 #![feature(proc_macro)]
 
 #[macro_use]
 extern crate derive_a;
 #[macro_use]
-extern crate derive_a_2; //~ ERROR: cannot shadow existing derive mode `A`
+extern crate derive_a; //~ ERROR `derive_a` has already been defined
 
 fn main() {}