Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing error message when wildcard importing two same-named traits #54156

Open
mehcode opened this issue Sep 12, 2018 · 0 comments
Open

Confusing error message when wildcard importing two same-named traits #54156

mehcode opened this issue Sep 12, 2018 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-traits Area: Trait system C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@mehcode
Copy link
Contributor

mehcode commented Sep 12, 2018

Discovered this when using tokio-async-await and futures. Both define FutureExt and StreamExt traits in their preludes. Both traits are meant to be used at the same time (from what I understand).

use tokio::prelude::*;  // contains StreamExt, FutureExt
use futures::prelude::*;  // contains StreamExt, FutureExt

After doing both this imports rust proceeds to act like neither of the traits got imported and give error help on any method usage something like "trait not in scope; use tokio::async_await::stream::StreamExt".

Here is a Rust playground illustrating the bug: https://play.rust-lang.org/?gist=c8ebd2f79eca354ecb2dd6c828d73ad0&version=nightly&mode=debug&edition=2015

And here is a work-around for it (in nightly): https://play.rust-lang.org/?gist=f28928ef69a1985ee79d321cb58ae7e1&version=nightly&mode=debug&edition=2015

I think the way forward here is a good warning (or error) message when a duplicate trait item import happens between two wildcard imports.

@zackmdavis zackmdavis added the A-diagnostics Area: Messages for errors, warnings, and lints label Sep 12, 2018
@estebank estebank added A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 25, 2020
@crlf0710 crlf0710 added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-traits Area: Trait system C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants