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

error: unresolved import #2915

Closed
jesse99 opened this issue Jul 14, 2012 · 10 comments
Closed

error: unresolved import #2915

jesse99 opened this issue Jul 14, 2012 · 10 comments
Assignees
Labels
A-resolve Area: Name resolution
Milestone

Comments

@jesse99
Copy link
Contributor

jesse99 commented Jul 14, 2012

I know that there are a multitude of resolve tickets, but after grabbing commit 57e160b (which I think is 0.3) I am completely unable to build https://github.com/jesse99/rparse

I get the following:

rustc --test -o bin/test-rparse src/rparse.rc
error: failed to resolve imports
src/rparse.rs:8:7: 8:15 error: unresolved import
src/rparse.rs:8 import misc::*;
                       ^~~~~~~~
src/misc.rs:4:7: 4:16 error: unresolved import
src/misc.rs:4 import types::*;
                     ^~~~~~~~~
src/types.rs:3:7: 3:31 error: unresolved import
src/types.rs:3 import result = result::result;
                      ^~~~~~~~~~~~~~~~~~~~~~~~
src/tests/test_parsers.rs:1:7: 1:23 error: unresolved import
src/tests/test_parsers.rs:1 import test_helpers::*;
                                   ^~~~~~~~~~~~~~~~
src/tests/test_primitives.rs:2:7: 2:10 error: unresolved import
src/tests/test_primitives.rs:2 import io;
                                      ^~~
src/tests/test_expr.rs:2:7: 2:23 error: unresolved import
src/tests/test_expr.rs:2 import test_helpers::*;
                                ^~~~~~~~~~~~~~~~
src/tests/test_xml.rs:4:7: 4:22 error: unresolved import
src/tests/test_xml.rs:4 import to_str::to_str;
                               ^~~~~~~~~~~~~~~
src/tests/test_c99_parser.rs:1:7: 1:23 error: unresolved import
src/tests/test_c99_parser.rs:1 import test_helpers::*;
                                      ^~~~~~~~~~~~~~~~
src/tests/test_helpers.rs:2:7: 2:10 error: unresolved import
src/tests/test_helpers.rs:2 import io;
                                   ^~~
error: aborting due to 10 previous errors
make: *** [bin/test-rparse] Error 101
exited with code 2

I haven't made any progress whatsoever with these errors. Not sure what's going on. Maybe there is a problem with my code somewhere, but "unresolved import" is certainly not helping me find anything. Note that the code did build a week or two ago (when brson went through all the cargo packages and fixed them up).

I also tried head as of evening Friday, Jul 13 PST with the same results.

@jesse99
Copy link
Contributor Author

jesse99 commented Jul 14, 2012

The commit that worked for me with rparse is 1eae497

@jesse99
Copy link
Contributor Author

jesse99 commented Jul 14, 2012

Seems 0.3 was never merged into master so I was not using 0.3. Will try again soon with the commit labeled "release-0.3" on incoming.

@jesse99
Copy link
Contributor Author

jesse99 commented Jul 15, 2012

Tried compiling rparse with 2f32a15 which I think is 0.3 and got the same unresolved import disaster.

@eugenkiss
Copy link

I just want to add that I'm experiencing the same errors (for another really small project) since installing rust 0.3 with homebrew.

EDIT: Sorry, it was an error on my part. Apparently, the structure of modules/crates changed, so that I must not write e.g. import std::list but instead import list.

@catamorphism
Copy link
Contributor

With Rust HEAD, I see the first three unresolved imports, but not the others.

I'm able to make resolve succeed by changing import types::* in misc.rs to import types::{parser, state, status};. After that I get a lot of other errors due to this code being behind the syntax that HEAD expects, but resolve does complete.

When in doubt, when resolve doesn't work, change glob imports to specific imports.

That said, either this should work with the glob-import as is, or the error message should be better, so I'm deferring to @pcwalton .

@ghost ghost assigned pcwalton Jul 20, 2012
@jesse99
Copy link
Contributor Author

jesse99 commented Jul 22, 2012

Thanks catamorphism. I was able to get past this issue using your tactic, but am still dealing with a blizzard of unrelated errors.

Hopefully I can get a better repro for the resolve error: I think it may be related to circular module imports. Possibly involving what seems to be special handling of the "main" module (the one named after the rc file).

@jesse99
Copy link
Contributor Author

jesse99 commented Jul 22, 2012

Spent all day, but I finally have rparse compiling with rust HEAD from master (as of July 22). I can repro the original problem by:

  1. adding import misc::*; to str_parsers.rs
  2. adding import str_parsers::*; to misc.rs

When I do that I get 11+ unresolved import errors:

rustc --test -o bin/test-rparse src/rparse.rc
error: failed to resolve imports
src/rparse.rs:7:7: 7:22 error: unresolved import
src/rparse.rs:7 import str_parsers::*;
                       ^~~~~~~~~~~~~~~
src/types.rs:2:7: 2:31 error: unresolved import
src/types.rs:2 import result = result::result;
                      ^~~~~~~~~~~~~~~~~~~~~~~~
src/tests/test_c99_parser.rs:1:7: 1:23 error: unresolved import
src/tests/test_c99_parser.rs:1 import test_helpers::*;
                                      ^~~~~~~~~~~~~~~~
src/tests/test_helpers.rs:2:7: 2:10 error: unresolved import
src/tests/test_helpers.rs:2 import io;
                                   ^~~
src/tests/test_parsers.rs:1:7: 1:23 error: unresolved import
src/tests/test_parsers.rs:1 import test_helpers::*;
                                   ^~~~~~~~~~~~~~~~
src/tests/test_primitives.rs:2:7: 2:10 error: unresolved import
src/tests/test_primitives.rs:2 import io;
                                      ^~~
src/tests/test_expr.rs:2:7: 2:23 error: unresolved import
src/tests/test_expr.rs:2 import test_helpers::*;
                                ^~~~~~~~~~~~~~~~
src/tests/test_xml.rs:4:7: 4:22 error: unresolved import
src/tests/test_xml.rs:4 import to_str::to_str;
                               ^~~~~~~~~~~~~~~
src/str_parsers.rs:2:7: 2:15 error: unresolved import
src/str_parsers.rs:2 import misc::*;
                            ^~~~~~~~
src/misc.rs:4:7: 4:22 error: unresolved import
src/misc.rs:4 import str_parsers::*;
                     ^~~~~~~~~~~~~~~
error: aborting due to 11 previous errors

Seem to be a number of problems here:

  1. It's not clear that this should be an error.
  2. The error message is distinctly unhelpful.
  3. The error doesn't point to anywhere useful.

@jesse99
Copy link
Contributor Author

jesse99 commented Jul 26, 2012

It's not just circular module references that land you here: it can also happen with crates with multiple files that use the wildcard imports.

And it can be rather painful to fix this. You need to guess where the problem is and start, more or less blindly, replacing wildcard imports with potentially big long curly brace lists. Not fun.

@jesse99
Copy link
Contributor Author

jesse99 commented Sep 2, 2012

This ticket should probably be closed since there isn't a good repro and rparse is building now. However it would be good to have a ticket for better resolve error messages.

@jesse99
Copy link
Contributor Author

jesse99 commented Nov 19, 2012

I've been able to build rparse in a sane way now. There are also a few tickets open for improved resolve error messages (e.g. #3004) so I'm closing this.

@jesse99 jesse99 closed this as completed Nov 19, 2012
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jun 29, 2023
use as_os_str_bytes

Make use of the new operations recently added (tracking issue: rust-lang#111544). At least the "host OsStr to target bytes" direction now works even for non-utf-8 strings on all hosts!
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Rename the file to use '-' instead of `_` and add the new page to the
index. Fixed version can be seen here:
https://celinval.github.io/kani-dev/stable-mir.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name resolution
Projects
None yet
Development

No branches or pull requests

4 participants