Skip to content

Commit fcb0371

Browse files
committed
update error messages & bless tests
1 parent 46859b0 commit fcb0371

23 files changed

+115
-102
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

+26-13
Original file line numberDiff line numberDiff line change
@@ -2722,7 +2722,8 @@ impl<'a> Parser<'a> {
27222722
}
27232723

27242724
pub fn recover_conflict_marker(&mut self) {
2725-
let Some(start) = self.conflict_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt) else {
2725+
let Some(start) = self.conflict_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt)
2726+
else {
27262727
return;
27272728
};
27282729
let mut spans = Vec::with_capacity(3);
@@ -2734,40 +2735,52 @@ impl<'a> Parser<'a> {
27342735
if self.token.kind == TokenKind::Eof {
27352736
break;
27362737
}
2737-
if let Some(span) = self.conflict_marker(&TokenKind::OrOr, &TokenKind::BinOp(token::Or)) {
2738+
if let Some(span) = self.conflict_marker(&TokenKind::OrOr, &TokenKind::BinOp(token::Or))
2739+
{
27382740
middlediff3 = Some(span);
27392741
}
27402742
if let Some(span) = self.conflict_marker(&TokenKind::EqEq, &TokenKind::Eq) {
27412743
middle = Some(span);
27422744
}
2743-
if let Some(span) = self.conflict_marker(&TokenKind::BinOp(token::Shr), &TokenKind::Gt) {
2745+
if let Some(span) = self.conflict_marker(&TokenKind::BinOp(token::Shr), &TokenKind::Gt)
2746+
{
27442747
spans.push(span);
27452748
end = Some(span);
27462749
break;
27472750
}
27482751
self.bump();
27492752
}
2750-
let mut err = self.struct_span_err(spans, "encountered diff marker");
2751-
err.span_label(start, "after this is the code before the merge");
2753+
let mut err = self.struct_span_err(spans, "encountered git conflict marker");
2754+
2755+
// with diff3
27522756
if let Some(middle) = middlediff3 {
2753-
err.span_label(middle, "");
2757+
err.span_label(
2758+
start,
2759+
"between this marker and `|||||||` is the code that we're merging into",
2760+
);
2761+
err.span_label(middle, "between this marker and `=======` is the base code (what the two refs diverged from)");
2762+
} else {
2763+
err.span_label(
2764+
start,
2765+
"between this marker and `=======` is the code that we're merging into",
2766+
);
27542767
}
2768+
27552769
if let Some(middle) = middle {
2756-
err.span_label(middle, "");
2770+
err.span_label(middle, "between this marker and `>>>>>>>` is the incoming code");
27572771
}
2772+
27582773
if let Some(end) = end {
2759-
err.span_label(end, "above this are the incoming code changes");
2774+
err.span_label(end, "");
27602775
}
27612776
err.help(
2762-
"if you're having merge conflicts after pulling new code, the top section is the code \
2763-
you already had and the bottom section is the remote code",
2777+
"conflict markers indicate that a merge was started but could not be completed due to merge conflicts",
27642778
);
27652779
err.help(
2766-
"if you're in the middle of a rebase, the top section is the code being rebased onto \
2767-
and the bottom section is the code coming from the current commit being rebased",
2780+
"to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers",
27682781
);
27692782
err.note(
2770-
"for an explanation on these markers from the `git` documentation, visit \
2783+
"for more information, visit the `git` documentation \
27712784
<https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
27722785
);
27732786
err.emit();

tests/ui/parser/diff-markers/enum-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
enum E {
22
Foo {
3-
<<<<<<< HEAD //~ ERROR encountered diff marker
3+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
44
x: u8,
55
|||||||
66
z: (),
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/enum-2.rs:3:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `|||||||` is the code that we're merging into
66
LL | x: u8,
77
LL | |||||||
8-
| -------
8+
| ------- between this marker and `=======` is the base code (what the two refs diverged from)
99
LL | z: (),
1010
LL | =======
11-
| -------
11+
| ------- between this marker and `>>>>>>>` is the incoming code
1212
LL | y: i8,
1313
LL | >>>>>>> branch
14-
| ^^^^^^^ above this are the incoming code changes
14+
| ^^^^^^^
1515
|
16-
= 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
17-
= 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
18-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
16+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
17+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
18+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1919

2020
error: aborting due to previous error
2121

tests/ui/parser/diff-markers/enum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
enum E {
2-
<<<<<<< HEAD //~ ERROR encountered diff marker
2+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
33
Foo(u8),
44
=======
55
Bar(i8),
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/enum.rs:2:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `=======` is the code that we're merging into
66
LL | Foo(u8),
77
LL | =======
8-
| -------
8+
| ------- between this marker and `>>>>>>>` is the incoming code
99
LL | Bar(i8),
1010
LL | >>>>>>> branch
11-
| ^^^^^^^ above this are the incoming code changes
11+
| ^^^^^^^
1212
|
13-
= 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
14-
= 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
15-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
13+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
14+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
15+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1616

1717
error: aborting due to previous error
1818

tests/ui/parser/diff-markers/fn-arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
trait T {
22
fn foo(
3-
<<<<<<< HEAD //~ ERROR encountered diff marker
3+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
44
x: u8,
55
=======
66
x: i8,
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/fn-arg.rs:3:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `=======` is the code that we're merging into
66
LL | x: u8,
77
LL | =======
8-
| -------
8+
| ------- between this marker and `>>>>>>>` is the incoming code
99
LL | x: i8,
1010
LL | >>>>>>> branch
11-
| ^^^^^^^ above this are the incoming code changes
11+
| ^^^^^^^
1212
|
13-
= 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
14-
= 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
15-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
13+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
14+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
15+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1616

1717
error: aborting due to previous error
1818

tests/ui/parser/diff-markers/item-with-attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[attribute]
2-
<<<<<<< HEAD //~ ERROR encountered diff marker
2+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
33
fn foo() {}
44
=======
55
fn bar() {}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/item-with-attr.rs:2:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `=======` is the code that we're merging into
66
LL | fn foo() {}
77
LL | =======
8-
| -------
8+
| ------- between this marker and `>>>>>>>` is the incoming code
99
LL | fn bar() {}
1010
LL | >>>>>>> branch
11-
| ^^^^^^^ above this are the incoming code changes
11+
| ^^^^^^^
1212
|
13-
= 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
14-
= 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
15-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
13+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
14+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
15+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1616

1717
error: aborting due to previous error
1818

tests/ui/parser/diff-markers/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<<<<<<< HEAD //~ ERROR encountered diff marker
1+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
22
fn foo() {}
33
=======
44
fn bar() {}
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/item.rs:1:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `=======` is the code that we're merging into
66
LL | fn foo() {}
77
LL | =======
8-
| -------
8+
| ------- between this marker and `>>>>>>>` is the incoming code
99
LL | fn bar() {}
1010
LL | >>>>>>> branch
11-
| ^^^^^^^ above this are the incoming code changes
11+
| ^^^^^^^
1212
|
13-
= 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
14-
= 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
15-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
13+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
14+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
15+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1616

1717
error: aborting due to previous error
1818

tests/ui/parser/diff-markers/statement.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct S;
77
impl T for S {}
88

99
fn main() {
10-
<<<<<<< HEAD //~ ERROR encountered diff marker
10+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
1111
S::foo();
1212
=======
1313
S::bar();
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/statement.rs:10:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `=======` is the code that we're merging into
66
LL | S::foo();
77
LL | =======
8-
| -------
8+
| ------- between this marker and `>>>>>>>` is the incoming code
99
LL | S::bar();
1010
LL | >>>>>>> branch
11-
| ^^^^^^^ above this are the incoming code changes
11+
| ^^^^^^^
1212
|
13-
= 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
14-
= 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
15-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
13+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
14+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
15+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1616

1717
error: aborting due to previous error
1818

tests/ui/parser/diff-markers/struct-expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ struct S {
33
}
44
fn main() {
55
let _ = S {
6-
<<<<<<< HEAD //~ ERROR encountered diff marker
6+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
77
x: 42,
88
=======
99
x: 0,
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/struct-expr.rs:6:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `=======` is the code that we're merging into
66
LL | x: 42,
77
LL | =======
8-
| -------
8+
| ------- between this marker and `>>>>>>>` is the incoming code
99
LL | x: 0,
1010
LL | >>>>>>> branch
11-
| ^^^^^^^ above this are the incoming code changes
11+
| ^^^^^^^
1212
|
13-
= 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
14-
= 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
15-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
13+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
14+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
15+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1616

1717
error: aborting due to previous error
1818

tests/ui/parser/diff-markers/struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
struct S {
2-
<<<<<<< HEAD //~ ERROR encountered diff marker
2+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
33
x: u8,
44
=======
55
x: i8,
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/struct.rs:2:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `=======` is the code that we're merging into
66
LL | x: u8,
77
LL | =======
8-
| -------
8+
| ------- between this marker and `>>>>>>>` is the incoming code
99
LL | x: i8,
1010
LL | >>>>>>> branch
11-
| ^^^^^^^ above this are the incoming code changes
11+
| ^^^^^^^
1212
|
13-
= 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
14-
= 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
15-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
13+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
14+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
15+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1616

1717
error: aborting due to previous error
1818

tests/ui/parser/diff-markers/trait-item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
trait T {
2-
<<<<<<< HEAD //~ ERROR encountered diff marker
2+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
33
fn foo() {}
44
=======
55
fn bar() {}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: encountered diff marker
1+
error: encountered git conflict marker
22
--> $DIR/trait-item.rs:2:1
33
|
44
LL | <<<<<<< HEAD
5-
| ^^^^^^^ after this is the code before the merge
5+
| ^^^^^^^ between this marker and `=======` is the code that we're merging into
66
LL | fn foo() {}
77
LL | =======
8-
| -------
8+
| ------- between this marker and `>>>>>>>` is the incoming code
99
LL | fn bar() {}
1010
LL | >>>>>>> branch
11-
| ^^^^^^^ above this are the incoming code changes
11+
| ^^^^^^^
1212
|
13-
= 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
14-
= 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
15-
= note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
13+
= help: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
14+
= help: to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
15+
= note: for more information, visit the `git` documentation <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>
1616

1717
error: aborting due to previous error
1818

tests/ui/parser/diff-markers/tuple-struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
struct S(
2-
<<<<<<< HEAD //~ ERROR encountered diff marker
2+
<<<<<<< HEAD //~ ERROR encountered git conflict marker
33
u8,
44
=======
55
i8,

0 commit comments

Comments
 (0)