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

Cargo suggestion doesn't work with crates having a hyphen in the name #115841

Open
hrxi opened this issue Sep 14, 2023 · 7 comments
Open

Cargo suggestion doesn't work with crates having a hyphen in the name #115841

hrxi opened this issue Sep 14, 2023 · 7 comments
Labels
T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.

Comments

@hrxi
Copy link
Contributor

hrxi commented Sep 14, 2023

While hitting #84970 (comment), I got this from Cargo:

$ cargo check
[…]
error: internal compiler error: encountered incremental compilation error with mir_built(2b0ee002860f4e6d-86dbf79d6866cd33)
  |
  = help: This is a known issue with the compiler. Run `cargo clean -p nimiq_lib` or `cargo clean` to allow your project to compile
  = note: Please follow the instructions below to create a bug report with the provided information
  = note: See <https://github.com/rust-lang/rust/issues/84970> for more information
[…]

Running cargo clean -p nimiq_lib failed with the following error:

$ cargo clean -p nimiq_lib
error: package ID specification `nimiq_lib` did not match any packages

	Did you mean `nimiq-lib`?
$ cargo clean -p nimiq-lib
$

And indeed cargo clean -p nimiq-lib works.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 14, 2023
@apiraino
Copy link
Contributor

Not completely sure but rust-lang/cargo#9038 could be related. Probably this report can be moved to that repository.

@saethlin saethlin added T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 15, 2023
@weihanglo
Copy link
Member

The error message is from rustc diagnostics:

let run_cmd = if let Some(crate_name) = &tcx.sess().opts.crate_name {
format!("`cargo clean -p {crate_name}` or `cargo clean`")
} else {
"`cargo clean`".to_string()
};
let dep_node = tcx.dep_graph().data().unwrap().prev_node_of(prev_index);
tcx.sess().emit_err(crate::error::IncrementCompilation {
run_cmd,
dep_node: format!("{dep_node:?}"),
});

And --crate-name is provided with hyphen-to-underscore normalization to rustc by cargo.

I've got the impression that the Cargo team tries to reduce such kind of normalization in exchange for performance, at least for crates.io index query. Package ID flag -p/--package is also a thing that never got normalized. Thus, I lean toward not fixing this to avoid complexity.

Given the above points, and the helpful Did you mean …? message, I propose to close this as "wont fix" at this moment.

@hrxi
Copy link
Contributor Author

hrxi commented Sep 28, 2023

So the problem is that rustc tries to guess the correct cargo invocation based on incomplete (hyphen-to-underscore-normalized) information passed to it? Cargo doesn't want to do reverse-normalization on -p, so the only option would be to pass the non-normalized data to rustc, but that's considered too complex?

@weihanglo
Copy link
Member

so the only option would be to pass the non-normalized data to rustc, but that's considered too complex?

This won't be too complex I guess. It just seems too specialized to me. We need to add a new rustc option and make cargo pass it only for this incremental compilation error. It also kinda leaks the abstraction between Cargo and rustc. Not sure if that is a right approach for this.

@Enselic
Copy link
Member

Enselic commented Nov 2, 2024

I propose to close this as "wont fix" at this moment.

No objections were raised, so let's close.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2024
@hrxi
Copy link
Contributor Author

hrxi commented Nov 4, 2024

Is it not useful to keep it open as the problem itself still exists, even though we don't want to fix it right now?

@Enselic
Copy link
Member

Enselic commented Nov 4, 2024

If you disagree with closing I'm fine with reopening.

@Enselic Enselic reopened this Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants