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

Provide extra context on a query failure. #7934

Merged
merged 2 commits into from
Feb 27, 2020

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Feb 25, 2020

This adds error context when a query fails, primarily to tell you which parent package included the dependency that failed. For example, imagine deep within your dependency graph you have a git dependency, and it fails to download. The current error doesn't tell you where in the graph that git dependency was included.

I also slightly tweaked the failed to load source error message. I felt like the existing wording could be misinterpreted that it was an error loading the dependency for the given package. I felt like there were multiple ways to interpret it, so I tried to simplify it to avoid that possibility.

@rust-highfive
Copy link

r? @Eh2406

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 25, 2020
@ehuss
Copy link
Contributor Author

ehuss commented Feb 25, 2020

This is just an experiment, and I wanted to get feedback if anyone thinks it looks like a good idea. I'm also open to changing the wording.

@Eh2406
Copy link
Contributor

Eh2406 commented Feb 25, 2020

seems reasonable.

@alexcrichton
Copy link
Member

It sounds like the goal here is to sort of figure out why a package was included, right? If so I think 1 package as a parent helps a lot, but perhaps we could go all the way and do the path_to_root method which prints everything?

@ehuss
Copy link
Contributor Author

ehuss commented Feb 26, 2020

A full path might be nice, but I don't know how to do that at this location. I assume you're referring to path_to_bottom? It looks like that requires Context.parents? It looks like I could maybe pass something in, but I'm very unfamiliar with this, so I'm not clear on the relationship of the "candidate" and the parents.

@Eh2406
Copy link
Contributor

Eh2406 commented Feb 26, 2020

Yes, I think something like

describe_path(
                &cx.parents.path_to_bottom(&parent.package_id()),
            )

Will make a message that matches our other errors. Looks like we can pass cx from the activate.

Or perhaps that can be added as part of a chain_err on the result of build_deps in activate, I don't know the capabilities of anyhow.

cc #6199

@alexcrichton
Copy link
Member

I think that if the error context was shifted to around here it may be easier to call that describe_path method perhaps? (poking a bit in the dark myself here)

@ehuss
Copy link
Contributor Author

ehuss commented Feb 26, 2020

Hm, I pushed a change that moves the context up so that it can get the path. Unfortunately build_deps also handles feature validation, and the error messages in those cases were worse off (that's not necessarily an error loading a dependency). So I added a special variant to ActivateError to detect that case.

I'm not really sure it's worth it, it seems to complicate things a little. What do you think?

@Eh2406
Copy link
Contributor

Eh2406 commented Feb 26, 2020

Hmmm, I was more thinking of the smaller change like master...Eh2406:pull/7934#diff-995a0a0a73b467f7c6b0cb34d8fba39d (I did not fix the tests.)

@ehuss
Copy link
Contributor Author

ehuss commented Feb 26, 2020

I was more thinking of the smaller change like

That looks good. (The link is broken, but I think this link works: Eh2406@d3f712a) I'll try it out tomorrow.

@ehuss ehuss force-pushed the query-error-context branch from 4e8091e to 1eca786 Compare February 27, 2020 16:17
@ehuss
Copy link
Contributor Author

ehuss commented Feb 27, 2020

Thanks, updated with @Eh2406 suggestion, it looks much better.

@Eh2406
Copy link
Contributor

Eh2406 commented Feb 27, 2020

Looks great! Thanks for adding the new test!
@bors r+

@bors
Copy link
Contributor

bors commented Feb 27, 2020

📌 Commit 1eca786 has been approved by Eh2406

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 27, 2020
@bors
Copy link
Contributor

bors commented Feb 27, 2020

⌛ Testing commit 1eca786 with merge 7ba6e49...

@bors
Copy link
Contributor

bors commented Feb 27, 2020

☀️ Test successful - checks-azure
Approved by: Eh2406
Pushing 7ba6e49 to master...

@bors bors merged commit 7ba6e49 into rust-lang:master Feb 27, 2020
bors added a commit to rust-lang/rust that referenced this pull request Mar 2, 2020
Update cargo, clippy

Closes #69601

## cargo

16 commits in e57bd02999c9f40d52116e0beca7d1dccb0643de..bda50510d1daf6e9c53ad6ccf603da6e0fa8103f
2020-02-21 20:20:10 +0000 to 2020-03-02 18:05:34 +0000
- Fix rare failure in collision_export test. (rust-lang/cargo#7956)
- Ignore broken Cargo.toml in git sources (rust-lang/cargo#7947)
- Add more fingerprint mtime debug logging. (rust-lang/cargo#7952)
- Fix plugin tests for latest nightly. (rust-lang/cargo#7955)
- Simplified usage code of SipHasher (rust-lang/cargo#7945)
- Add a special case for git config discovery inside tests (rust-lang/cargo#7944)
- Fixes issue rust-lang/cargo#7543 (rust-lang/cargo#7946)
- Filter out cfgs which should not be used during build (rust-lang/cargo#7943)
- Provide extra context on a query failure. (rust-lang/cargo#7934)
- Try to clarify `cargo metadata`'s relationship with the workspace. (rust-lang/cargo#7927)
- Update libgit2 dependency (rust-lang/cargo#7939)
- Fix link in comment (rust-lang/cargo#7936)
- Enable `cargo doc --open` tests on macos. (rust-lang/cargo#7932)
- build-std: remove sysroot probe (rust-lang/cargo#7931)
- Try to clarify how feature flags work on the "current" package. (rust-lang/cargo#7928)
- Add extra details in the new feature resolver doc comment. (rust-lang/cargo#7918)

## clippy

6 commits in fc5d0cc..8b7f7e6
2020-02-24 05:58:17 +0000 to 2020-03-02 20:00:31 +0000
- Rustup to #69469 (rust-lang/rust-clippy#5254)
- Some rustups (rust-lang/rust-clippy#5247)
- Update git2 to 0.12 (rust-lang/rust-clippy#5232)
- Rustup to #61812 (rust-lang/rust-clippy#5231)
- Add lint to improve floating-point expressions (rust-lang/rust-clippy#4897)
- Do not run deploy action on other repos (rust-lang/rust-clippy#5222)
@ehuss ehuss added this to the 1.43.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants