Do not ICE on async fn with non-Copy infered type arg

Fix #66958.
This commit is contained in:
Esteban Küber 2019-12-03 15:02:27 -08:00
parent d0126e8ed3
commit 0f306a7db4
3 changed files with 38 additions and 9 deletions

View file

@ -240,15 +240,16 @@ 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);
let generics = tcx.hir().get_generics(self.mir_def_id).unwrap();
suggest_constraining_type_param(
generics,
&mut err,
&param.name.as_str(),
"Copy",
tcx.sess.source_map(),
span,
);
if let Some(generics) = tcx.hir().get_generics(self.mir_def_id) {
suggest_constraining_type_param(
generics,
&mut err,
&param.name.as_str(),
"Copy",
tcx.sess.source_map(),
span,
);
}
}
let span = if let Some(local) = place.as_local() {
let decl = &self.body.local_decls[local];

View file

@ -0,0 +1,15 @@
// edition:2018
struct Ia<S>(u32, S);
impl<S> Ia<S> {
fn partial(_: S) {}
fn full(self) {}
async fn crash(self) {
Self::partial(self.1);
Self::full(self); //~ ERROR use of moved value: `self`
}
}
fn main() {}

View file

@ -0,0 +1,13 @@
error[E0382]: use of moved value: `self`
--> $DIR/issue-66958.rs:11:20
|
LL | Self::partial(self.1);
| ------ value moved here
LL | Self::full(self);
| ^^^^ value used here after partial move
|
= note: move occurs because `self.1` has type `S`, which does not implement the `Copy` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.