-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
File not found for module error #39765
File not found for module error #39765
Conversation
src/libsyntax/diagnostic_list.rs
Outdated
Erroneous code example: | ||
|
||
```compile_fail,E0583 | ||
mod file_that_doesnt_exist; // error: ile not found for module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "ile not found for module"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups, thanks!
@@ -224,4 +291,5 @@ register_diagnostics! { | |||
E0555, // malformed feature attribute, expected #![feature(...)] | |||
E0556, // malformed feature, expected just one word | |||
E0557, // feature has been removed | |||
E0584, // file for module `..` found at both .. and .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the other newly added errors be registered as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know how to trigger this one and not enough time to investigate. Someone will do it later on if I don't myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error occurs for mod foo;
when both foo.rs
and foo/mod.rs
exist. There's a test: cfail/mod_file_disambig.
ed430c8
to
57bc7de
Compare
fn foo() {} | ||
``` | ||
"##, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature flags will be needed in these examples, also the cfail tests for inclusive ranges.
@durka: I added the corresponding tests already. Take a look at the new files in |
Yeah but you are missing |
It's not needed as far as I can tell... ? At least when I test, I have no missing feature issue. |
Huh... I guess since this error is generated in the parser it occurs before
the unstable feature check. So it's okay I guess.
…On Mon, Feb 13, 2017 at 11:54 AM, Guillaume Gomez ***@***.***> wrote:
It's not needed as far as I can tell... ? At least when I test, I have no
missing feature issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39765 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n2GC6GEfxqv3beixvW_uCblHhPn5ks5rcIrIgaJpZM4L-f60>
.
|
I'm cool with this change, but you probably want to ping someone on the compiler team to double-check the logic. I haven't done much with the module system, yet. |
cc @rust-lang/compiler |
src/libsyntax/diagnostic_list.rs
Outdated
@@ -201,6 +201,73 @@ where appropriate is ongoing. Try using an unquoted name instead: | |||
pub fn something() {} | |||
``` | |||
"##, | |||
|
|||
E0583: r##" | |||
A file wasn't found for a module import. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to call mod foo;
a "module import"?
I've heard it called an "out-of-line module", but never heard "module import" except to refer to a use
import of a module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you reword it then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call it a "module item" or an "out-of-line module".
src/libsyntax/diagnostic_list.rs
Outdated
fn main() {} | ||
``` | ||
|
||
Please be sure that a file corresponding to the module really exist. So if you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: really exists. So
src/libsyntax/diagnostic_list.rs
Outdated
|
||
Please be sure that a file corresponding to the module really exist. So if you | ||
want to import a `file_that_doesnt_exist` module, you need to have a | ||
`file_that_doesnt_exist.rs` file at the same level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or file_that_doesnt_exist/mod.rs
src/libsyntax/diagnostic_list.rs
Outdated
"##, | ||
|
||
E0585: r##" | ||
A documentation comment which doesn't comment anything was found. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/which/that/, s/comment/document/
src/libsyntax/diagnostic_list.rs
Outdated
} | ||
``` | ||
|
||
Documentation comments need to be used on items like functions, types, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/used on/followed by/, s/like/including/
src/libsyntax/parse/parser.rs
Outdated
mod_name: mod_name.clone(), | ||
default_path: default_path_str, | ||
secondary_path: secondary_path_str, | ||
dir_path: format!("{}", dir_path.display()) }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a newline before the }),
src/libsyntax/parse/parser.rs
Outdated
dir_path: format!("{}", dir_path.display()) }), | ||
(true, true) => Err(Errors::DuplicatePaths { mod_name: mod_name.clone(), | ||
default_path: default_path_str, | ||
secondary_path: secondary_path_str }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: block indenting is more idiomatic here.
src/libsyntax/parse/parser.rs
Outdated
match paths.result { | ||
Ok(succ) => Ok(succ), | ||
Err(err) => Err(self.span_fatal_err(id_sp, err)), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we could use map_err
here instead of match
.
fn main() { | ||
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; | ||
let x = &tmp[1...]; //~ ERROR E0586 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no trailing new newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/libsyntax/parse/parser.rs
Outdated
dir_path: String }, | ||
DuplicatePaths { mod_name: String, default_path: String, secondary_path: String }, | ||
UselessDocComment, | ||
InclusiveRangeWithNoEnd, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this variant? I think it would be simpler to just emit the error directly in the relevant parsing function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to centralize the errors. Making them easier to spot and modify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think UselessDocComment
and InclusiveRangeWithNoEnd
would be more appropriate as methods on the Parser
, since they don't have anything to do with with the first two variants (except that they are errors during parsing).
Then, the enum could be named ModulePathError
-- clearer and more precise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point isn't to group same kind of errors but to centralize them.
57bc7de
to
3235835
Compare
@jseyfried: Is it ok for you now? ;) |
src/libsyntax/diagnostic_list.rs
Outdated
``` | ||
|
||
Please be sure that a file corresponding to the module exists. If you | ||
want to import a `file_that_doesnt_exist` module, you need to have a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not "import"ing here -- I would say "define", "declare", or "use" instead.
Also I would say "a module named file_that_doesnt_exist
" instead of "a file_that_doesnt_exist
module".
src/libsyntax/diagnostic_list.rs
Outdated
|
||
Please be sure that a file corresponding to the module exists. If you | ||
want to import a `file_that_doesnt_exist` module, you need to have a | ||
`file_that_doesnt_exist/mod.rs` file at the same level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user can have file_that_doesnt_exist.rs
or file_that_doesnt_exist/mod.rs
-- we need to mention both options here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I would say "in the same directory" instead of "at the same level".
src/libsyntax/diagnostic_list.rs
Outdated
} | ||
``` | ||
|
||
Documentation comments need to be followed items including functions, types, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to be followed by items**,** including
(add "by" and ",")
src/libsyntax/diagnostic_list.rs
Outdated
``` | ||
|
||
Documentation comments need to be followed items including functions, types, | ||
modules, etc... Examples: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one "." here.
src/libsyntax/parse/parser.rs
Outdated
"doc comments must come before what they document, maybe a \ | ||
comment was intended with `//`?"); | ||
Errors::UselessDocComment.span_err(s.prev_span, s.diagnostic()) | ||
.emit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're not getting rid of span_fatal_err
, shouldn't we use it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely!
3235835
to
1e27c61
Compare
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me modulo comments
src/libsyntax/diagnostic_list.rs
Outdated
|
||
Please be sure that a file corresponding to the module exists. If you | ||
want to use a module named `file_that_doesnt_exist`, you need to have a | ||
`file_that_doesnt_exist.rs` or a `file_that_doesnt_exist/mod.rs` file in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you need to have a file_that_doesnt_exist.rs
or file_that_doesnt_exist/mod.rs
file in the same directory.
or: you need to have a file named file_that_doesnt_exist.rs
or file_that_doesnt_exist/mod.rs
in the same directory.
src/libsyntax/parse/parser.rs
Outdated
@@ -233,6 +233,63 @@ pub struct ModulePathError { | |||
pub help_msg: String, | |||
} | |||
|
|||
pub enum Errors { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional nit: Error
would be a more idiomatic name
1e27c61
to
a9f22d7
Compare
Ok, I fixed the two last nits. If you find anything else, don't hesitate to r-! @bors: r=jseyfried |
📌 Commit a9f22d7 has been approved by |
src/libsyntax/parse/parser.rs
Outdated
InclusiveRangeWithNoEnd, | ||
} | ||
|
||
impl Errors { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors
-> Error
(won't pass travis)
src/libsyntax/parse/parser.rs
Outdated
Error::FileNotFoundForModule { ref mod_name, | ||
ref default_path, | ||
ref secondary_path, | ||
ref dir_path } => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indent (one extra space)
src/libsyntax/parse/parser.rs
Outdated
@@ -955,6 +1009,9 @@ impl<'a> Parser<'a> { | |||
pub fn span_fatal(&self, sp: Span, m: &str) -> DiagnosticBuilder<'a> { | |||
self.sess.span_diagnostic.struct_span_fatal(sp, m) | |||
} | |||
pub fn span_fatal_err(&self, sp: Span, err: Errors) -> DiagnosticBuilder<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here (Errors
-> Error
), etc.
src/libsyntax/parse/parser.rs
Outdated
ref default_path, | ||
ref secondary_path, | ||
ref dir_path } => { | ||
let mut err = struct_span_er!(handler, sp, E0583, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
@bors r- |
a9f22d7
to
88c81c5
Compare
@jseyfried: Outch, my string replacement failed badly... Updated. |
88c81c5
to
b6818be
Compare
Tests seem ok this time so let's r+ it. Thanks @jseyfried! @bors: r=jseyfried |
📌 Commit b6818be has been approved by |
⌛ Testing commit b6818be with merge ab89a78... |
💔 Test failed - status-appveyor |
@bors: retry
* network failure
…On Tue, Feb 21, 2017 at 2:53 PM, bors ***@***.***> wrote:
💔 Test failed - status-appveyor
<https://ci.appveyor.com/project/rust-lang/rust/build/1.0.2054>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#39765 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95OAISJpoL3yPH4ZYO08TutVSLEPlks5re06ugaJpZM4L-f60>
.
|
⌛ Testing commit b6818be with merge 0f34b53... |
…, r=jseyfried File not found for module error Fixes #39542. r? @jonathandturner Maybe you want to take a look @pnkfelix?
☀️ Test successful - status-appveyor, status-travis |
Fixes #39542.
r? @jonathandturner
Maybe you want to take a look @pnkfelix?