rust-dev-tools / rls-analysis

Core functionality for handling rustc's save-analysis data
39 stars 26 forks source link

Unexpected macro def #47

Closed nrc closed 7 years ago

nrc commented 7 years ago
{
    "message": "/checkout/src/librustc_save_analysis/dump_visitor.rs:341: process_def_kind for unexpected item: Macro(DefId { krate: CrateNum(105), node: DefIndex(1) => dom_struct/5a34075aa16a3b97e60148202989464b::{{?}}[0] }, Attr)",
    "code": null,
    "level": "error: internal compiler error",
    "spans": [{
        "file_name": "/home/ncameron/servo/components/script/dom/attr.rs",
        "byte_start": 74612,
        "byte_end": 74634,
        "line_start": 15,
        "line_end": 15,
        "column_start": 5,
        "column_end": 27,
        "is_primary": true,
        "text": [{
            "text": "use dom_struct::dom_struct;",
            "highlight_start": 5,
            "highlight_end": 27
        }],
        "label": null,
        "suggested_replacement": null,
        "expansion": null
    }],
    "children": [],
    "rendered": null
}
nrc commented 7 years ago

Minimal test case:

bar.rs:

#![feature(proc_macro)]
extern crate proc_macro;

use proc_macro::TokenStream;
use std::str::FromStr;

#[proc_macro_attribute]
pub fn dom_struct(_args: TokenStream, input: TokenStream) -> TokenStream {
    TokenStream::from_str(&input.to_string().replace("Attr", "FooAttr")).unwrap()
}

foo.rs:

#![feature(proc_macro)]

extern crate bar;

use bar::dom_struct;

#[dom_struct]
pub struct Attr {
    f: i32,
}

fn main() {
}
nrc commented 7 years ago

The ICE is easy to deal, with but then that exposes a span error - a span which should show up as generated code does not.

nrc commented 7 years ago

https://github.com/rust-lang/rust/pull/40311