-
Notifications
You must be signed in to change notification settings - Fork 85
Regression on 0.6 on rust messages with attribute macro #125
Comments
This is caused by #90 (comment), in other words a problem in proc-macro2. I think the hope is proc-macro2 will land the required feature soon. |
See dtolnay/proc-macro2#104 and rust-lang/rust#43081 for reference. |
Maybe updating to syn 0.15 will fix this problem: https://github.com/dtolnay/syn/releases/tag/0.15.0 |
@TeXitoi do you have steps to reproduce the problem you are seeing? That way we can evaluate if moving to syn 0.15.0 helps or not. in particular, I'm seeing that debugging works as intended on 1.30-beta. This is using the dev profile. What version of GDB are you using? Compile errors on statements also have the correct span. // ..
#[entry]
fn main() -> ! {
let x: () = 42;
loop {}
} $ cargo build
error[E0308]: mismatched types
--> src/main.rs:14:17
|
14 | let x: () = 42;
| ^^ expected (), found integral variable
|
= note: expected type `()`
found type `{integer}` Where I see incorrect spans is when e.g. the // ..
#[entry]
fn main() -> ! {}
Enabling the nightly feature of proc-macro2 should be documented in the crate level documentation. |
I'm on debian stable, gdb-arm-none-eabi 7.12-6+9+b2 But I can't reproduce anymore the error. Maybe a bad nightly. I close this, and I'll reopen if I manage to reproduce. |
127: bump the syn dependency r=therealprof a=japaric and switch to the recommended way to parse tokens: `parse_macro_input!`. This improves (?) error messages when the user applies one of our attributes to an item that's not a function. Consider ``` rust #[entry] static MAIN: () = (); ``` The error message changed from: ``` error: custom attribute panicked --> src/main.rs:10:1 | 10 | #[entry] | ^^^^^^^^ | = help: message: `#[entry]` must be applied to a function: ParseError(Some("failed to parse fn item: failed to parse")) ``` to: ``` error: expected `fn` --> src/main.rs:11:1 | 11 | static MAIN: () = (); | ^^^^^^ error: aborting due to previous error ``` --- Before landing this I'd like to hear more details about #125 to see if this helps Co-authored-by: Jorge Aparicio <[email protected]>
I can reproduce this issue and have put code to reproduce this at https://github.com/johkra/repro. If I declare the i2c mode inline, cargo check shows the following output:
Note how the warning about the unused variable i2c points to the entry macro instead of the actual line. If I perform a slight change and return the mode declaration from a function instead of inline, the warning points to the correct place. Diff:
Cargo check:
|
What if you add a coma after 100000? I think I've seen a bug report by the rocket author about something like that, bit I can't find it anymore. |
@SergioBenitez maybe you know the issue? |
With a comma after 100000 it should work. This is a compiler bug: rust-lang/rust#43081. |
Oups, I didn't scroll then I checked this issue! Thanks @dtolnay. |
I confirm that after adding the comma the warning points to the correct line and not to the macro invocation. Glad to hear that this is a known issue and people are working on it! |
Hi!
When using the new attribute macro (
#[entry] fn main() -> ! { loop {} }
, I have a big regression when compiling and using a debugger: everything (error, warning and debugger) point to the attribute line, making debugging tricky.A workaround is to directly call another function, but that's quite dirty:
The text was updated successfully, but these errors were encountered: