Treat custom derive extern crates like empty modules.

This commit is contained in:
Jeffrey Seyfried 2016-10-15 07:56:54 +00:00
parent 33e3da831c
commit aac6dca21e
3 changed files with 7 additions and 27 deletions

View File

@ -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));
}
}

View File

@ -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
}

View File

@ -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() {}