Seed: line macro interferes with assert macro

Created on 5 Feb 2019  路  6Comments  路  Source: seed-rs/seed

Consider (using seed v0.2.6):

#[macro_use]
extern crate seed;

fn main () {
    assert!(true);
}

cargo expand displays:

fn main() {
    if !true {

        {
            ::std::rt::begin_panic("assertion failed: true",
                                   &("iml-action-dropdown/src/lib.rs",
                                     {
                                         let mut el =
                                             El::empty_svg(seed::dom_types::Tag::Line);
                                         el
                                     }, 5u32))
        }
    };
}

I've tracked this down to the line! macro.

If we do not import the line! macro, the assert expands as expected.

bug

Most helpful comment

Fixed in the latest release; 0.2.7

All 6 comments

Nice find. Appears to occur with any macro named line. Can reproduce by making a new crate with cargo new cratename --bin, with this as main.rs:

#[macro_export]
macro_rules! line {
    ( a:expr ) => {

    }
}

fn main() {
    assert!(true);
}

In next commit/release, have renamed the line! macro to line_!.

edit: line! appears to be a builtin macro.

馃憤 Any idea why the macro gets expanded this way?

@johnsonw It appears to be because the assert! macro is invoking the line! macro to get the line the assert appears on.

When the seed line! macro is in scope, it's overwriting the builtin one.

Understood. That makes sense.

I'm seeing the same error with dbg!() and panic!() macros:

error[E0433]: failed to resolve: use of undeclared type or module `El`
  --> src/parser.rs:23:9
   |
23 |         dbg!(s);
   |         ^^^^^^^^ use of undeclared type or module `El`
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

Fixed in the latest release; 0.2.7

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MartinKavik picture MartinKavik  路  4Comments

MartinKavik picture MartinKavik  路  3Comments

FliegendeWurst picture FliegendeWurst  路  3Comments

TuntematonSotilas picture TuntematonSotilas  路  3Comments

dashed picture dashed  路  5Comments