Skip to content

edition compatbility lint: fails to handle macro and crate with same name #57422

Closed
@ehuss

Description

@ehuss

The following code compiles without warnings in 2015:

#![warn(rust_2018_compatibility)]
#[macro_use]
extern crate serde_json;
extern crate json;

pub mod m {
    use json;
    pub fn f() {
        json::parse("").unwrap();
    }
}

pub fn f() {
    println!("{:?}", json!({}));
}

In 2018, it fails to compile with the following error:

error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130)
 --> src/lib.rs:7:9
  |
2 | #[macro_use]
  | ------------ not an extern crate passed with `--extern`
...
7 |     use json;
  |         ^^^^
  |
  = help: add #![feature(uniform_paths)] to the crate attributes to enable
note: this import refers to the macro imported here
 --> src/lib.rs:2:1
  |
2 | #[macro_use]
  | ^^^^^^^^^^^^

Notice the json macro conflicts with the json crate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions