Repository: rust
Issue: `#[macro_use]` on `use` broken with gfx-rs
Labels: A-lints,S-needs-repro,A-edition-2018

With rust 2015 we can do this:
```rust
#[macro_use] extern crate gfx;

gfx_defines! {
    vertex Vertex {
        pos: [f32; 2] = "a_Pos",
    }
    pipeline rect_pipe {
        vertices: gfx::VertexBuffer<Vertex> = (),
    }
}

fn main() {}
```
But it's 2018 so we should deal with this warning:
```
warning: deprecated `#[macro_use]` directive used to import macros should be replaced at use sites with a `use` statement to import the macro instead
 --> src/main.rs:4:1
  |
4 | #[macro_use]
  | ^^^^^^^^^^^^
  |
```
OK, lets give it a try.
```rust
#![feature(rust_2018_preview)]
#![warn(rust_2018_idioms)]

use gfx;
#[macro_use] use gfx::gfx_defines;

gfx_defines! {
    vertex Vertex {
        pos: [f32; 2] = "a_Pos",
    }
    pipeline rect_pipe {
        vertices: gfx::VertexBuffer<Vertex> = (),
    }
}

fn main() {}
```
Oops!
```
error: cannot find macro `gfx_vertex_struct_meta!` in this scope
  --> src/main.rs:7:1
   |
7  | / gfx_defines! {
8  | |     vertex Vertex {
9  | |         pos: [f32; 2] = "a_Pos",
10 | |     }
...  |
13 | |     }
14 | | }
   | |_^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `gfx_pipeline!` in this scope
  --> src/main.rs:7:1
   |
7  | / gfx_defines! {
8  | |     vertex Vertex {
9  | |         pos: [f32; 2] = "a_Pos",
10 | |     }
...  |
13 | |     }
14 | | }
   | |_^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
```
Looks like it wants me to import some macros which are used internally by the one that I called. Surely that's a bug in itself. Lets try and work around it though!

Two iterations later, we have `#[macro_use] use gfx::{gfx_defines, gfx_pipeline, gfx_vertex_struct_meta, gfx_impl_struct_meta, gfx_pipeline_inner};` and an odd message.
```
error[E0282]: type annotations needed
  --> src/gui/render.rs:19:1
   |
19 | / gfx_defines! {
20 | |     vertex Vertex {
21 | |         pos: [f32; 2] = "a_Pos",
22 | |     }
...  |
70 | |     }
71 | | }
   | |_^ cannot infer type for `std::ops::Range<{integer}>`
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
```
Cargo suggests running with `-Z external-macro-backtrace`, but then complains that no such `-Z` flag exists (yes, this is a nightly build). I guessed that I should really be passing that flag to rustc and not cargo, so I tried `RUSTFLAGS="-Z external-macro-backtrace" cargo run` and got the info I was looking for.

```
error[E0282]: type annotations needed
   --> <gfx_pipeline_inner macros>:88:28
    |
1   | /      { $ ( $ field : ident : $ ty : ty , ) * } => {
2   | |      use $ crate :: pso :: {
3   | |      DataLink , DataBind , Descriptor , InitError , RawDataSet , AccessInfo } ; # [
4   | |      derive ( Clone , Debug , PartialEq ) ] pub struct Data < R : $ crate ::
...   |
88  | |      => (  ) , } ) * } for _ in 0 .. 1 {
    | |                                 ------
    | |                                 |
    | |                                 cannot infer type for `std::ops::Range<{integer}>`
    | |                                 in this expansion of `desugaring of `...`` (#7)
    | |                                 in this macro invocation (#7)
...   |
99  | |      $ ( meta . $ field . bind_to ( out , & self . $ field , man , access ) ; ) * }
100 | |      } }
    | |________- in this expansion of `gfx_pipeline_inner!` (#6)
    |
   ::: <gfx_defines macros>:1:1
    |
1   |        (
    |      __-
    |     |__|
    |    ||__|
    |   |||__|
    |  ||||
2   |  ||||  $ ( # [ $ attr : meta ] ) * vertex $ name : ident {
3   |  ||||  $ (
4   |  ||||  $ ( # [ $ field_attr : meta ] ) * $ field : ident : $ ty : ty = $ e : expr , )
...    ||||
17  |  ||||  ) => { gfx_pipeline ! ( $ name { $ ( $ field : $ ty = $ e , ) + } ) ; } ; (
    |  ||||         -------------------------------------------------------------- in this macro invocation (#5)
...    ||||
24  |  ||||  $ ( $ ( # [ $ field_attr ] ) * $ field : $ ty = $ e , ) + } } gfx_defines ! (
    |  ||||________________________________________________________________-
    | |||||________________________________________________________________|
    | |||||
25  | |||||  $ ( $ tail ) + ) ; } ; (
    | |||||                   -
    | |||||___________________|
    | |||||___________________in this macro invocation (#2)
    |  ||||                   in this macro invocation (#4)
...    ||||
37  | |||||  gfx_defines ! { $ keyword $ name { $ ( $ field : $ ty = $ e , ) + } }
38  | |||||  gfx_defines ! ( $ ( $ tail ) + ) ; } ;
    | |||||  ----------------------------------   -
    | |||||__|____________________________________|
    | ||||___|____________________________________in this expansion of `gfx_defines!` (#1)
    | |||____|____________________________________in this expansion of `gfx_defines!` (#2)
    | ||_____|____________________________________in this expansion of `gfx_defines!` (#3)
    | |      |                                    in this expansion of `gfx_defines!` (#4)
    | |      in this macro invocation (#3)
    |
   ::: <gfx_pipeline macros>:1:1
    |
1   |      / ( $ module : ident { $ ( $ field : ident : $ ty : ty = $ value : expr , ) * }
2   |      | ) => {
3   |      | # [ allow ( missing_docs ) ] pub mod $ module {
4   |      | # [ allow ( unused_imports ) ] use super :: * ; # [ allow ( unused_imports ) ]
5   |      | use super :: gfx ; gfx_pipeline_inner ! { $ ( $ field : $ ty , ) * } pub fn
    |      |                    ------------------------------------------------- in this macro invocation (#6)
6   |      | new (  ) -> Init < 'static > { Init { $ ( $ field : $ value , ) * } } } }
    |      |_________________________________________________________________________- in this expansion of `gfx_pipeline!` (#5)
    |
   ::: src/gui/render.rs:19:1
    |
19  | /      gfx_defines! {
20  | |          vertex Vertex {
21  | |              pos: [f32; 2] = "a_Pos",
22  | |          }
...   |
70  | |          }
71  | |      }
    | |______- in this macro invocation (#1)
```

The ASCII art is beautiful. But I still have no clue what is going on, especially considering that this was working fine when I was doing `#[macro_use] extern crate gfx;`.

`for _ in 0 .. 1 { }` appears to be a fully valid construct when it appears anywhere else but [here](https://docs.rs/gfx/0.17.1/src/gfx/macros/pso.rs.html#193).

version info:
```
rustc 1.29.0-nightly (6a1c0637c 2018-07-23)
binary: rustc
commit-hash: 6a1c0637ce44aeea6c60527f4c0e7fb33f2bcd0d
commit-date: 2018-07-23
host: x86_64-unknown-linux-gnu
release: 1.29.0-nightly
LLVM version: 7.0
```
gfx crate is at `0.17.1`