Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

ices/102209.rs: fixed with errors #1435

Merged
merged 1 commit into from
Oct 2, 2022
Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 2, 2022

Issue: rust-lang/rust#102209

use std::marker::PhantomData;

pub struct NfaBuilder<'brand> {
    brand: PhantomData<&'brand mut &'brand mut ()>,
}

impl NfaBuilder<'_> {
    pub fn with<R, F: FnOnce(NfaBuilder<'_>) -> R>(f: F) -> R {
        Brand::with(|brand| {
            // This should be using NfaBuilder instead of Self becuase they have diffrent lifetime constraints
            f(Self {
                brand: brand.lt,
            })
        })
    }
}

#[derive(Clone, Copy)]
pub struct Brand<'brand> {
    lt: PhantomData<&'brand mut &'brand mut ()>,
}

impl Brand<'_> {
    pub fn with<R, F: FnOnce(Brand<'_>) -> R>(f: F) -> R {
        f(Self { lt: PhantomData })
    }
}

pub fn main() {}
=== stdout ===
=== stderr ===
error: lifetime may not live long enough
  --> /home/runner/work/glacier/glacier/ices/102209.rs:12:24
   |
7  | impl NfaBuilder<'_> {
   |                 -- lifetime `'2` appears in the `impl`'s self type
8  |     pub fn with<R, F: FnOnce(NfaBuilder<'_>) -> R>(f: F) -> R {
9  |         Brand::with(|brand| {
   |                      ----- has type `Brand<'1>`
...
12 |                 brand: brand.lt,
   |                        ^^^^^^^^ this usage requires that `'1` must outlive `'2`

error: lifetime may not live long enough
  --> /home/runner/work/glacier/glacier/ices/102209.rs:12:24
   |
7  | impl NfaBuilder<'_> {
   |                 -- lifetime `'1` appears in the `impl`'s self type
...
12 |                 brand: brand.lt,
   |                        ^^^^^^^^ this usage requires that `'1` must outlive `'static`

error: aborting due to 2 previous errors

==============

=== stdout ===
=== stderr ===
error: lifetime may not live long enough
  --> /home/runner/work/glacier/glacier/ices/102209.rs:12:24
   |
7  | impl NfaBuilder<'_> {
   |                 -- lifetime `'2` appears in the `impl`'s self type
8  |     pub fn with<R, F: FnOnce(NfaBuilder<'_>) -> R>(f: F) -> R {
9  |         Brand::with(|brand| {
   |                      ----- has type `Brand<'1>`
...
12 |                 brand: brand.lt,
   |                        ^^^^^^^^ this usage requires that `'1` must outlive `'2`

error: lifetime may not live long enough
  --> /home/runner/work/glacier/glacier/ices/102209.rs:12:24
   |
7  | impl NfaBuilder<'_> {
   |                 -- lifetime `'1` appears in the `impl`'s self type
...
12 |                 brand: brand.lt,
   |                        ^^^^^^^^ this usage requires that `'1` must outlive `'static`

error: aborting due to 2 previous errors

==============
@JohnTitor JohnTitor merged commit 0708d10 into master Oct 2, 2022
@JohnTitor JohnTitor deleted the autofix/ices/102209.rs branch October 2, 2022 22:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants