rust/src/test
bors 4f9c9ed1a5 Auto merge of #40847 - jseyfried:decl_macro, r=nrc
Initial implementation of declarative macros 2.0

Implement declarative macros 2.0 (rust-lang/rfcs#1584) behind `#![feature(decl_macro)]`.
Differences from `macro_rules!` include:
 - new syntax: `macro m(..) { .. }` instead of `macro_rules! m { (..) => { .. } }`
 - declarative macros are items:
```rust
// crate A:
pub mod foo {
    m!(); // use before definition; declaration order is irrelevant
    pub macro m() {} // `pub`, `pub(super)`, etc. work
}
fn main() {
    foo::m!(); // named like other items
    { use foo::m as n; n!(); } // imported like other items
}
pub use foo::m; // re-exported like other items

// crate B:
extern crate A; // no need for `#[macro_use]`
A::foo::m!(); A::m!();
```
 - Racket-like hygiene for items, imports, methods, fields, type parameters, privacy, etc.
   - Intuitively, names in a macro definition are resolved in the macro definition's scope, not the scope in which the macro is used.
   - This [explaination](http://beautifulracket.com/explainer/hygiene.html) of hygiene for Racket applies here (except for the "Breaking Hygiene" section). I wrote a similar [explanation](https://github.com/jseyfried/rfcs/blob/hygiene/text/0000-hygiene.md) for Rust.
   - Generally speaking, if `fn f() { <body> }` resolves, `pub macro m() { <body> } ... m!()` also resolves, even if `m!()` is in a separate crate.
   - `::foo::bar` in a `macro` behaves like `$crate::foo::bar` in a `macro_rules!`, except it can access everything visible from the `macro` (thus more permissive).
   - See [`src/test/{run-pass, compile-fail}/hygiene`](https://github.com/rust-lang/rust/pull/40847/commits/afe7d89858fd72b983e24727d6f4058293153c19) for examples. Small example:
```rust
mod foo {
    fn f() { println!("hello world"); }
    pub macro m() { f(); }
}
fn main() { foo::m!(); }
```

Limitations:
 - This does not address planned changes to matchers (`expr`,`ty`, etc.), c.f. #26361.
 - Lints (including stability and deprecation) and `unsafe` are not hygienic.
   - adding hygiene here will be mostly or entirely backwards compatible
 - Nested macro definitions (a `macro` inside another `macro`) don't always work correctly when invoked from external crates.
   - pending improvements in how we encode macro definitions in crate metadata
 - There is no way to "escape" hygiene without using a procedural macro.

r? @nrc
2017-05-25 22:31:34 +00:00
..
codegen Add simple [repr(align)] codegen test. 2017-05-01 23:13:22 +10:00
codegen-units translate drop glue using MIR 2017-03-18 02:53:08 +02:00
compile-fail Auto merge of #40847 - jseyfried:decl_macro, r=nrc 2017-05-25 22:31:34 +00:00
compile-fail-fulldeps Remove some needless // gate-test- comments 2017-05-23 20:17:38 +02:00
debuginfo debuginfo: Generate unique DW_AT_names for compilation units to work around OSX linker bug. 2017-05-19 13:06:30 +02:00
incremental Enable cross-crate incremental compilation by default. 2017-05-18 10:12:13 +02:00
mir-opt Auto merge of #42023 - nikomatsakis:issue-36799-ostn15_phf, r=arielb1 2017-05-23 09:55:40 +00:00
parse-fail remove "much" from unicode diagnostic 2017-05-20 11:18:26 -04:00
pretty
run-fail Unignore tests which work fine now. 2017-04-28 22:31:10 -06:00
run-fail-fulldeps Implement a file-path remapping feature in support of debuginfo and reproducible builds. 2017-04-26 15:44:02 +02:00
run-make fix atomic_lock_free test case 2017-05-22 17:11:39 -04:00
run-pass Auto merge of #40847 - jseyfried:decl_macro, r=nrc 2017-05-25 22:31:34 +00:00
run-pass-fulldeps Fix #35829 (syntax extension's quote_expr!() does not handle b"…") 2017-05-13 21:41:25 +08:00
run-pass-valgrind
rustdoc rustdoc: Fix names of items in cross crate reexported modules 2017-05-22 02:05:16 +01:00
ui Rollup merge of #42150 - citizen428:feature/error-count-messages, r=Mark-Simulacrum 2017-05-24 19:50:05 -06:00
ui-fulldeps/custom-derive Separate "ui-fulldeps" tests from "ui" tests 2017-03-04 21:38:26 +03:00
COMPILER_TESTS.md Move COMPILER_TESTS.md out of the root directory 2017-02-25 00:13:00 -06:00