-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)D-editionDiagnostics: An error or lint that should account for edition differences.Diagnostics: An error or lint that should account for edition differences.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.
Description
#![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 (`|…| { … }`)Area: Closures (`|…| { … }`)D-editionDiagnostics: An error or lint that should account for edition differences.Diagnostics: An error or lint that should account for edition differences.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.