Skip to content

Warnings and error suggestions are wrong when originating from inside proc-macros #50141

Open
@bjorn3

Description

@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:18: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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions