Skip to content

Give nice errors on merge conflict markers #44403

@chris-morgan

Description

@chris-morgan

Take code like this:

<<<<<<< HEAD
fn foo() -> Foo { }
=======
pub fn foo() -> Foo { }
>>>>>>> something

Outside macros and strings, this kind of thing will always fail to parse (seven equals signs in a row is always illegal), though the precise errors it will fail with will vary depends on the context.

It’d be nice if the compiler, on detecting a syntax error caused by merge conflict markers, gave a friendlier error message, something like this:

error: file contains merge conflict markers
  --> <anon>:1:1
   |
1  | <<<<<<< HEAD
   | ^^^^^^^ merge conflict marker here

(Inspiration: Perl 5.26.0 produces a syntax error like “Version control conflict marker at line 123” thanks to https://rt.perl.org/Public/Bug/Display.html?id=127993.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions