Skip to content
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

Int and float inference variables are trivially copy #102695

Merged
merged 2 commits into from
Oct 14, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {

// If the type being assigned needs dropped, then the mutation counts as a borrow
// since it is essentially doing `Drop::drop(&mut x); x = new_value;`.
//
// FIXME(drop-tracking): We need to be more responsible about inference
// variables here, since `needs_drop` is a "raw" type query, i.e. it
// basically requires types to have been fully resolved.
if assignee_place.place.base_ty.needs_drop(self.tcx, self.param_env) {
self.places
.borrowed
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,10 @@ impl<'tcx> Ty<'tcx> {
// These aren't even `Clone`
ty::Str | ty::Slice(..) | ty::Foreign(..) | ty::Dynamic(..) => false,

ty::Int(..) | ty::Uint(..) | ty::Float(..) => true,
ty::Infer(ty::InferTy::FloatVar(_) | ty::InferTy::IntVar(_))
| ty::Int(..)
| ty::Uint(..)
| ty::Float(..) => true,

// The voldemort ZSTs are fine.
ty::FnDef(..) => true,
Expand Down
23 changes: 23 additions & 0 deletions src/test/ui/generator/issue-102645.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// compile-flags: -Zdrop-tracking

#![feature(generators, generator_trait)]

use std::ops::Generator;
use std::pin::Pin;

fn main() {
let mut a = 5;
let mut b = || {
let d = 6;
yield;
_zzz(); // #break
a = d;
};
Pin::new(&mut b).resume();
//~^ ERROR this function takes 1 argument but 0 arguments were supplied
// This type error is required to reproduce the ICE...
}

fn _zzz() {
()
}
19 changes: 19 additions & 0 deletions src/test/ui/generator/issue-102645.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/issue-102645.rs:16:22
|
LL | Pin::new(&mut b).resume();
| ^^^^^^-- an argument of type `()` is missing
|
note: associated function defined here
--> $SRC_DIR/core/src/ops/generator.rs:LL:COL
|
LL | fn resume(self: Pin<&mut Self>, arg: R) -> GeneratorState<Self::Yield, Self::Return>;
| ^^^^^^
help: provide the argument
|
LL | Pin::new(&mut b).resume(());
| ~~~~

error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.