Skip to content

Commit 28d3fef

Browse files
committed
Add a test case for rust-lang#137646
1 parent 2b3cef8 commit 28d3fef

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//! Regression test for https://github.com/rust-lang/rust/issues/137646.
2+
//! FIXME: The parameter value at all calls to `check` should be `(1, 1, 1)`.
3+
4+
//@ run-pass
5+
//@ check-run-results
6+
7+
use std::hint::black_box;
8+
9+
type T = (i32, i32, i32);
10+
11+
pub trait Trait {
12+
fn m(&self, _: T, _: T) {}
13+
}
14+
15+
impl Trait for () {
16+
fn m(&self, mut _v1: T, v2: T) {
17+
_v1 = (0, 0, 0);
18+
check(v2);
19+
}
20+
}
21+
22+
pub fn run_1(trait_: &dyn Trait) {
23+
let v1 = (1, 1, 1);
24+
let v2 = (1, 1, 1);
25+
trait_.m(v1, v2);
26+
}
27+
28+
pub fn run_2(trait_: &dyn Trait) {
29+
let v1 = (1, 1, 1);
30+
let v2 = (1, 1, 1);
31+
trait_.m(v1, v2);
32+
check(v1);
33+
check(v2);
34+
}
35+
36+
#[inline(never)]
37+
fn check(v: T) {
38+
dbg!(v);
39+
// assert_eq!(v, (1, 1, 1));
40+
}
41+
42+
fn main() {
43+
black_box(run_1 as fn(&dyn Trait));
44+
black_box(run_2 as fn(&dyn Trait));
45+
run_1(&());
46+
run_2(&());
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[$DIR/virtual-call-attrs-issue-137646.rs:38:5] v = (
2+
498486832,
3+
22093,
4+
498491440,
5+
)
6+
[$DIR/virtual-call-attrs-issue-137646.rs:38:5] v = (
7+
0,
8+
0,
9+
0,
10+
)
11+
[$DIR/virtual-call-attrs-issue-137646.rs:38:5] v = (
12+
0,
13+
0,
14+
0,
15+
)
16+
[$DIR/virtual-call-attrs-issue-137646.rs:38:5] v = (
17+
0,
18+
0,
19+
0,
20+
)

0 commit comments

Comments
 (0)