Skip to content

rust_2021_incompatible_closure_captures suggestion expands macro #87955

Closed
@m-ou-se

Description

@m-ou-se
#![warn(rust_2021_incompatible_closure_captures)]

fn main() {
    let a = ("hey".to_string(), "123".to_string());
    let _ = || dbg!(a.0);
}

produces:

help: add a dummy let to cause `a` to be fully captured
  |
29~         { let _ = &a; match $val {
29+             tmp => {
29+                 $crate::eprintln!("[{}:{}] {} = {:#?}",
30+                     $crate::file!(), $crate::line!(), $crate::stringify!($val), &tmp);
30+                 tmp
30+             }
...

It expanded the dbg!() macro. This only happens when the macro invocation is the entire body of the closure.

Metadata

Metadata

Assignees

Labels

A-closuresArea: Closures (`|…| { … }`)D-editionDiagnostics: An error or lint that should account for edition differences.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions