Skip to content

unresolved lifetime #4885

Description

@philberty

Summary

test.rs:12:29: error: unresolved lifetime
   12 |     type Searcher: Searcher<'a>;
      |                             ^~

Reproducer

I tried this code:

#![feature(no_core, lang_items)]
#![no_core]

#[lang = "sized"]
pub trait Sized {}

pub unsafe trait Searcher<'a> {
    fn haystack(&self) -> &'a ();
}

pub trait Pattern<'a>: Sized {
    type Searcher: Searcher<'a>;
}

pub trait MultiCharEq {}

struct MultiCharEqPattern<C: MultiCharEq>(C);

struct MultiCharEqSearcher<'a, C: MultiCharEq> {
    marker: &'a (),
    c: C,
}

impl<'a, C: MultiCharEq> Pattern<'a> for MultiCharEqPattern<C> {
    type Searcher = MultiCharEqSearcher<'a, C>;
}

unsafe impl<'a, C: MultiCharEq> Searcher<'a> for MultiCharEqSearcher<'a, C> {
    fn haystack(&self) -> &'a () {
        self.marker
    }
}

impl<'x> MultiCharEq for &'x [i32] {}

pub struct CharSliceSearcher<'a, 'b>(<MultiCharEqPattern<&'b [i32]> as Pattern<'a>>::Searcher);

fn main() -> i32 {
    0
}

Does the code make use of any (1.49) nightly feature ?

  • Nightly

Godbolt link

No response

Actual behavior

The current behavior is...

Expected behavior

I expected to see...

GCC Version

HEAD

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreIssue related to the compilation of the `core` crate

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions