rust/src/libsyntax_pos
bors 0b90e4e8cd Auto merge of #46551 - jseyfried:improve_legacy_modern_macro_interaction, r=nrc
macros: improve 1.0/2.0 interaction

This PR supports using unhygienic macros from hygienic macros without breaking the latter's hygiene.
```rust
// crate A:
#[macro_export]
macro_rules! m1 { () => {
    f(); // unhygienic: this macro needs `f` in its environment
    fn g() {} // (1) unhygienic: `g` is usable outside the macro definition
} }

// crate B:
#![feature(decl_macro)]
extern crate A;
use A::m1;

macro m2() {
    fn f() {} // (2)
    m1!(); // After this PR, `f()` in the expansion resolves to (2), not (3)
    g(); // After this PR, this resolves to `fn g() {}` from the above expansion.
         // Today, it is a resolution error.
}

fn test() {
    fn f() {} // (3)
    m2!(); // Today, `m2!()` can see (3) even though it should be hygienic.
    fn g() {} // Today, this conflicts with `fn g() {}` from the expansion, even though it should be hygienic.
}
```

Once this PR lands, you can make an existing unhygienic macro hygienic by wrapping it in a hygienic macro. There is an [example](b766fa887d) of this in the tests.

r? @nrc
2018-01-12 10:00:09 +00:00
..
Cargo.toml
hygiene.rs Auto merge of #46551 - jseyfried:improve_legacy_modern_macro_interaction, r=nrc 2018-01-12 10:00:09 +00:00
lib.rs incr.comp.: Precompute small hash for filenames to save some work. 2017-12-19 15:27:50 +01:00
span_encoding.rs Fix comment formatting 2017-11-05 01:24:20 +02:00
symbol.rs Auto merge of #46497 - AgustinCB:issue-46311, r=petrochenkov 2017-12-07 21:05:49 +00:00