diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-12-03 15:02:27 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-12-06 10:06:10 -0800 |
| commit | 0f306a7db431f335b5a3d94c31222a8b008d5437 (patch) | |
| tree | 9cc589cf0d84f6664370a39af36b19c092f741fb | |
| parent | d0126e8ed3cc0d6fcb9dd44c36a46f9ce65010a0 (diff) | |
| download | rust-0f306a7db431f335b5a3d94c31222a8b008d5437.tar.gz rust-0f306a7db431f335b5a3d94c31222a8b008d5437.zip | |
Do not ICE on async fn with non-Copy infered type arg
Fix #66958.
| -rw-r--r-- | src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-66958.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-66958.stderr | 13 |
3 files changed, 38 insertions, 9 deletions
diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index d14957b9017..a0f126fb2cb 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -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(¶m_ty, tcx); - let generics = tcx.hir().get_generics(self.mir_def_id).unwrap(); - suggest_constraining_type_param( - generics, - &mut err, - ¶m.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, + ¶m.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]; diff --git a/src/test/ui/issues/issue-66958.rs b/src/test/ui/issues/issue-66958.rs new file mode 100644 index 00000000000..a4c48ab05c0 --- /dev/null +++ b/src/test/ui/issues/issue-66958.rs @@ -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() {} diff --git a/src/test/ui/issues/issue-66958.stderr b/src/test/ui/issues/issue-66958.stderr new file mode 100644 index 00000000000..79a80168a5e --- /dev/null +++ b/src/test/ui/issues/issue-66958.stderr @@ -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`. |
