Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// edition:2018

struct Ia<S>(S);

impl<S> Ia<S> {
fn partial(_: S) {}
fn full(self) {}

async fn crash(self) {
Self::partial(self.0);
Self::full(self); //~ ERROR use of moved value: `self`
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error[E0382]: use of moved value: `self`
--> $DIR/issue-66958-non-copy-infered-type-arg.rs:11:20
|
LL | Self::partial(self.0);
| ------ value moved here
LL | Self::full(self);
| ^^^^ value used here after partial move
|
= note: move occurs because `self.0` 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`.