]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #37247 - jseyfried:future_proof_no_link, r=nrc
authorbors <bors@rust-lang.org>
Fri, 21 Oct 2016 08:48:31 +0000 (01:48 -0700)
committerGitHub <noreply@github.com>
Fri, 21 Oct 2016 08:48:31 +0000 (01:48 -0700)
macros: Future proof `#[no_link]`

This PR future proofs `#[no_link]` for macro modularization (cc #35896).

First, we resolve all `#[no_link] extern crate`s. `#[no_link]` crates without `#[macro_use]` or `#[macro_reexport]` are not resolved today, this is a [breaking-change]. For example,
```rust
```
Any breakage can be fixed by simply removing the `#[no_link] extern crate`.

Second, `#[no_link] extern crate`s will define an empty module in type namespace to eventually allow importing the crate's macros with `use`. This is a [breaking-change], for example:
```rust
mod syntax {} //< This becomes a duplicate error.
```

r? @nrc

1  2 
src/librustc_resolve/build_reduced_graph.rs

index f19afd67faa212da8442ac9688c3d9c54ab60288,a5bc708b4f05a672dca91624bda01f6ca50978c5..9ed7be5af4e55fbd1cbf076827eb9baedea64b1c
@@@ -255,19 -249,8 +255,19 @@@ impl<'b> Resolver<'b> 
                      });
                      self.define(parent, name, TypeNS, (module, sp, vis));
  
 +                    if let Some(mark) = opt_mark {
 +                        let invocation = self.arenas.alloc_invocation_data(InvocationData {
 +                            module: Cell::new(module),
 +                            def_index: CRATE_DEF_INDEX,
 +                            const_integer: false,
 +                            legacy_scope: Cell::new(LegacyScope::Empty),
 +                            expansion: Cell::new(LegacyScope::Empty),
 +                        });
 +                        self.invocations.insert(mark, invocation);
 +                    }
 +
                      self.populate_module_if_necessary(module);
-                 } else if custom_derive_crate {
+                 } else {
                      // 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));