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

Dependency info issue for modules loaded from files with mod modname; #43696

Closed
petrochenkov opened this issue Aug 6, 2017 · 2 comments
Closed
Labels
C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@petrochenkov
Copy link
Contributor

petrochenkov commented Aug 6, 2017

How to reproduce:

  • Create a Cargo project with source tree looking like this
.
├── lib.rs
└── modname.rs

and lib.rs looking like this

mod modname;
  • run cargo build
  • add a new directory and file so the source tree becomes
.
├── lib.d
├── lib.rs
├── modname
│   └── mod.rs
└── modname.rs
  • run cargo build again

In theory, the second cargo build should start running the build and report the error

error[E0584]: file for module `modname` found at both modname.rs and modname\mod.rs

but no build is started because Cargo thinks everything is up-to-date.

Cargo uses depinfo produced by rustc to check file freshness and for this example depinfo produced during the first build looks like this

lib.d: lib.rs modname.rs

lib.rs:
modname.rs:

, so Cargo checks lib.rs and modname.rs for freshness, but it doesn't know anything modname/mod.rs.


This can be fixed by issuing additional depinfo - modname/mod.rs for each modname.rs, and modname.rs for each modname/mod.rs.
The problem is that it will require build systems (including Cargo) spend roughly twice as much time on checking file freshness on rebuilds for all projects, even if none of them does the madness described in the reproduction paragraph.
So, it may be reasonable to close this as WONTFIX.


The issue itself may be esoteric, but I think it's interesting as a glimpse into the world of project structures inferred from filesystem, which is currently discussed in various module system reform proposals.

@petrochenkov
Copy link
Contributor Author

The "language lawyer" fix for the problem could look like

If modname.rs and modname\mod.rs both exist it's unspecified which one of them will be used, an error is reported on best effort basis.

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Aug 10, 2017
@Enselic
Copy link
Member

Enselic commented Sep 15, 2023

So, it may be reasonable to close this as WONTFIX.

Triage: No one argued against this for 6 years, so let's close as WONTFIX .

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants