Skip to content
This repository was archived by the owner on Mar 1, 2019. It is now read-only.

Unexpected macro def #47

Closed
nrc opened this issue Mar 2, 2017 · 3 comments
Closed

Unexpected macro def #47

nrc opened this issue Mar 2, 2017 · 3 comments

Comments

@nrc
Copy link
Member

nrc commented Mar 2, 2017

{
	"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
Copy link
Member Author

nrc commented Mar 7, 2017

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
Copy link
Member Author

nrc commented Mar 7, 2017

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
Copy link
Member Author

nrc commented Mar 7, 2017

rust-lang/rust#40311

@nrc nrc closed this as completed Mar 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant