-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #82442 - Aaron1011:fix/closure-mut-crash, r=matthewja…
…sper Skip emitting closure diagnostic when closure_kind_origins has no entry Fixes #82438 This map is not guarnateed to have an entry for a closure.
- Loading branch information
Showing
3 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::error::Error; | ||
struct A { | ||
} | ||
|
||
impl A { | ||
pub fn new() -> A { | ||
A { | ||
} | ||
} | ||
|
||
pub fn f<'a>( | ||
&'a self, | ||
team_name: &'a str, | ||
c: &'a mut dyn FnMut(String, String, u64, u64) | ||
) -> Result<(), Box<dyn Error>> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
|
||
fn main() { | ||
let A = A::new(); | ||
let participant_name = "A"; | ||
|
||
let c = |a, b, c, d| {}; | ||
|
||
A.f(participant_name, &mut c); //~ ERROR cannot borrow | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0596]: cannot borrow `c` as mutable, as it is not declared as mutable | ||
--> $DIR/issue-82438-mut-without-upvar.rs:27:27 | ||
| | ||
LL | let c = |a, b, c, d| {}; | ||
| - help: consider changing this to be mutable: `mut c` | ||
LL | | ||
LL | A.f(participant_name, &mut c); | ||
| ^^^^^^ cannot borrow as mutable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0596`. |