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

Fix metabuild compile errors with --message-format=json. #6432

Merged
merged 3 commits into from
Dec 18, 2018

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Dec 13, 2018

If an error occurs while compiling a metabuild target with --message-format=json, it would panic because it was unable to serialize Target. This change makes it so that it places a fake "metabuild.rs" string in the src_path in this situation.

I'm very unhappy with this solution, but I'm unable to think of something better. Changing src_path to an Option (or something) would break existing tools (this might break, but maybe not catastrophically?). I tried implementing something that resets the src_path to the correct path in the target dir after the workspace is configured, but it felt very brittle – you have to fix up after all dependencies are downloaded, and there's not a good place to ensure that happens correctly. Any alternate ideas?

This adds a with_json_contains_unordered to help with tests.

@rust-highfive
Copy link

r? @alexcrichton

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

@ehuss ehuss force-pushed the fix-metabuild-json branch from 95a9963 to 2087c47 Compare December 13, 2018 21:58
@dwijnand
Copy link
Member

This adds a with_json_contains_unordered to help with tests.

👍

Changing src_path to an Option (or something) would break existing tools (this might break, but maybe not catastrophically?)

Do we have commitments to other tools on our serialised data formats?

Any alternate ideas?

The wonderful (terrible) thing about string-based data is you don't need no Option: it already comes with its own action-ready null object value: ""!

@ehuss
Copy link
Contributor Author

ehuss commented Dec 14, 2018

Do we have commitments to other tools on our serialised data formats?

I don't know if Cargo has any hard rules for stability. Maybe we should clarify that? The tough part about the artifact messages is that there is no way to version them (unlike cargo metadata which has a version flag).

The wonderful (terrible) thing about string-based data is you don't need no Option: it already comes with its own action-ready null object value: ""!

Yea, I considered that, too. The issue is if a tool wants to actually read the file, it will fail (either with "" or the fake path I used). I figured the fake path would at least be a little more visible if there is an error.

@alexcrichton
Copy link
Member

Without having tons of context I'd actually naively expect that we could use an Option here to faithfully represent the lack of a source file because all existing tools would continue to work (as metabuild isn't stable) and they'd just need an update to work with metabuild. That to me seems like a naively ok tradeoff at least.

If this only happens during actual compilation though, we should have a path to the actual file as well though, right?

If an error occurs while compiling a metabuild target with
`--message-format=json`, it would panic because it was unable to serialize
`Target`. This change makes it so that it places a fake "metabuild.rs" string in
the `src_path` in this situation.

I'm very unhappy with this solution, but I'm unable to think of something
better. Changing `src_path` to an `Option` (or something) would break existing
tools. I tried implementing something that resets the `src_path` to the correct
path in the target dir after the workspace is configured, but it felt very
brittle – you have to fix up after all dependencies are downloaded, and there's
not a good way to ensure that happens correctly.

This adds a `with_json_contains_unordered` to help with tests.
@ehuss ehuss force-pushed the fix-metabuild-json branch from 2087c47 to 48d56a4 Compare December 18, 2018 03:58
@ehuss
Copy link
Contributor Author

ehuss commented Dec 18, 2018

OK, I decided to go ahead and just use None for SerializedTarget::src_path. I hate breaking things, but hopefully the fallout will be small. If it is much of a problem, we can always revisit this later.

If this only happens during actual compilation though, we should have a path to the actual file as well though, right?

The problem is:

  • The serialization code does not have access to target_dir to compute the correct path.
  • The Targets can be mutated to "fix" the path after they are created (target_dir isn't known when manifests are parsed). However, this is a game of whack-a-mole trying to find every place a manifest is created (at a minimum, it would be after creating a workspace, and in several places in the guts of Downloads). Alternatively it can "fix" the paths during compilation (like it does here), but that will also be very difficult to ensure every location is covered.

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new unwraps are unfortunate, but nothing seems to fall over in CI, LGTM

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Dec 18, 2018

📌 Commit 48d56a4 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Dec 18, 2018

⌛ Testing commit 48d56a4 with merge 8ffc960...

bors added a commit that referenced this pull request Dec 18, 2018
Fix metabuild compile errors with --message-format=json.

If an error occurs while compiling a metabuild target with `--message-format=json`, it would panic because it was unable to serialize `Target`. This change makes it so that it places a fake "metabuild.rs" string in the `src_path` in this situation.

I'm very unhappy with this solution, but I'm unable to think of something better. Changing `src_path` to an `Option` (or something) would break existing tools (this might break, but maybe not catastrophically?). I tried implementing something that resets the `src_path` to the correct path in the target dir after the workspace is configured, but it felt very brittle – you have to fix up after all dependencies are downloaded, and there's not a good place to ensure that happens correctly. Any alternate ideas?

This adds a `with_json_contains_unordered` to help with tests.
@bors
Copy link
Contributor

bors commented Dec 18, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 8ffc960 to master...

@bors bors merged commit 48d56a4 into rust-lang:master Dec 18, 2018
bors added a commit to rust-lang/rust that referenced this pull request Dec 29, 2018
Update cargo, rls, miri

Update cargo, rls, miri

Added `rustc-workspace-hack` to miri so that it shares the same features for serde as other tools.

cc @alexcrichton

## cargo

25 commits in 2cf1f5dda2f7ed84e94c4d32f643e0f1f15352f0..0d1f1bbeabd5b43a7f3ecfa16540af8e76d5efb4
2018-12-11 03:44:04 +0000 to 2018-12-19 14:45:14 +0000
- Remove Stale bot's configuration (rust-lang/cargo#6463)
- Add labels to issue templates (rust-lang/cargo#6464)
- Fix new man page links. (rust-lang/cargo#6459)
- Fix metabuild compile errors with --message-format=json. (rust-lang/cargo#6432)
- Support alt-registry names in [patch] table. (rust-lang/cargo#6456)
- Update the rustup URL (rust-lang/cargo#6455)
- New man pages. (rust-lang/cargo#6405)
- Reify the DepFingerprint type (rust-lang/cargo#6451)
- Extract Fingerprint::new (rust-lang/cargo#6449)
- Upgrade the metabuild to Rust 2018 (rust-lang/cargo#6448)
- Make edition comparing code consistent (rust-lang/cargo#6450)
- Document `name` and `authors` in [package] (rust-lang/cargo#6447)
- Travis: only use mdbook 0.1.7. (rust-lang/cargo#6443)
- Update git2-curl requirement from 0.8.1 to 0.9.0 (rust-lang/cargo#6439)
- Update git2 requirement from 0.7.5 to 0.8.0 (rust-lang/cargo#6438)
- Display errors when `cargo fix` fails. (rust-lang/cargo#6419)
- cargo fix: fix targets with shared sources. (rust-lang/cargo#6434)
- Fix panic-in-panic in tests. (rust-lang/cargo#6431)
- More Rust 2018 edition cleanups (rust-lang/cargo#6422)
- Cleanup some trait impls for SourceId (rust-lang/cargo#6429)
- Remove a nightly check from doc tests (rust-lang/cargo#6427)
- Replace CargoError with failure::Error (rust-lang/cargo#6425)
- Allow testsuite warnings in dev (rust-lang/cargo#6426)
- add `--dry-run` option to cargo update (rust-lang/cargo#6371)
- Migrate to some Rust 2018 idioms (rust-lang/cargo#6416)

## rls

16 commits in bd5b899afb05e14d33e210ede3da241ca1ca088f..6f5e4bba7b1586fca6e0ea7724cadb5683b2f308
2018-12-10 08:53:00 +0100 to 2018-12-21 17:11:08 +0100
- Update jsonrpc-core (rust-lang/rls#1206)
- Use `home_dir` from `home` crate (rust-lang/rls#1207)
- Update cargo. (rust-lang/rls#1204)
- Fix deprecated `trim_{left,right}` warnings (rust-lang/rls#1203)
- Respect ${CARGO,RUSTUP}_HOME for tooltip relative dirs (rust-lang/rls#1201)
- Separate tooltip tests that require Racer fallback (rust-lang/rls#1200)
- tests: Don't generate tooltip results in tests/fixtures (rust-lang/rls#1199)
- Overhaul fixture handling in tests (rust-lang/rls#1190)
- Don't return symbols with empty names (rust-lang/rls#1193)
- Don't check AppVeyor CI status for bors
- Properly infer full_docs (rust-lang/rls#1192)
- Update cargo (rust-lang/rls#1191)
- Improve hover test_tooltip tests (rust-lang/rls#1175)
- Fix unused warnings (rust-lang/rls#1185)
- Workaround rust-lang/rls#703 to prevent obscure failures due to sccache. (rust-lang/rls#1177)
- Disable travis cache (rust-lang/rls#1182)

## miri

14 commits in bccadeb..6c2fc6d
2018-12-08 11:07:22 +0100 to 2018-12-26 14:28:25 +0100
- use memory::check_bounds_ptr for offset check (rust-lang/miri#589)
- Fix comparing function pointers (rust-lang/miri#587)
- fix for infallible allocation (rust-lang/miri#586)
- fix test for latest nightly (rust-lang/miri#585)
- Treat ref-to-raw cast like a reborrow: do a special kind of retag (rust-lang/miri#572)
- Test cargo-miri on Windows (rust-lang/miri#578)
- Cargo miri tweaks and test that we can exclude tests (rust-lang/miri#580)
- Fix cargo miri test (rust-lang/miri#550)
- fix for latest nightly (rust-lang/miri#574)
- Add rustc-workspace-hack. (rust-lang/miri#575)
- use RUSTC_WRAPPER for the cargo hook (rust-lang/miri#573)
- do not auto-detect the targets in the sysroot, instead specify target manually through env var (rust-lang/miri#570)
- Cleanup: Avoid repeating signatures, get rid of to_bytes hack (rust-lang/miri#568)
- Support building and running with full MIR on foreign architectures, drop support for missing MIR (rust-lang/miri#566)
@ehuss ehuss added this to the 1.33.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants