Skip to content

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

Closed
@davidbarsky

Description

@davidbarsky

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions