diff options
| author | Andrew Xie <ndrew.xie@gmail.com> | 2023-04-12 18:03:11 -0400 |
|---|---|---|
| committer | Andrew Xie <ndrew.xie@gmail.com> | 2023-04-12 18:03:11 -0400 |
| commit | 9e0e4c31aa88e5d510fdd0742808ec95329470e4 (patch) | |
| tree | 253ec7eb6a766ba20932f59b3f21d34003189939 /tests/ui/suggestions/suggest-pin-macro.rs | |
| parent | 59a05ad118a5d85dd8998babbe5bcd3163303a43 (diff) | |
| download | rust-9e0e4c31aa88e5d510fdd0742808ec95329470e4.tar.gz rust-9e0e4c31aa88e5d510fdd0742808ec95329470e4.zip | |
Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented
Diffstat (limited to 'tests/ui/suggestions/suggest-pin-macro.rs')
| -rw-r--r-- | tests/ui/suggestions/suggest-pin-macro.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/suggestions/suggest-pin-macro.rs b/tests/ui/suggestions/suggest-pin-macro.rs new file mode 100644 index 00000000000..f5b96215925 --- /dev/null +++ b/tests/ui/suggestions/suggest-pin-macro.rs @@ -0,0 +1,23 @@ +use std::pin::Pin; +use std::marker::PhantomPinned; + +#[derive(Debug)] +struct Test { + _marker: PhantomPinned, +} +impl Test { + fn new() -> Self { + Test { + _marker: PhantomPinned, // This makes our type `!Unpin` + } + } +} + +fn dummy(_: &mut Test) {} + +pub fn main() { + let mut test1 = Test::new(); + let mut test1 = unsafe { Pin::new_unchecked(&mut test1) }; + + dummy(test1.get_mut()); //~ ERROR E0277 +} |
