Skip to content

"file not found for module" compile error doesn't have an error number #39542

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

Closed
frgtn opened this issue Feb 4, 2017 · 5 comments
Closed

"file not found for module" compile error doesn't have an error number #39542

frgtn opened this issue Feb 4, 2017 · 5 comments

Comments

@frgtn
Copy link

frgtn commented Feb 4, 2017

"file not found for module" compile error does not have an error number/code, thus it cannot be easily identified/handled by external tools.

My use case is with Vim w0rp/ale plugin which does code checking as you type. It uses rustc to do "as-you-type" error checking and cargo check when a file is saved (see ale-integration-rust). Since imports cannot be resolved with "as-you-type" checking it would make sense to ignore such errors and only show them if they're detected by cargo. But since "file not found for module" doesn't have an error code I can't ignore it.

Example code src/main.rs:

mod doesnotexist;

fn main() {
    println!("Hello world");
}

When compiling I expect to get an error with an error number, something like error[E0123]: ... but no error number is provided:

$ rustc src/main.rs
error: file not found for module `doesnotexist`
 --> src/main.rs:1:5
  |
1 | mod doesnotexist;
  |     ^^^^^^^^^^^^
  |
  = help: name the file either doesnotexist.rs or doesnotexist/mod.rs inside the directory "src"
$ rustc --verbose --version
rustc 1.15.0 (10893a9a3 2017-01-19)
binary: rustc
commit-hash: 10893a9a349cdd423f2490a6984acb5b3b7c8046
commit-date: 2017-01-19
host: x86_64-apple-darwin
release: 1.15.0
LLVM version: 3.9
@jseyfried
Copy link
Contributor

@frgtn There are many errors right now that don't have error codes -- I'm not sure it would be feasible or desirable to give every error we emit today an error code.

@frgtn
Copy link
Author

frgtn commented Feb 9, 2017

@jseyfried good point, thanks for your response. Is there some formal process that error messages are assigned codes or is it historically so that first errors have codes and the ones added later do not?

This is a very minor issue and more of a nice-to-have for language integration into IDEs and editor plugins. I think it would be good if more common errors would eventually get assigned some sort of error codes (or the messages get standardised somehow) so that tools can identify them.

@jseyfried
Copy link
Contributor

@frgtn

Is there some formal process that error messages are assigned codes or is it historically so that first errors have codes and the ones added later do not?

I'm not aware of a formal process, it usually depends on whether the author thought it was worth it to add an error code.

I think it would be good if more common errors would eventually get assigned some sort of error codes (or the messages get standardised somehow) so that tools can identify them.

Error codes are subject to change though, so checking the error code isn't much more stable than e.g. checking if "file not found for module" is a prefix the error text.

Also, I'm not sure why you are expecting "file not found for module" when doing "as-you-type" checking. These error happen very early in the compilation process and causes rustc to abort before anything interesting happens. Also, import resolution errors have the potential to cause all sorts of problems later on in type checking, etc.

Why can't imports cannot be resolved with "as-you-type" checking?

@petrochenkov
Copy link
Contributor

cc @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

I'm going to give it a try.

bors added a commit that referenced this issue Feb 21, 2017
…, r=jseyfried

File not found for module error

Fixes #39542.

r? @jonathandturner

Maybe you want to take a look @pnkfelix?
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

No branches or pull requests

4 participants