From 698ebe357f3323a953d0751d5764966b3ffb3cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 28 Dec 2022 18:46:20 -0800 Subject: [PATCH] Tweak wording --- .../rustc_parse/src/parser/diagnostics.rs | 19 +++++++++++++++---- compiler/rustc_parse/src/parser/item.rs | 2 +- compiler/rustc_parse/src/parser/stmt.rs | 2 +- src/test/ui/parser/diff-markers/enum-2.stderr | 10 +++++++--- src/test/ui/parser/diff-markers/enum.stderr | 10 +++++++--- src/test/ui/parser/diff-markers/fn-arg.stderr | 10 +++++++--- .../parser/diff-markers/item-with-attr.stderr | 10 +++++++--- src/test/ui/parser/diff-markers/item.stderr | 10 +++++++--- .../ui/parser/diff-markers/statement.stderr | 10 +++++++--- .../ui/parser/diff-markers/struct-expr.stderr | 10 +++++++--- src/test/ui/parser/diff-markers/struct.stderr | 10 +++++++--- .../ui/parser/diff-markers/trait-item.stderr | 10 +++++++--- .../parser/diff-markers/tuple-struct.stderr | 10 +++++++--- .../parser/diff-markers/use-statement.stderr | 10 +++++++--- 14 files changed, 94 insertions(+), 39 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index ffadb77320a..dd7341af4d5 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -2586,7 +2586,6 @@ impl<'a> Parser<'a> { break; } if let Some(span) = self.diff_marker(&TokenKind::EqEq, &TokenKind::Eq) { - spans.push(span); middle = Some(span); } if let Some(span) = self.diff_marker(&TokenKind::BinOp(token::Shr), &TokenKind::Gt) { @@ -2597,13 +2596,25 @@ impl<'a> Parser<'a> { self.bump(); } let mut err = self.struct_span_err(spans, "encountered diff marker"); - err.span_label(start, "start"); + err.span_label(start, "after this is the code before the merge"); if let Some(middle) = middle { - err.span_label(middle, "middle"); + err.span_label(middle, ""); } if let Some(end) = end { - err.span_label(end, "end"); + err.span_label(end, "above this are the incoming code changes"); } + err.help( + "if you're having merge conflicts after pulling new code, the top section is the code \ + you already had and the bottom section is the remote code", + ); + err.help( + "if you're in the middle of a rebase, the top section is the code being rebased onto \ + and the bottom section is the code coming from the current commit being rebased", + ); + err.note( + "for an explanation on these markers from the `git` documentation, visit \ + ", + ); err.emit(); FatalError.raise() } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index b996ce0a155..c6b6c04de85 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1583,7 +1583,7 @@ impl<'a> Parser<'a> { p.collect_tokens_trailing_token(attrs, ForceCollect::No, |p, attrs| { let mut snapshot = None; if p.is_diff_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt) { - // Account for `<<<<<<<` diff markers. We can't proactivelly error here because + // Account for `<<<<<<<` diff markers. We can't proactively error here because // that can be a valid type start, so we snapshot and reparse only we've // encountered another parse error. snapshot = Some(p.create_snapshot_for_diagnostic()); diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 4cbf89169b6..0daae457d30 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -537,7 +537,7 @@ impl<'a> Parser<'a> { break; } if self.is_diff_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt) { - // Account for `<<<<<<<` diff markers. We can't proactivelly error here because + // Account for `<<<<<<<` diff markers. We can't proactively error here because // that can be a valid path start, so we snapshot and reparse only we've // encountered another parse error. snapshot = Some(self.create_snapshot_for_diagnostic()); diff --git a/src/test/ui/parser/diff-markers/enum-2.stderr b/src/test/ui/parser/diff-markers/enum-2.stderr index 5264a596488..4e612a5427a 100644 --- a/src/test/ui/parser/diff-markers/enum-2.stderr +++ b/src/test/ui/parser/diff-markers/enum-2.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/enum-2.rs:3:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | x: u8, LL | ======= - | ^^^^^^^ middle + | ------- LL | x: i8, LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/enum.stderr b/src/test/ui/parser/diff-markers/enum.stderr index 6bdc20d3cd3..abbf3fb41e7 100644 --- a/src/test/ui/parser/diff-markers/enum.stderr +++ b/src/test/ui/parser/diff-markers/enum.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/enum.rs:2:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | Foo(u8), LL | ======= - | ^^^^^^^ middle + | ------- LL | Bar(i8), LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/fn-arg.stderr b/src/test/ui/parser/diff-markers/fn-arg.stderr index 4a816ff75bc..933a206410e 100644 --- a/src/test/ui/parser/diff-markers/fn-arg.stderr +++ b/src/test/ui/parser/diff-markers/fn-arg.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/fn-arg.rs:3:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | x: u8, LL | ======= - | ^^^^^^^ middle + | ------- LL | x: i8, LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/item-with-attr.stderr b/src/test/ui/parser/diff-markers/item-with-attr.stderr index 4fcb782846e..850e2368e55 100644 --- a/src/test/ui/parser/diff-markers/item-with-attr.stderr +++ b/src/test/ui/parser/diff-markers/item-with-attr.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/item-with-attr.rs:2:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | fn foo() {} LL | ======= - | ^^^^^^^ middle + | ------- LL | fn bar() {} LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/item.stderr b/src/test/ui/parser/diff-markers/item.stderr index 7c81f0fafa6..9ab3631a60e 100644 --- a/src/test/ui/parser/diff-markers/item.stderr +++ b/src/test/ui/parser/diff-markers/item.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/item.rs:1:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | fn foo() {} LL | ======= - | ^^^^^^^ middle + | ------- LL | fn bar() {} LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/statement.stderr b/src/test/ui/parser/diff-markers/statement.stderr index 4c821c02f0d..7ca2495b829 100644 --- a/src/test/ui/parser/diff-markers/statement.stderr +++ b/src/test/ui/parser/diff-markers/statement.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/statement.rs:10:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | S::foo(); LL | ======= - | ^^^^^^^ middle + | ------- LL | S::bar(); LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/struct-expr.stderr b/src/test/ui/parser/diff-markers/struct-expr.stderr index 0ddb1a301e3..d70476a9833 100644 --- a/src/test/ui/parser/diff-markers/struct-expr.stderr +++ b/src/test/ui/parser/diff-markers/struct-expr.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/struct-expr.rs:6:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | x: 42, LL | ======= - | ^^^^^^^ middle + | ------- LL | x: 0, LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/struct.stderr b/src/test/ui/parser/diff-markers/struct.stderr index e47bcfdaedc..cc0b3da664e 100644 --- a/src/test/ui/parser/diff-markers/struct.stderr +++ b/src/test/ui/parser/diff-markers/struct.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/struct.rs:2:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | x: u8, LL | ======= - | ^^^^^^^ middle + | ------- LL | x: i8, LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/trait-item.stderr b/src/test/ui/parser/diff-markers/trait-item.stderr index 8e18d5db7c7..cdc19f8e076 100644 --- a/src/test/ui/parser/diff-markers/trait-item.stderr +++ b/src/test/ui/parser/diff-markers/trait-item.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/trait-item.rs:2:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | fn foo() {} LL | ======= - | ^^^^^^^ middle + | ------- LL | fn bar() {} LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/tuple-struct.stderr b/src/test/ui/parser/diff-markers/tuple-struct.stderr index 7f30cbcc1f7..d673db89837 100644 --- a/src/test/ui/parser/diff-markers/tuple-struct.stderr +++ b/src/test/ui/parser/diff-markers/tuple-struct.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/tuple-struct.rs:2:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | u8, LL | ======= - | ^^^^^^^ middle + | ------- LL | i8, LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error diff --git a/src/test/ui/parser/diff-markers/use-statement.stderr b/src/test/ui/parser/diff-markers/use-statement.stderr index 818c90aa59b..12e6f57dd50 100644 --- a/src/test/ui/parser/diff-markers/use-statement.stderr +++ b/src/test/ui/parser/diff-markers/use-statement.stderr @@ -2,13 +2,17 @@ error: encountered diff marker --> $DIR/use-statement.rs:2:1 | LL | <<<<<<< HEAD - | ^^^^^^^ start + | ^^^^^^^ after this is the code before the merge LL | bar, LL | ======= - | ^^^^^^^ middle + | ------- LL | baz, LL | >>>>>>> branch - | ^^^^^^^ end + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit error: aborting due to previous error