]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-102209.rs
Move /src/test to /tests
[rust.git] / tests / ui / borrowck / issue-102209.rs
1 use std::marker::PhantomData;
2
3 pub struct NfaBuilder<'brand> {
4     brand: PhantomData<&'brand mut &'brand mut ()>,
5 }
6
7 impl NfaBuilder<'_> {
8     pub fn with<R, F: FnOnce(NfaBuilder<'_>) -> R>(f: F) -> R {
9         Brand::with(|brand| {
10             f(Self { brand: brand.lt })
11             //~^ ERROR lifetime may not live long enough
12             //~| ERROR lifetime may not live long enough
13         })
14     }
15 }
16
17 #[derive(Clone, Copy)]
18 pub struct Brand<'brand> {
19     lt: PhantomData<&'brand mut &'brand mut ()>,
20 }
21
22 impl Brand<'_> {
23     pub fn with<R, F: FnOnce(Brand<'_>) -> R>(f: F) -> R {
24         f(Self { lt: PhantomData })
25     }
26 }
27
28 fn main() {}