-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cherry-pick some downstream commits #13459
Conversation
proc_macro/bridge: send diagnostics over the bridge as a struct This removes some RPC when creating and emitting diagnostics, and simplifies the bridge slightly. After this change, there are no remaining methods which take advantage of the support for `&mut` references to objects in the store as arguments, meaning that support for them could technically be removed if we wanted. The only remaining uses of immutable references into the store are `TokenStream` and `SourceFile`. r? `@eddyb`
This fixes a typo first appearing in #94624 in which test-macro diagnostic uses "a" article twice. Since I searched sources for " a a " sequences, I also fixed the same issue in a few source files where I found it. Signed-off-by: Petr Portnov <gh@progrm-jarvis.ru>
I don't know subtrees too well but could this cause problems with syncs? (I have no idea how subtree syncs were tbh, is it just a merge commit?) |
For rust-analyzer -> rust it is a merge commit created using the subtree merge strategy. For rust -> rust-analyzer it synthesizes new commits. Not sure if the commits in this PR will conflict. |
Yeah, I think the sync back looks like this:
|
r? @fasterthanlime, maybe? |
Just discovering this PR now — does the original PR description mean that following this guide didn't work? (I'm not sure what "merge" means in that context) https://doc.rust-lang.org/clippy/development/infrastructure/sync.html#performing-the-sync-from-rust-langrust-to-clippy Cherry-picking seems like a bad idea and I'd rather ping some folks working on clippy/other subtrees before merging this. |
I cherry picked some commits from the branch created by git subtree. But I can't merge the master branch into that one. |
can't those merge conflicts be fixed? I feel like I should try to do the sync myself to see exactly what's going on. |
I tried, but there were too many. It seemed to me that some of them were in files not touched by the downstream commits. |
Whenever syncing from rust-analyzer -> rust you have to immediately sync the merge commit from rust -> rust-analyzer to prevent merge conflicts in the future. |
I unfortunately won't have time to look more into this until next week, sorry - pinging @oli-obk for additional git-subtree expertise. |
yea I think you need to either redo a rustc->here sync right after the last here->rustc sync or move to using https://github.com/josh-project/josh like miri did: https://github.com/rust-lang/miri/blob/master/CONTRIBUTING.md#advanced-topic-syncing-with-the-rustc-repo |
Is there any way to fix this now that I've missed some syncs? I think I tried it right after a filing a sync PR, but before it being merged. Cherry-picking the commits doesn't sound too bad to me in the meanwhile. On the other hand, we should probably give |
hmm... I'm not sure. You could try to do a sync in the other direction at each of the past syncs and basically rebuild what was "lost". But that could be a lot of work |
I'm still inclined to merge this. If we ever make it work in the future, they should "go away" and if not, the rust-lang/rust side isn't that hard to handle in the same way (with cherry-picks). |
Now that I'm full-time on open-source stuff (among other things), I actually do have time to work on this — do we have time for me to take a closer look, or should I do so after this is merged? josh looks interesting, if it fixes most of our subtree woes, I would definitely invest effort into that. |
No hurry there. The commits here are pretty old and I don't think we've missed them. There's at least one more I didn't pick because it was a mass replace in a test fixture. |
So I gave josh a quick try (using RalfJung's fork), with:
(Where https://github.com/rust-lang/rust/commits/a63222cd240d9b5405826783603f3b391c90885d is the first commit in Passing https://gist.github.com/fasterthanlime/bb66f688764de5b4223b715e1704dbad I think I could go through all these merge conflicts if we were convinced that was the way forward? Here's a sample one: I think like often the "Current change" is the one we want to keep: ...there might even be a git option to do just that... |
Just checking in - do we think the way forward is switching to josh + resolving merge conflicts once? I have time to resolve the merge conflicts, it's time-consuming and annoying but if we do it once and "do it right" moving forward, it might be worth it, I just want to confirm that it's what we think is the right thing to do. |
Some quick (but still late) thoughts:
So |
That's actually my question: if we resolve the conflicts now and "do it right" moving forward, will it be the last time we have to deal with merge conflicts? (Unless there were actual conflicting changes, which I don't think is what happened there). And also: if we do cherry pick those commits, will the next time we run a git-subtree or josh sync be conflict-free? Could we make sure that after cherry-picking, the file trees under Maybe @RalfJung knows more? (since their fork of josh includes additional functionality) |
Josh needs to be used with care. :) And you cannot mix josh with other sync strategies, it's use only-josh or no-josh. Using josh here means you should stop using The key thing to ensure with josh is that extracting the history from rustc must exactly produce the history in this repo. When was the last time RA got pushed to rustc, and which RA commit was the one that got pushed? The first order of business is to ensure that extracting RA from rustc with josh yields a history that contains that commit. Since you used In Miri we use the filter
where 75dd959a3a40eb5b4574f8d2e23aa6efbeb33573 is the last (most recent) Miri commit in rustc that was created by Once you have that first josh fetch figured out, you should produce a merge of that with RA master, resolving any conflicts that have occurred. Those should be real conflicts, if there are nonsense conflicts here then likely something went wrong. Prepare that commit but do not merge this in RA yet, you want to be sure this all went well before permanently merging something into RA! Merging the wrong thing can make it permanently impossible to use josh properly, fixable only with a force-push. Still it's a good idea to make a GitHub PR at this point, as that will show very nicely which new commits are being added, so it's a good sanity-check to look at the new commits and the diff. To make sure it all went well, you want to test that pushing this new version of RA to rustc via josh (a) works, and (b) round-trips, i.e. fetching that indeed yields the new RA master you constructed. It's also worth opening a rustc PR for the push, again just to sanity-check things by looking at the new commits and the diff. If anything seems odd, stop and investigate. The josh parts of the Also I think it is a bad idea to have pull and push syncs that race: at any point in time, there should either be an open PR in the RA repo, waiting to merge the latest rustc-pull, or an open PR in the rustc repo, waiting to merge the latest rustc-push. I have not tried what happens when these happen in parallel, but it seems like trouble worth avoiding. ;) In fact what I usually do is that I do a pull immediately before each push. IOW, when I push, the commit I am pushing is a just-merged rustc-pull. pushing is the much harder less well-defined task for josh, so this ensures that that has the highest chance of succeeding. I do not know if it is strictly required to be so careful, but it seems to help avoid josh-project/josh#998 and also we had 2 force-pushes in Miri recently and I'd rather avoid having more. ;) (So this is basically the opposite of what @bjorn3 said about
Nope it's wrong, you want the last (most recent) subtree commit.
If you needed that flag it means the roundtrip failed, so something went wrong. (Not surprising given the wrong filter.) |
Oh I should also say that I consider josh to still be on probation in Miri. We had some annoying trouble last week, after which we updated our scripts and a josh bug got fixed and hopefully that is dealt with now. But if this happens again we'll probably give up on trying to sync history, and do something home-brew that just tries to get the file contents back and forth. If you wait a month I can tell you more, but at this point I cannot yet wholeheartedly recommend switching to josh. Once you merge any of the josh-produced history, I am not sure if switching back to So it depends on how fed up you are with |
@RalfJung thanks for the thoughtful response: what I'm getting from this is "don't switch to josh yet because it can lock us out of git-subtree". My only remaining question is: if we do these cherry-picks, can we still use git-subtree later or are we forever locked into doing these manual cherry-picks (unless we're willing to force-push If not, then apologies for wasting everyone's time and let's move forward with the cherry-picking. |
I know nothing about If this was josh, then I think cherry-picks would lead to annoying conflicts on the next rustc-push and to these commits being duplicated, but the situation should stabilize afterwards. |
Update: I'm trying something locally with some external help. Please don't merge this today (but if I don't report back before monday, feel free). Edit: I'm cautiously optimistic, will open PR when done. Edit 2: whoomp there it is: #13676 |
Closing in favor of #13676 |
Mega-sync from `rust-lang/rust` This essentially implements `@oli-obk's` suggestion here #13459 (comment), with `@eddyb's` help. This PR is equivalent to 14 syncs (back and forth) between `rust-lang/rust` and `rust-lang/rust-analyzer`. Working from this list (from bottom to top): ``` (x) a2a1d99 ⬆️ rust-analyzer (x) 79923c3 ⬆️ rust-analyzer (x) c60b1f6 ⬆️ rust-analyzer (x) 8807fc4 ⬆️ rust-analyzer (x) a99a48e ⬆️ rust-analyzer (x) 4f55ebb ⬆️ rust-analyzer (x) f5fde4d ⬆️ rust-analyzer (x) 459bbb4 ⬆️ rust-analyzer (x) 65e1dc4 ⬆️ rust-analyzer (x) 3e358a6 ⬆️ rust-analyzer (x) 31519bb ⬆️ rust-analyzer (x) 8231fee ⬆️ rust-analyzer (x) 22c8c9c ⬆️ rust-analyzer (x) 9d2cb42 ⬆️ rust-analyzer ``` (This listed was assembled by doing a `git subtree push`, which made a branch, and looking at the new commits in that branch, picking only those that were `⬆️ rust-analyzer` commits) We used the following commands to simulate merges in both directions: ```shell TO_MERGE=22c8c9c40 # taken from the list above, bottom to top git merge --no-edit --no-ff $TO_MERGE git merge --no-edit --no-ff $(git -C ../rust log --pretty=format:'%cN | %s | %ad => %P' | rg -m1 -F "$(git show --no-patch --pretty=format:%ad $TO_MERGE)" | tee /dev/stderr | rg '.* => \S+ (\S+)$' --replace '$1') ``` We encountered no merge conflicts that Git wasn't able to solve by doing it this way. Here's what the commit graph looks like (as shown in the Git Lens VSCode extension): <img width="1345" alt="image" src="https://user-images.githubusercontent.com/7998310/203984523-7c1a690a-8224-416c-8015-ed6e49667066.png"> This PR closes #13459 ## Does this unbreak `rust->ra` syncs? Yes, here's how we tried: In `rust-analyzer`: * check out `subtree-fix` (this PR's branch) * make a new branch off of it: `git checkout -b subtree-fix-merge-test` * simulate this PR getting merged with `git merge master` In `rust`: * pull latest master * make a new branch: `git checkout -b test-change` * mess with rust-analyzer (I added a comment to `src/tools/rust-analyzer/Cargo.toml`) * commit * run `git subtree push -P src/tools/rust-analyzer ra-local final-sync` (this follows the [Clippy sync guide](https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html)) This created a `final-sync` branch in `rust-analyzer`. In `rust-analyzer`: * `git merge --no-ff final-sync` (this follows the [Clippy sync guide](https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html)) Now `git log` in `rust-analyzer` shows this: ``` commit 460128387e46ddfc2b95921b2d7f6e913a3d2b9f (HEAD -> subtree-fix-merge-test) Merge: 0513fc02a 9ce6a734f Author: Amos Wenger <amoswenger@gmail.com> Date: Fri Nov 25 13:28:24 2022 +0100 Merge branch 'final-sync' into subtree-fix-merge-test commit 0513fc02a08ea9de952983624bd0a00e98044b36 Merge: 38c98d1 6918009 Author: Amos Wenger <amoswenger@gmail.com> Date: Fri Nov 25 13:28:02 2022 +0100 Merge branch 'master' into subtree-fix-merge-test commit 9ce6a734f37ef8e53689f1c6f427a9efafe846bd (final-sync) Author: Amos Wenger <amoswenger@gmail.com> Date: Fri Nov 25 13:26:26 2022 +0100 Mess with rust-analyzer just for fun ``` And `git diff 0513fc02a08ea9de952983624bd0a00e98044b36` shows this: ```patch diff --git a/Cargo.toml b/Cargo.toml index 286ef1e7d..c9e24cd19 100644 --- a/Cargo.toml +++ b/Cargo.toml `@@` -32,3 +32,5 `@@` debug = 0 # ungrammar = { path = "../ungrammar" } # salsa = { path = "../salsa" } + +# lol, hi ``` ## Does this unbreak `ra->rust` syncs? Yes, here's how we tried. From `rust`: * `git checkout -b sync-from-ra` * `git subtree pull -P src/tools/rust-analyzer ra-local subtree-fix-merge-test` (this is adapted from the [Clippy sync guide](https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html#performing-the-sync-from-clippy-to-rust-langrust), you would normally use `ra-upstream master` but we're simulating things here) A commit editor pops up, there was no merge conflicts. ## How do we prevent this from happening again? Like `@bjorn3` said in #13459 (comment) > Whenever syncing from rust-analyzer -> rust you have to immediately sync the merge commit from rust -> rust-analyzer to prevent merge conflicts in the future. But if we get it wrong again, at least now we have a not-so-painful way to fix it.
I couldn't use
git merge
for this, it seemed to give conflicts on files only modified on our side, likecrates/project-model/Cargo.toml
, so I cherry-picked a couple of commits from there.