Do not ICE on closure

This commit is contained in:
Yuki Okushi 2019-12-08 20:54:54 +09:00
parent dbbe4f10fa
commit b879ecccd0
3 changed files with 22 additions and 1 deletions

View File

@ -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,

View File

@ -0,0 +1,5 @@
fn foo<T>(t: T) {
|| { t; t; }; //~ ERROR: use of moved value
}
fn main() {}

View File

@ -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`.