Warnings and error suggestions are wrong when originating from inside proc-macros · Issue #50141 · rust-lang/rust (original) (raw)

@bjorn3

For example

warning: unused import: `Form`
  --> example/src/main.rs:11:26
   |
11 | #[derive(Debug, Default, Form)]
   |                          ^^^^
   |
   = note: #[warn(unused_imports)] on by default

error[E0369]: binary operation `+` cannot be applied to type `&str`
  --> example/src/main.rs🔞26
   |
18 | #[derive(Debug, Default, Form)]
   |                          ^^^^ `+` can't be used to concatenate two `&str` strings
help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
   |
18 | #[derive(Debug, Default, Form.to_owned())]
   |

when the expanded source contains

use self::gtk::{Widget, Button, ComboBoxText, Label};

// and

let _ = "a" + "b";

with ComboBoxText being unused.