- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Closed
Closed
Copy link
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
.Current output
error[E0500]: closure requires unique access to `*self` but it is already borrowed
   --> compiler/rustc_resolve/src/macros.rs:828:25
    |
824 |                       self.visit_scopes(
    |                       -    ------------ first borrow later used by call
    |  _____________________|
    | |
825 | |                         ScopeSet::Macro(MacroKind::Derive),
826 | |                         &parent_scope,
827 | |                         ident.span.ctxt(),
828 | |                         |this, scope, use_prelude, ctxt| {
    | |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ closure construction occurs here
...   |
839 | |                                                     let x = self.get_macro_by_def_id(def_id);
    | |                                                             ---- second borrow occurs due to use of `*self` in closure
...   |
861 | |                         },
862 | |                     );
    | |_____________________- borrow occurs hereDesired output
error[E0500]: closure requires unique access to `*self` but it is already borrowed
   --> compiler/rustc_resolve/src/macros.rs:828:25
    |
824 |                       self.visit_scopes(
    |                       -    ------------ first borrow later used by call
    |  _____________________|
    | |
825 | |                         ScopeSet::Macro(MacroKind::Derive),
826 | |                         &parent_scope,
827 | |                         ident.span.ctxt(),
828 | |                         |this, scope, use_prelude, ctxt| {
    | |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ closure construction occurs here
...   |
839 | |                                                     let x = self.get_macro_by_def_id(def_id);
    | |                                                             ----
    | |                                                             |
    | |                                                             second borrow occurs due to use of `*self` in closure
    | |                                                             help: a closure argument with the same type as `self` is available, you might have meant to use that: `this`
...   |
861 | |                         },
862 | |                     );
    | |_____________________- borrow occurs hereRationale and extra context
No response
Other cases
No response
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.