Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b651646

Browse files
committed
Auto merge of rust-lang#13676 - fasterthanlime:subtree-fix, r=Veykril
Mega-sync from `rust-lang/rust` This essentially implements `@oli-obk's` suggestion here rust-lang/rust-analyzer#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 rust-lang#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 <[email protected]> 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 <[email protected]> Date: Fri Nov 25 13:28:02 2022 +0100 Merge branch 'master' into subtree-fix-merge-test commit 9ce6a734f37ef8e53689f1c6f427a9efafe846bd (final-sync) Author: Amos Wenger <[email protected]> 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 286ef1e..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 rust-lang/rust-analyzer#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.
2 parents e668eca + 38c98d1 commit b651646

File tree

11 files changed

+15
-68
lines changed

11 files changed

+15
-68
lines changed

bench_data/glorious_old_parser

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ impl<'a> Parser<'a> {
19881988
err.span_suggestion(
19891989
span,
19901990
"declare the type after the parameter binding",
1991-
String::from("<identifier>: <type>"),
1991+
"<identifier>: <type>",
19921992
Applicability::HasPlaceholders,
19931993
);
19941994
} else if require_name && is_trait_item {

crates/hir-def/src/builtin_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
379379
// ==========================================================================
380380

381381
rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
382-
rustc_attr!(rustc_allocator_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
382+
rustc_attr!(rustc_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
383383
gated!(
384384
alloc_error_handler, Normal, template!(Word), WarnFollowing,
385385
experimental!(alloc_error_handler)

crates/hir-def/src/nameres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ mod path_resolution;
5757
#[cfg(test)]
5858
mod tests;
5959

60-
use std::{ops::Deref, sync::Arc};
60+
use std::{cmp::Ord, ops::Deref, sync::Arc};
6161

6262
use base_db::{CrateId, Edition, FileId};
6363
use hir_expand::{name::Name, InFile, MacroCallId, MacroDefId};

crates/hir-ty/src/autoderef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! In certain situations, rust automatically inserts derefs as necessary: for
22
//! example, field accesses `foo.bar` still work when `foo` is actually a
33
//! reference to a type with the field `bar`. This is an approximation of the
4-
//! logic in rustc (which lives in librustc_typeck/check/autoderef.rs).
4+
//! logic in rustc (which lives in rustc_hir_analysis/check/autoderef.rs).
55
66
use std::sync::Arc;
77

crates/hir-ty/src/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! the type of each expression and pattern.
33
//!
44
//! For type inference, compare the implementations in rustc (the various
5-
//! check_* methods in librustc_typeck/check/mod.rs are a good entry point) and
5+
//! check_* methods in rustc_hir_analysis/check/mod.rs are a good entry point) and
66
//! IntelliJ-Rust (org.rust.lang.core.types.infer). Our entry point for
77
//! inference here is the `infer` function, which infers the types of all
88
//! expressions in a given function.

crates/hir-ty/src/infer/coerce.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! like going from `&Vec<T>` to `&[T]`.
44
//!
55
//! See <https://doc.rust-lang.org/nomicon/coercions.html> and
6-
//! `librustc_typeck/check/coercion.rs`.
6+
//! `rustc_hir_analysis/check/coercion.rs`.
77
88
use std::{iter, sync::Arc};
99

crates/hir-ty/src/method_resolution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This module is concerned with finding methods that a given type provides.
22
//! For details about how this works in rustc, see the method lookup page in the
33
//! [rustc guide](https://rust-lang.github.io/rustc-guide/method-lookup.html)
4-
//! and the corresponding code mostly in librustc_typeck/check/method/probe.rs.
4+
//! and the corresponding code mostly in rustc_hir_analysis/check/method/probe.rs.
55
use std::{iter, ops::ControlFlow, sync::Arc};
66

77
use arrayvec::ArrayVec;

crates/ide-db/src/imports/merge_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn path_cmp_short(a: &ast::Path, b: &ast::Path) -> Ordering {
225225
}
226226

227227
/// Compares two paths, if one ends earlier than the other the has_tl parameters decide which is
228-
/// greater as a a path that has a tree list should be greater, while one that just ends without
228+
/// greater as a path that has a tree list should be greater, while one that just ends without
229229
/// a tree list should be considered less.
230230
pub(super) fn use_tree_path_cmp(
231231
a: &ast::Path,

crates/proc-macro-srv/src/abis/abi_sysroot/ra_server.rs

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,6 @@ pub struct SourceFile {
3737
type Level = super::proc_macro::Level;
3838
type LineColumn = super::proc_macro::LineColumn;
3939

40-
/// A structure representing a diagnostic message and associated children
41-
/// messages.
42-
#[derive(Clone, Debug)]
43-
pub struct Diagnostic {
44-
level: Level,
45-
message: String,
46-
spans: Vec<Span>,
47-
children: Vec<Diagnostic>,
48-
}
49-
50-
impl Diagnostic {
51-
/// Creates a new diagnostic with the given `level` and `message`.
52-
pub fn new<T: Into<String>>(level: Level, message: T) -> Diagnostic {
53-
Diagnostic { level, message: message.into(), spans: vec![], children: vec![] }
54-
}
55-
}
56-
5740
pub struct FreeFunctions;
5841

5942
#[derive(Default)]
@@ -65,8 +48,6 @@ impl server::Types for RustAnalyzer {
6548
type FreeFunctions = FreeFunctions;
6649
type TokenStream = TokenStream;
6750
type SourceFile = SourceFile;
68-
type MultiSpan = Vec<Span>;
69-
type Diagnostic = Diagnostic;
7051
type Span = Span;
7152
type Symbol = Symbol;
7253
}
@@ -90,6 +71,10 @@ impl server::FreeFunctions for RustAnalyzer {
9071
span: tt::TokenId::unspecified(),
9172
})
9273
}
74+
75+
fn emit_diagnostic(&mut self, _: bridge::Diagnostic<Self::Span>) {
76+
// FIXME handle diagnostic
77+
}
9378
}
9479

9580
impl server::TokenStream for RustAnalyzer {
@@ -282,30 +267,6 @@ impl server::SourceFile for RustAnalyzer {
282267
}
283268
}
284269

285-
impl server::Diagnostic for RustAnalyzer {
286-
fn new(&mut self, level: Level, msg: &str, spans: Self::MultiSpan) -> Self::Diagnostic {
287-
let mut diag = Diagnostic::new(level, msg);
288-
diag.spans = spans;
289-
diag
290-
}
291-
292-
fn sub(
293-
&mut self,
294-
_diag: &mut Self::Diagnostic,
295-
_level: Level,
296-
_msg: &str,
297-
_spans: Self::MultiSpan,
298-
) {
299-
// FIXME handle diagnostic
300-
//
301-
}
302-
303-
fn emit(&mut self, _diag: Self::Diagnostic) {
304-
// FIXME handle diagnostic
305-
// diag.emit()
306-
}
307-
}
308-
309270
impl server::Span for RustAnalyzer {
310271
fn debug(&mut self, span: Self::Span) -> String {
311272
format!("{:?}", span.0)
@@ -372,18 +333,6 @@ impl server::Span for RustAnalyzer {
372333
}
373334
}
374335

375-
impl server::MultiSpan for RustAnalyzer {
376-
fn new(&mut self) -> Self::MultiSpan {
377-
// FIXME handle span
378-
vec![]
379-
}
380-
381-
fn push(&mut self, other: &mut Self::MultiSpan, span: Self::Span) {
382-
//TODP
383-
other.push(span)
384-
}
385-
}
386-
387336
impl server::Symbol for RustAnalyzer {
388337
fn normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
389338
// FIXME: nfc-normalize and validate idents

crates/rust-analyzer/src/bin/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ where
132132

133133
let ext = span.extensions();
134134

135-
// `FormattedFields` is a a formatted representation of the span's
135+
// `FormattedFields` is a formatted representation of the span's
136136
// fields, which is stored in its extensions by the `fmt` layer's
137137
// `new_span` method. The fields will have been formatted
138138
// by the same field formatter that's provided to the event

crates/syntax/src/validation.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
mod block;
66

77
use rowan::Direction;
8-
use rustc_lexer::unescape::{
9-
self, unescape_byte, unescape_byte_literal, unescape_char, unescape_literal, Mode,
10-
};
8+
use rustc_lexer::unescape::{self, unescape_byte, unescape_char, unescape_literal, Mode};
119

1210
use crate::{
1311
algo,
@@ -143,7 +141,7 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
143141
ast::LiteralKind::ByteString(s) => {
144142
if !s.is_raw() {
145143
if let Some(without_quotes) = unquote(text, 2, '"') {
146-
unescape_byte_literal(without_quotes, Mode::ByteStr, &mut |range, char| {
144+
unescape_literal(without_quotes, Mode::ByteStr, &mut |range, char| {
147145
if let Err(err) = char {
148146
push_err(2, (range.start, err));
149147
}

0 commit comments

Comments
 (0)