mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-17 19:14:16 +00:00
Do not ICE on closure
This commit is contained in:
parent
dbbe4f10fa
commit
b879ecccd0
@ -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(¶m_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,
|
||||
|
5
src/test/ui/closures/issue-67123.rs
Normal file
5
src/test/ui/closures/issue-67123.rs
Normal file
@ -0,0 +1,5 @@
|
||||
fn foo<T>(t: T) {
|
||||
|| { t; t; }; //~ ERROR: use of moved value
|
||||
}
|
||||
|
||||
fn main() {}
|
15
src/test/ui/closures/issue-67123.stderr
Normal file
15
src/test/ui/closures/issue-67123.stderr
Normal 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`.
|
Loading…
Reference in New Issue
Block a user