diff options
| author | bors <bors@rust-lang.org> | 2022-10-14 07:41:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-14 07:41:55 +0000 |
| commit | 32717603f61a566ff0b8293ef3177cb7c4f50fa9 (patch) | |
| tree | cc33fd4c0f6cdf11caf2f0aa7e1cd72ed791f89f | |
| parent | 1755c8530287d9f29d8d188e5d7a57f6aa35cf7f (diff) | |
| parent | 42321b01e0acc46839dfecd78985174e4e6ef417 (diff) | |
| download | rust-32717603f61a566ff0b8293ef3177cb7c4f50fa9.tar.gz rust-32717603f61a566ff0b8293ef3177cb7c4f50fa9.zip | |
Auto merge of #102695 - compiler-errors:int-and-float-trivial-copy, r=lcnr
Int and float inference variables are trivially copy Fixes #102645
4 files changed, 50 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs b/compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs index e22675e9d5f..2f68b57a019 100644 --- a/compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs +++ b/compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs @@ -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 diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 64636963313..cf420bafeb1 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -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, diff --git a/src/test/ui/generator/issue-102645.rs b/src/test/ui/generator/issue-102645.rs new file mode 100644 index 00000000000..0589c5a009a --- /dev/null +++ b/src/test/ui/generator/issue-102645.rs @@ -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() { + () +} diff --git a/src/test/ui/generator/issue-102645.stderr b/src/test/ui/generator/issue-102645.stderr new file mode 100644 index 00000000000..7b4d5021325 --- /dev/null +++ b/src/test/ui/generator/issue-102645.stderr @@ -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`. |
