Skip to content

Second panicking custom derive has bad span #36935

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
alexcrichton opened this issue Oct 3, 2016 · 5 comments · Fixed by #38607
Closed

Second panicking custom derive has bad span #36935

alexcrichton opened this issue Oct 3, 2016 · 5 comments · Fixed by #38607
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@alexcrichton
Copy link
Member

Inlined from #35900 (comment)


Another issue. If a struct has two different custom derives on it and the second one panics, the error span will point to the first one, not the one which panicked.

Reproduction Script

@alexcrichton
Copy link
Member Author

@sgrif was "Reproduction Script" supposed to be a link? I'm spinning this off from #35900 (comment) as I don't think it's going to block stabilization and/or closing that issue.

@sgrif
Copy link
Contributor

sgrif commented Oct 3, 2016

Reproduction script there is a summary tag

@sgrif
Copy link
Contributor

sgrif commented Oct 3, 2016

Reproduction Script

In a crate called demo_plugin

#![feature(rustc_macro, rustc_macro_lib)]

extern crate rustc_macro;

use rustc_macro::TokenStream;

#[rustc_macro_derive(Foo)]
pub fn derive_foo(input: TokenStream) -> TokenStream {
    input
}

#[rustc_macro_derive(Bar)]
pub fn derive_bar(input: TokenStream) -> TokenStream {
    panic!("lolnope");
}

In another crate

#![feature(rustc_macro)]

#[macro_use] extern crate demo_plugin;

#[derive(Foo, Bar)]
struct Baz {
    a: i32,
    b: i32,
}

The error will highlight Foo even though Bar panicked.

@keeperofdakeys
Copy link
Contributor

This seems to be fixed now, so this issue can be closed.

@sfackler sfackler added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Nov 8, 2016
@keeperofdakeys
Copy link
Contributor

I ran this as a test, and got the following output:

   Compiling b v0.1.0 (file:///tmp/b)
error: custom derive attribute panicked
 --> src/lib.rs:5:15
  |
5 | #[derive(Foo, Bar)]
  |               ^^^
  |
  = help: message: lolnope

error: Could not compile `b`.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 4, 2017
…nkov

Test for appropriate span on second custom derive

Adds test for and closes rust-lang#36935.
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 4, 2017
…nkov

Test for appropriate span on second custom derive

Adds test for and closes rust-lang#36935.
sanxiyn added a commit to sanxiyn/rust that referenced this issue Jan 10, 2017
…hton

Test for appropriate span on second custom derive

Adds test for and closes rust-lang#36935.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants