Skip to content

Syntactic context discarded when quoting a macro invocation #16617

Closed
@kmcallister

Description

@kmcallister

#15750 is fixed now, but a variant of the same issue occurs when quoting a macro invocation.

Using plugin.rs from #15750 and this test.rs:

#![feature(phase)]

#[phase(plugin)]
extern crate plugin;

fn main() {
    let x = true;
    println!("{}", mymacro!(assert!(x)));
}

I get this result:

$ rustc -v
rustc 0.12.0-pre (3f5d0b5b6 2014-08-19 16:35:51 +0000)

$ rustc plugin.rs

$ rustc -L. test.rs
<quote expansion>:1:20: 1:21 error: unresolved name `x`.
<quote expansion>:1 name_64,ctxt_11!(x)
                                       ^
<std macros>:1:1: 12:2 note: in expansion of assert!
<quote expansion>:1:1: 1:22 note: expansion site
test.rs:1:1: 9:1 note: in expansion of mymacro!
test.rs:8:20: 8:40 note: expansion site
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
test.rs:8:5: 8:42 note: expansion site
error: aborting due to previous error

Also the NULL characters used to delimit the magic identifier string appear in the error output, which causes the error caret to appear in the wrong place.

See also #15962.

CC @pnkfelix. This is still a huge improvement from before and I think I can work around the remaining issues in html5ever. Thank you for fixing #15750 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions