| 1 |
// Copyright 2025 The Fuchsia Authors |
| 2 |
// |
| 3 |
// Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| 4 |
// https://opensource.org/license/bsd-2-clause>, Apache License, Version 2.0 |
| 5 |
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT |
| 6 |
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. |
| 7 |
// This file may not be copied, modified, or distributed except according to |
| 8 |
// those terms. |
| 9 |
|
| 10 |
include!("../include.rs"); |
| 11 |
|
| 12 |
use zerocopy::pointer::{ |
| 13 |
invariant::{Aligned, Exclusive, Shared, Valid}, |
| 14 |
Ptr, |
| 15 |
}; |
| 16 |
|
| 17 |
fn _when_exclusive<'big: 'small, 'small>( |
| 18 |
big: Ptr<'small, &'big u32, (Exclusive, Aligned, Valid)>, |
| 19 |
mut _small: Ptr<'small, &'small u32, (Exclusive, Aligned, Valid)>, |
| 20 |
) { |
| 21 |
_small = big; |
| 22 |
//~[msrv]^ ERROR: lifetime mismatch |
| 23 |
//~[stable, nightly]^^ ERROR: lifetime may not live long enough |
| 24 |
} |
| 25 |
|
| 26 |
fn _when_shared<'big: 'small, 'small>( |
| 27 |
big: Ptr<'small, &'big u32, (Shared, Aligned, Valid)>, |
| 28 |
mut _small: Ptr<'small, &'small u32, (Shared, Aligned, Valid)>, |
| 29 |
) { |
| 30 |
_small = big; |
| 31 |
//~[msrv]^ ERROR: lifetime mismatch |
| 32 |
//~[stable, nightly]^^ ERROR: lifetime may not live long enough |
| 33 |
} |
| 34 |
|
| 35 |
fn main() {} |