Skip to content

suggestion prints expanded macros #41858

Closed
@oli-obk

Description

@oli-obk

= help: try with &mut $ crate :: fmt :: format ( format_args ! ( $ ( $ arg ) * ) )

should be

= help: try with &mut format!("foo")

at the minimum. Even better would be to suggest *s for the s on the lhs of the assignment.

fn main() {
    let s = &mut String::new();
    s = format!("foo");
}

produces

error[E0308]: mismatched types
 --> <anon>:3:9
  |
3 |     s = format!("foo");
  |         ^^^^^^^^^^^^^^ expected mutable reference, found struct `std::string::String`
  |
  = note: expected type `&mut std::string::String`
             found type `std::string::String`
  = help: try with `&mut $ crate :: fmt :: format ( format_args ! ( $ ( $ arg ) * ) )`
  = note: this error originates in a macro outside of the current crate

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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