Skip to content

Fix up the spans for type errors #1

@chris-morgan

Description

@chris-morgan

Compare assert and assert_ng when there is a type error, and you’ll see assert_ng isn’t faring well.

assert_ng:

a.rs:12:5: 12:25 error: mismatched types: expected `int`, found `&int` (expected int, found &-ptr)
a.rs:12     assert_ng!(a == &a);
            ^~~~~~~~~~~~~~~~~~~~
a.rs:1:1: 14:1 note: in expansion of assert_ng!
a.rs:12:5: 12:25 note: expansion site

assert:

a.rs:13:18: 13:20 error: mismatched types: expected `int`, found `&int` (expected int, found &-ptr)
a.rs:13     assert!(a == &a);
                         ^~
<std macros>:1:1: 12:2 note: in expansion of assert!
a.rs:13:5: 13:22 note: expansion site

Using quote_expr just isn’t going to cut it for getting it perfect; it’s going to need a manually constructed AST with spans carefully arranged in some way to get the correspondence correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions