Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros 1.1: future proofing and cleanup #37198

Merged
merged 3 commits into from
Oct 19, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
@@ -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));
}
}

25 changes: 0 additions & 25 deletions src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-2.rs

This file was deleted.

3 changes: 1 addition & 2 deletions src/test/compile-fail-fulldeps/proc-macro/shadow.rs
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm isn't this testing something else than before? Before it was preventing two #[proc_macro_derive(A)] was an error, but here it's erroring out on the extern crate annotations?

Copy link
Contributor Author

@jseyfried jseyfried Oct 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it used to test that a #[macro_use]-imported custom derive cannot shadow an existing #[macro_use]-imported custom derive.

This PR changes #[macro_use]-imported custom derives to have the same scope and shadowing restrictions as other #[macro_use]-imported macros, so it is no longer an error for an unexpanded #[macro_use] to import a shadowing custom derive (just as it is not an error today for ordinary unexpanded #[macro_use]s to shadow).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(c.f. the second bullet point in the initial comment)


fn main() {}