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

Misleading error message when ambiguity between a function and module is introduced #71406

Closed
davidbarsky opened this issue Apr 21, 2020 · 2 comments · Fixed by #71419
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@davidbarsky
Copy link
Contributor

Given this code (playground):

use tokio::sync::mpsc;

fn main() {
    let (tx, rx) = mpsc::channel::new(1);
}

I expected that rustc would indicate that new() is not function but channel(1) is. Instead, I got:

   Compiling playground v0.0.1 (/playground)
error[E0433]: failed to resolve: could not find `channel` in `mpsc`
 --> src/main.rs:4:26
  |
4 |     let (tx, rx) = mpsc::channel::new(1);
  |                          ^^^^^^^ could not find `channel` in `mpsc`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
error: could not compile `playground`.

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

A diagnostic along the lines of new(..) isn't a function, but channel(..) is would be helpful.

Meta

rustc --version --verbose:

❯ rustc --version --verbose
rustc 1.42.0 (b8cedc004 2020-03-09)
binary: rustc
commit-hash: b8cedc00407a4c56a3bda1ed605c6fc166655447
commit-date: 2020-03-09
host: x86_64-apple-darwin
release: 1.42.0
LLVM version: 9.0

@davidbarsky davidbarsky added the C-bug Category: This is a bug. label Apr 21, 2020
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution 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. and removed C-bug Category: This is a bug. labels Apr 21, 2020
@estebank estebank added the D-papercut Diagnostics: An error or lint that needs small tweaks. label Apr 21, 2020
@contrun
Copy link
Contributor

contrun commented Apr 22, 2020

I tried to resolve this issue with #71419

The error message now is

`channel` in `mpsc` is a concrete value (function, constant), not a module or Struct you specified

Any informative error message suggestions?

@davidbarsky
Copy link
Contributor Author

@contrun Thanks for trying to address this. I'll comment on the PR you opened.

@bors bors closed this as completed in 94ac0ac Apr 27, 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-resolve Area: Name resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants