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

resolve: nonsensical diagnostics for an expression that resolves to a module #33186

Closed
jseyfried opened this issue Apr 25, 2016 · 0 comments · Fixed by #33190
Closed

resolve: nonsensical diagnostics for an expression that resolves to a module #33186

jseyfried opened this issue Apr 25, 2016 · 0 comments · Fixed by #33190

Comments

@jseyfried
Copy link
Contributor

jseyfried commented Apr 25, 2016

This code:

mod foo {}

fn main() {
    let v = Vec::new();
    v.push(foo);
}

produces these diagnostics:

<anon>:5:12: 5:15 error: unresolved name `foo` [E0425]
<anon>:5     v.push(foo);
                    ^~~
<anon>:5:12: 5:15 help: see the detailed explanation for E0425
<anon>:5:12: 5:15 help: To call a function from the `foo` module, use `foo::push(..)`

The suggestion doesn't make sense -- we should instead emit something like "modules are not valid expressions".

@jseyfried jseyfried changed the title resolve: nonsensical diagnostics for an expression the resolves to a module resolve: nonsensical diagnostics for an expression that resolves to a module Apr 25, 2016
bors added a commit that referenced this issue May 2, 2016
resolve: improve diagnostics and lay groundwork for resolving before ast->hir

This PR improves diagnostics in `resolve` and lays some groundwork for resolving before ast->hir.

More specifically,
 - It removes an API in `resolve` intended for external refactoring tools (see #27493) that appears not to be in active use. The API is incompatible with resolving before ast->hir, but could be rewritten in a more compatible and less intrusive way.
 - It improves the diagnostics for pattern bindings that conflict with `const`s.
 - It improves the diagnostics for modules used as expressions (fixes #33186).
 - It refactors away some uses of the hir map, which is unavavailable before ast->hir lowering.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant