Skip to content

Commit

Permalink
Do not ICE on closure
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Dec 9, 2019
1 parent dbbe4f1 commit b879ecc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
Expand Up @@ -240,7 +240,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let tcx = self.infcx.tcx;
let generics = tcx.generics_of(self.mir_def_id);
let param = generics.type_param(&param_ty, tcx);
if let Some(generics) = tcx.hir().get_generics(self.mir_def_id) {
if let Some(generics) =
tcx.hir().get_generics(tcx.closure_base_def_id(self.mir_def_id)) {
suggest_constraining_type_param(
generics,
&mut err,
Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/closures/issue-67123.rs
@@ -0,0 +1,5 @@
fn foo<T>(t: T) {
|| { t; t; }; //~ ERROR: use of moved value
}

fn main() {}
15 changes: 15 additions & 0 deletions src/test/ui/closures/issue-67123.stderr
@@ -0,0 +1,15 @@
error[E0382]: use of moved value: `t`
--> $DIR/issue-67123.rs:2:13
|
LL | fn foo<T>(t: T) {
| - help: consider restricting this bound: `T: Copy`
LL | || { t; t; };
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `t` has type `T`, which does not implement the `Copy` trait

error: aborting due to previous error

For more information about this error, try `rustc --explain E0382`.

0 comments on commit b879ecc

Please sign in to comment.