Skip to content

rustc can't read files with more than one dot in filename #113981

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Jul 23, 2023 · 2 comments · Fixed by #114058
Closed

rustc can't read files with more than one dot in filename #113981

matthiaskrgr opened this issue Jul 23, 2023 · 2 comments · Fixed by #114058
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@matthiaskrgr
Copy link
Member

echo "pub fn main() {}" > a.b.rs
rustc a.b.rs
error: invalid character `'.'` in crate name: `a.b`

Why would rustc think this is related to crates when I just pass a simple path into it?

@matthiaskrgr matthiaskrgr added the C-bug Category: This is a bug. label Jul 23, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 23, 2023
@matthiaskrgr matthiaskrgr changed the title rustc can't read files with more than one dot in path rustc can't read files with more than one dot in filename Jul 23, 2023
@ehuss
Copy link
Contributor

ehuss commented Jul 23, 2023

Rustc has to infer the crate name when you don't specify it with --crate-name, or with #![crate_name="…"]. It is not as important for a binary compared to a library (since you can't directly import a binary), but it still appears in some circumstances like symbols, debuginfo, some diagnostics, and macros, and still needs to be well-formed.

@matthiaskrgr
Copy link
Member Author

Hmm, so it assumes {crate_name}.rs which would in this case be "a.b" which is not a valid crate name?
It would be nice to have some help message for the a.b.rs case which hints to usage of either --crate-name or #![crate_name="…"] 🙂

@chenyukang chenyukang self-assigned this Jul 24, 2023
@chenyukang chenyukang added A-diagnostics Area: Messages for errors, warnings, and lints and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 24, 2023
@bors bors closed this as completed in de5228e Jul 25, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants