]> git.lizzy.rs Git - rust.git/commit - src/tools/clippy
Auto merge of #52841 - petrochenkov:premacro, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 2 Aug 2018 21:39:14 +0000 (21:39 +0000)
committerbors <bors@rust-lang.org>
Thu, 2 Aug 2018 21:39:14 +0000 (21:39 +0000)
commit40e4b6ee3dd70a05007915bd1c15c150a7b7899f
treeb9ca402630b5a091d7fb317c270af3b8d83683bf
parent40cb4478a3f550bf12d81cdcf08cc9ef3985ed41
parentc3e54217e855a2492d9b707eb3fb7cdb6702d45a
Auto merge of #52841 - petrochenkov:premacro, r=alexcrichton

resolve: Implement prelude search for macro paths, implement tool attributes

When identifier is macro path is resolved in scopes (i.e. the first path segment - `foo` in `foo::mac!()` or `foo!()`), scopes are searched in the same order as for non-macro paths - items in modules, extern prelude, tool prelude (see later), standard library prelude, language prelude, but with some extra shadowing restrictions (names from globs and macro expansions cannot shadow names from outer scopes). See the comment in `fn resolve_lexical_macro_path_segment` for more details.

"Tool prelude" currently contains two "tool modules" `rustfmt` and `clippy`, and is searched immediately after extern prelude.
This makes the [possible long-term solution](https://github.com/rust-lang/rfcs/blob/master/text/2103-tool-attributes.md#long-term-solution) for tool attributes exactly equivalent to the existing extern prelude scheme, except that `--extern=my_crate` making crate names available in scope is replaced with something like `--tool=my_tool` making tool names available in scope.

The `tool_attributes` feature is still unstable and `#![feature(tool_attributes)]` now implicitly enables `#![feature(use_extern_macros)]`. `use_extern_macros` is a prerequisite for `tool_attributes`, so their stabilization will happen in the same order.
If `use_extern_macros` is not enabled, then tool attributes are treated as custom attributes (this is temporary, anyway).

Fixes https://github.com/rust-lang/rust/issues/52576
Fixes https://github.com/rust-lang/rust/issues/52512
Fixes https://github.com/rust-lang/rust/issues/51277
cc https://github.com/rust-lang/rust/issues/52269
src/libsyntax/attr/mod.rs
src/libsyntax/ext/expand.rs
src/libsyntax/feature_gate.rs