In the following scenario, the user will have a better experience if we allow them to have an "unused" extern crate. --- [**[playground]**](https://play.rust-lang.org/?gist=73eada4e1502ddc50114bc53b11e792c&version=nightly) ```rust //extern crate serde; struct NotSerializable; struct TryingToSerialize { bad: NotSerializable, } // Code generated by a macro like #[derive(Serialize)]. const IMPL_SERIALIZE_FOR_TryingToSerialize: () = { extern crate serde; impl serde::Serialize for TryingToSerialize { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { serde::Serialize::serialize(&self.bad, serializer) } } }; ``` --- If we permit them to write `extern crate`, as recommended by Serde's docs for this reason, the error message is: ``` 8 | #[derive(Serialize)] | ^^^^^^^^^ the trait `serde::Serialize` is not implemented for `NotSerializable` ``` If they remove the unused `extern crate`, they generally get nastier error messages. ``` 8 | #[derive(Serialize)] | ^^^^^^^^^ the trait `_IMPL_SERIALIZE_FOR_TryingToSerialize::_serde::Serialize` is not implemented for `NotSerializable` ``` --- If we can't fix the error message to be as good as it was before the unused_extern_crates warning, let's disable unused_extern_crates in cases where the same crate is used later in some nested scope (submodule or code block). --- cc @ishitatsuyuki who has been involved with this warning.