Skip to content

Commit 5c2870e

Browse files
authored
Unrolled build for rust-lang#127948
Rollup merge of rust-lang#127948 - surechen:fix_127915, r=compiler-errors fixes panic error `index out of bounds` in conflicting error fixes rust-lang#127915
2 parents 41ff460 + 9747a2c commit 5c2870e

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
456456
if let Some(def_id) = def_id
457457
&& self.infcx.tcx.def_kind(def_id).is_fn_like()
458458
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
459-
&& let ty::Param(_) =
460-
self.infcx.tcx.fn_sig(def_id).skip_binder().skip_binder().inputs()
461-
[pos + offset]
462-
.kind()
459+
&& let Some(arg) = self
460+
.infcx
461+
.tcx
462+
.fn_sig(def_id)
463+
.skip_binder()
464+
.skip_binder()
465+
.inputs()
466+
.get(pos + offset)
467+
&& let ty::Param(_) = arg.kind()
463468
{
464469
let place = &self.move_data.move_paths[mpi].place;
465470
let ty = place.ty(self.body, self.infcx.tcx).ty;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![allow(dead_code)]
2+
3+
extern "C" {
4+
fn rust_interesting_average(_: i64, ...) -> f64;
5+
}
6+
7+
fn test<T, U>(a: i64, b: i64, c: i64, d: i64, e: i64, f: T, g: U) -> i64 {
8+
unsafe {
9+
rust_interesting_average(
10+
6, a as f64, b, b as f64, f, c as f64, d, d as f64, e, e as f64, f, g, //~ ERROR use of moved value: `f` [E0382]
11+
) as i64
12+
}
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0382]: use of moved value: `f`
2+
--> $DIR/move-error-suggest-clone-panic-issue-127915.rs:10:78
3+
|
4+
LL | fn test<T, U>(a: i64, b: i64, c: i64, d: i64, e: i64, f: T, g: U) -> i64 {
5+
| - move occurs because `f` has type `T`, which does not implement the `Copy` trait
6+
...
7+
LL | 6, a as f64, b, b as f64, f, c as f64, d, d as f64, e, e as f64, f, g,
8+
| - value moved here ^ value used here after move
9+
|
10+
help: if `T` implemented `Clone`, you could clone the value
11+
--> $DIR/move-error-suggest-clone-panic-issue-127915.rs:7:9
12+
|
13+
LL | fn test<T, U>(a: i64, b: i64, c: i64, d: i64, e: i64, f: T, g: U) -> i64 {
14+
| ^ consider constraining this type parameter with `Clone`
15+
...
16+
LL | 6, a as f64, b, b as f64, f, c as f64, d, d as f64, e, e as f64, f, g,
17+
| - you could clone this value
18+
help: consider restricting type parameter `T`
19+
|
20+
LL | fn test<T: Copy, U>(a: i64, b: i64, c: i64, d: i64, e: i64, f: T, g: U) -> i64 {
21+
| ++++++
22+
23+
error: aborting due to 1 previous error
24+
25+
For more information about this error, try `rustc --explain E0382`.

0 commit comments

Comments
 (0)