Skip to content

Conflict markers with nonstandard lengths are not recognized as such #150352

@Fulgen301

Description

@Fulgen301

Code

<<<<<<<<
========
>>>>>>>>
fn main() {}

Current output

error: expected identifier, found `<<`
 --> test.rs:1:1
  |
1 | <<<<<<<<
  | ^^ expected identifier

error: aborting due to 1 previous error

Desired output

error: encountered diff marker
 --> test.rs:1:1
  |
1 | <<<<<<<<
  | ^^^^^^^^ between this marker and `========` is the code that we're merging into
2 | ========
  | -------- between this marker and `>>>>>>>>` is the incoming code
3 | >>>>>>>>
  | ^^^^^^^^ this marker concludes the conflict region
  |
  = note: conflict markers indicate that a merge was started but could not be completed due to merge conflicts
          to resolve a conflict, keep only the code you want and then delete the lines containing conflict markers
  = 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
          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 <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>

error: aborting due to 1 previous error

Rationale and extra context

The default length of conflict markers is 7, but this is not a hard requirement; Git allows configuring the conflict marker size via the conflict-marker-size attribute. While this is a best-effort diagnostic and small conflict markers lengths are ambiguous, anything >=7 should be unambiguous.

Other cases

Rust Version

rustc 1.94.0-nightly (2ca7bcd03 2025-12-23)
binary: rustc
commit-hash: 2ca7bcd03b87b52f7055a59b817443b0ac4a530d
commit-date: 2025-12-23
host: x86_64-pc-windows-msvc
release: 1.94.0-nightly
LLVM version: 21.1.8

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions