{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/50672","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/50672/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/50672/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/50672/events","html_url":"https://github.com/rust-lang/rust/issues/50672","id":322445532,"number":50672,"title":"Lint for removing `extern crate` has false positive when crate is used","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"labels":[{"id":930400927,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-rust-2018-preview","name":"A-rust-2018-preview","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-11T21:53:12Z","updated_at":"2018-05-11T21:55:10Z","closed_at":null,"author_association":"OWNER","body":"The [following code](https://play.rust-lang.org/?gist=18ff3facf246fe36e51170f368d373c4&version=nightly&mode=debug)\r\n\r\n```rust\r\n#![feature(rust_2018_preview)]\r\n#![deny(unnecessary_extern_crate)]\r\n#![allow(unused_imports)]\r\n\r\nextern crate libc;\r\n\r\nmod foo {\r\n    use crate::libc;\r\n}\r\n\r\nfn main() {}\r\n```\r\n\r\ngenerates an error:\r\n\r\n```\r\nerror: `extern crate` is unnecessary in the new edition\r\n --> src/main.rs:5:1\r\n  |\r\n5 | extern crate libc;\r\n  | ^^^^^^^^^^^^^^^^^^ help: remove it\r\n  |\r\nnote: lint level defined here\r\n --> src/main.rs:2:9\r\n  |\r\n2 | #![deny(unnecessary_extern_crate)]\r\n  |         ^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nerror: aborting due to previous error\r\n\r\nerror: Could not compile `playground`.\r\n```\r\n\r\nbut if the `extern crate libc;` is removed it no longer compiles!\r\n\r\n\r\nThis situation has come up on two occasions so far:\r\n\r\n1. In attempting to fix https://github.com/rust-lang/rust/issues/50660 the lint started firing for `use libc;` and rustfix rewrote it to `use crate::libc;`. This worked in the 2015 edition because `extern crate libc;` was declared at the top. Later this `unnecessary_extern_crate` lint ended up showing the error above.\r\n2. Discovered in https://github.com/rust-lang/rust/pull/50665 the `use *;` statement is entirely disallowed in the 2018 edition, so we instead recommend the replacement `use crate::*;`. This, however, will also break if one of the identifiers used is an `extern crate` as the lint currently suggests removing `extern crate`"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/388495579","html_url":"https://github.com/rust-lang/rust/issues/50672#issuecomment-388495579","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/50672","id":388495579,"user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"created_at":"2018-05-11T21:55:10Z","updated_at":"2018-05-11T21:55:10Z","author_association":"OWNER","body":"cc @Manishearth "}}
{"actor":{"display_login":"alexcrichton"}}