Skip to content

Weird error output when combining syn::Error in expression context #1964

@danielparks

Description

@danielparks

Test repo: https://github.com/danielparks/test-syn-error-combine

In a proc macro in expression position, using syn::Error::combine() on generates weird error output (see below, or see the test repo for slightly more comprehensive examples). This does not happen if combine() is not used (actually, I’m calling extend(), but I ran into the same problem with an explicit combine()), or if the macro is called as a statement.

I’m not sure if this is a bug in syn, some other code, or if I am making an obvious mistake. I’m happy to dig into this more, but pointers would be appreciated.

error: missing angle brackets in associated item path
  --> tests/output.rs:15:19
   |
15 |     let _ = fail!("a" "b");
   |                   ^^^
   |
help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths
   |
15 |     let _ = fail!(<"a"> "b");
   |                   +   +

error: macro expansion ignores `!` and any tokens following
  --> tests/output.rs:15:23
   |
15 |     let _ = fail!("a" "b");
   |             ----------^^^- caused by the macro expansion here
   |
   = note: the usage of `fail!` is likely invalid in expression context

error: ERROR "a"
  --> tests/output.rs:15:19
   |
15 |     let _ = fail!("a" "b");
   |                   ^^^

error[E0223]: ambiguous associated type
  --> tests/output.rs:15:19
   |
15 |     let _ = fail!("a" "b");
   |                   ^^^^^^^
   |
help: if there were a trait named `Example` with associated type `core` implemented for `()`, you could use the fully-qualified path
   |
15 -     let _ = fail!("a" "b");
15 +     let _ = fail!(<() as Example>::"b");
   |

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