Skip to content

Regression importing log’s warn! macro inside of include!()ed file #53205

Closed
@SimonSapin

Description

@SimonSapin

Cargo.toml

[package]
name = "foo"
version = "0.0.0"

[dependencies]
log = "0.4"

src/main.rs

include!("real_main.rs");

src/real_main.rs

#[macro_use] extern crate log;

fn main() {
    warn!("!!!");
}

Code like this used to build correctly:

$ rustup run --install nightly-2018-08-02 rustc -V 
rustc 1.29.0-nightly (97085f9fb 2018-08-01)
$ rustup run --install nightly-2018-08-02 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/foo`

And now produces an error whose message seems wrong: it points at the call site of a macro as a "name also defined here":

$ rustup run --install nightly-2018-08-03 rustc -V
rustc 1.30.0-nightly (7e8ca9f8b 2018-08-03)
$ rustup run --install nightly-2018-08-03 cargo run
   Compiling foo v0.0.0 (file:///tmp/foo)
error[E0659]: `warn` is ambiguous
 --> src/real_main.rs:4:5
  |
4 |     warn!("!!!");
  |     ^^^^
  |
note: `warn` could refer to the name imported here
 --> src/real_main.rs:1:1
  |
1 | #[macro_use] extern crate log;
  | ^^^^^^^^^^^^
note: `warn` could also refer to the name defined here
 --> src/real_main.rs:4:5
  |
4 |     warn!("!!!");
  |     ^^^^
  = note: macro-expanded macro imports do not shadow

error: aborting due to previous error

For more information about this error, try `rustc --explain E0659`.
error: Could not compile `foo`.

To learn more, run the command again with --verbose.

Commit range between these two nightlies: 97085f9...7e8ca9f

#52841 is the only PR in the range that seems relevant. CC @petrochenkov, @alexcrichton

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions