Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Lifetime just does not work #270

Closed
wants to merge 2 commits into from
Closed

[WIP] Lifetime just does not work #270

wants to merge 2 commits into from

Conversation

tyb0807
Copy link
Collaborator

@tyb0807 tyb0807 commented Jan 3, 2025

Made quite some changes everywhere and it still doesn't compile

error[E0195]: lifetime parameters or bounds on method `search` do not match the trait declaration
   --> rs/index/src/ivf/index.rs:166:14
    |
166 |     fn search<'b>(
    |              ^^^^ lifetimes do not match method in trait
    |
   ::: rs/index/src/index.rs:6:14
    |
6   |     fn search<'b>(
    |              ---- lifetimes in impl do not match this method in trait

error[E0597]: `spann_reader` does not live long enough
  --> rs/index/src/collection/reader.rs:37:25
   |
33 |         let mut segments: Vec<Arc<BoxedSegmentSearchable>> = vec![];
   |                           -------------------------------- type annotation requires that `spann_reader` is borrowed for `'static`
...
36 |             let spann_reader = SpannReader::new(spann_path);
   |                 ------------ binding `spann_reader` declared here
37 |             let index = spann_reader.read()?;
   |                         ^^^^^^^^^^^^ borrowed value does not live long enough
38 |             segments.push(Arc::new(Box::new(ImmutableSegment::new(index))));
39 |         }
   |         - `spann_reader` dropped here while still borrowed

error[E0597]: `spann_reader` does not live long enough
   --> rs/index/src/collection/mod.rs:161:29
    |
159 |                 let spann_reader =
    |                     ------------ binding `spann_reader` declared here
160 |                     SpannReader::new(format!("{}/{}", self.base_directory, name_for_new_segment));
161 |                 let index = spann_reader.read()?;
    |                             ^^^^^^^^^^^^ borrowed value does not live long enough
162 |                 let segment: Arc<Box<dyn SegmentSearchable + Send + Sync>> =
163 |                     Arc::new(Box::new(ImmutableSegment::new(index)));
    |                              -------------------------------------- coercion requires that `spann_reader` is borrowed for `'static`
...
166 |             }
    |             - `spann_reader` dropped here while still borrowed
    |
    = note: due to object lifetime defaults, `Box<dyn SegmentSearchable + Send + Sync>` actually means `Box<(dyn SegmentSearchable + Send + Sync + 'static)>`
    ```

@tyb0807 tyb0807 closed this Jan 3, 2025
@tyb0807 tyb0807 deleted the tyb/lifetime branch January 3, 2025 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant