Skip to content

Commit c2702e3

Browse files
authored
Rollup merge of #67149 - JohnTitor:fix-ice-1, r=Dylan-DPC
Do not ICE #67123 Fixes #67123 r? @matthewjasper
2 parents 5ce5464 + b879ecc commit c2702e3

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
240240
let tcx = self.infcx.tcx;
241241
let generics = tcx.generics_of(self.mir_def_id);
242242
let param = generics.type_param(&param_ty, tcx);
243-
if let Some(generics) = tcx.hir().get_generics(self.mir_def_id) {
243+
if let Some(generics) =
244+
tcx.hir().get_generics(tcx.closure_base_def_id(self.mir_def_id)) {
244245
suggest_constraining_type_param(
245246
generics,
246247
&mut err,

src/test/ui/closures/issue-67123.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn foo<T>(t: T) {
2+
|| { t; t; }; //~ ERROR: use of moved value
3+
}
4+
5+
fn main() {}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0382]: use of moved value: `t`
2+
--> $DIR/issue-67123.rs:2:13
3+
|
4+
LL | fn foo<T>(t: T) {
5+
| - help: consider restricting this bound: `T: Copy`
6+
LL | || { t; t; };
7+
| - ^ value used here after move
8+
| |
9+
| value moved here
10+
|
11+
= note: move occurs because `t` has type `T`, which does not implement the `Copy` trait
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0382`.

0 commit comments

Comments
 (0)