Skip to content

Commit 0fc2b6c

Browse files
committed
tests: ui: compile-fail: init: add shadowing_field
Signed-off-by: Benno Lossin <lossin@kernel.org>
1 parent db96c51 commit 0fc2b6c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use pin_init::*;
2+
3+
struct Foo {
4+
x: usize,
5+
y: usize,
6+
}
7+
8+
fn main() {
9+
let x = 42;
10+
let _ = init!(Foo { x, y: x });
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0308]: mismatched types
2+
--> tests/ui/compile-fail/init/shadowing_field.rs:10:13
3+
|
4+
10 | let _ = init!(Foo { x, y: x });
5+
| ^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| expected `usize`, found `&mut usize`
8+
| arguments to this function are incorrect
9+
|
10+
note: function defined here
11+
--> $RUST/core/src/ptr/mod.rs
12+
|
13+
| pub const unsafe fn write<T>(dst: *mut T, src: T) {
14+
| ^^^^^
15+
= note: this error originates in the macro `$crate::__init_internal` which comes from the expansion of the macro `init` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)