Skip to content

Commit 0cad03c

Browse files
Rollup merge of rust-lang#158472 - chenyukang:yukang-fix-154568-unexpected-pointer-deref, r=mu001999
Add regression test for unexpected pointer dereference issue I try to pick up rust-lang#154568 and found it's fixed by rust-lang@4767f23. Fixes rust-lang#154568 cc @adwinwhite
2 parents 45a870a + 480ddb0 commit 0cad03c

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Regression test for #154568
2+
//@ compile-flags: -Znext-solver=globally
3+
4+
trait Role {
5+
type Inner;
6+
}
7+
8+
struct HandshakeCallback<C>(C);
9+
struct Handshake<R: Role>(R::Inner);
10+
11+
fn main() {
12+
let callback = HandshakeCallback(());
13+
let handshake = Handshake(callback.0.clone());
14+
//~^ ERROR type annotations needed
15+
match &handshake {
16+
hs if (|| {
17+
let borrowed_inner = &hs.0;
18+
borrowed_inner == &callback.0
19+
})() => println!(),
20+
_ => {}
21+
}
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0283]: type annotations needed for `Handshake<_>`
2+
--> $DIR/unexpected-pointer-deref-issue-154568.rs:13:9
3+
|
4+
LL | let handshake = Handshake(callback.0.clone());
5+
| ^^^^^^^^^ ----------------------------- type must be known at this point
6+
|
7+
= note: the type must implement `Role`
8+
note: required by a bound in `Handshake`
9+
--> $DIR/unexpected-pointer-deref-issue-154568.rs:9:21
10+
|
11+
LL | struct Handshake<R: Role>(R::Inner);
12+
| ^^^^ required by this bound in `Handshake`
13+
help: consider giving `handshake` an explicit type, where the type for type parameter `R` is specified
14+
|
15+
LL | let handshake: Handshake<R> = Handshake(callback.0.clone());
16+
| ++++++++++++++
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)