Skip to content

file!, line! and col! (and possibly module!) do the Wrong Thing. #3066

Closed
@paulstansifer

Description

@paulstansifer

In the following code, the error message refers to the location of the macro calls at HERE, not NOTHERE. I think this (a) isn't what happens in C, etc., and (b) is never useful.

Fixing this should be a simple mater of getting the syntax backtrace from cx in source_util.rs and finding the topmost span, and ignoring the span that's temptingly passed in as an argument. Except that the results won't be any different until #3065 is fixed.

macro_rules! my_complex_macro {
    { } => {
        fmt!("You invoked the macro wrong! (%s:%u:%u)",
             file!(), line!(), col!()) //HERE
    }
}

fn main() {
    io::println(my_complex_macro!()); //NOT HERE
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensionsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions