@@ -2965,9 +2965,10 @@ impl<'a> Parser<'a> {
2965
2965
2966
2966
/// This checks if this is a conflict marker, depending of the parameter passed.
2967
2967
///
2968
- /// * `>>>>>`
2969
- /// * `=====`
2970
- /// * `<<<<<`
2968
+ /// * `<<<<<<<`
2969
+ /// * `|||||||`
2970
+ /// * `=======`
2971
+ /// * `>>>>>>>`
2971
2972
///
2972
2973
pub ( super ) fn is_vcs_conflict_marker (
2973
2974
& mut self ,
@@ -2997,14 +2998,18 @@ impl<'a> Parser<'a> {
2997
2998
}
2998
2999
2999
3000
pub ( crate ) fn err_vcs_conflict_marker ( & mut self ) -> PResult < ' a , ( ) > {
3001
+ // <<<<<<<
3000
3002
let Some ( start) = self . conflict_marker ( & TokenKind :: BinOp ( token:: Shl ) , & TokenKind :: Lt )
3001
3003
else {
3002
3004
return Ok ( ( ) ) ;
3003
3005
} ;
3004
3006
let mut spans = Vec :: with_capacity ( 3 ) ;
3005
3007
spans. push ( start) ;
3008
+ // |||||||
3006
3009
let mut middlediff3 = None ;
3010
+ // =======
3007
3011
let mut middle = None ;
3012
+ // >>>>>>>
3008
3013
let mut end = None ;
3009
3014
loop {
3010
3015
if self . token . kind == TokenKind :: Eof {
@@ -3025,29 +3030,50 @@ impl<'a> Parser<'a> {
3025
3030
}
3026
3031
self . bump ( ) ;
3027
3032
}
3033
+
3028
3034
let mut err = self . dcx ( ) . struct_span_err ( spans, "encountered diff marker" ) ;
3029
- err. span_label ( start, "after this is the code before the merge" ) ;
3030
- if let Some ( middle) = middlediff3 {
3031
- err. span_label ( middle, "" ) ;
3032
- }
3035
+ match middlediff3 {
3036
+ // We're using diff3
3037
+ Some ( middlediff3) => {
3038
+ err. span_label (
3039
+ start,
3040
+ "between this marker and `|||||||` is the code that we're merging into" ,
3041
+ ) ;
3042
+ err. span_label ( middlediff3, "between this marker and `=======` is the base code (what the two refs diverged from)" ) ;
3043
+ }
3044
+ None => {
3045
+ err. span_label (
3046
+ start,
3047
+ "between this marker and `=======` is the code that we're merging into" ,
3048
+ ) ;
3049
+ }
3050
+ } ;
3051
+
3033
3052
if let Some ( middle) = middle {
3034
- err. span_label ( middle, "" ) ;
3053
+ err. span_label ( middle, "between this marker and `>>>>>>>` is the incoming code " ) ;
3035
3054
}
3036
3055
if let Some ( end) = end {
3037
- err. span_label ( end, "above this are the incoming code changes " ) ;
3056
+ err. span_label ( end, "this marker concludes the conflict region " ) ;
3038
3057
}
3039
- err. help (
3040
- "if you're having merge conflicts after pulling new code, the top section is the code \
3041
- you already had and the bottom section is the remote code",
3058
+ err. note (
3059
+ "conflict markers indicate that a merge was started but could not be completed due \
3060
+ to merge conflicts\n \
3061
+ to resolve a conflict, keep only the code you want and then delete the lines \
3062
+ containing conflict markers",
3042
3063
) ;
3043
3064
err. help (
3044
- "if you're in the middle of a rebase, the top section is the code being rebased onto \
3045
- and the bottom section is the code coming from the current commit being rebased",
3065
+ "if you're having merge conflicts after pulling new code:\n \
3066
+ the top section is the code you already had and the bottom section is the remote code\n \
3067
+ if you're in the middle of a rebase:\n \
3068
+ the top section is the code being rebased onto and the bottom section is the code \
3069
+ coming from the current commit being rebased",
3046
3070
) ;
3071
+
3047
3072
err. note (
3048
- "for an explanation on these markers from the `git` documentation, visit \
3049
- <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
3073
+ "for an explanation on these markers from the `git` documentation: \n \
3074
+ visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
3050
3075
) ;
3076
+
3051
3077
Err ( err)
3052
3078
}
3053
3079
0 commit comments