nuta / kerla

A new operating system kernel with Linux binary compatibility written in Rust.
Other
3.33k stars 89 forks source link

[Resolves #142] Add lifetimes to VAddr & PAddr #150

Open michalfita opened 2 years ago

michalfita commented 2 years ago

Description

An unfinished attempt to add lifetimes to VAddr & PAddr (as per #142).

@nuta I stuck with:

error[E0308]: mismatched types
   --> runtime/backtrace.rs:113:56
    |
113 |         Backtrace::current_frame().traverse(|_, vaddr: VAddr<'memory>| {
    |                                                        ^^^^^^^^^^^^^^ lifetime mismatch
    |
    = note: expected struct `address::VAddr<'_>`
               found struct `address::VAddr<'memory>`
note: the anonymous lifetime #1 defined here...
   --> runtime/backtrace.rs:113:45
    |
113 |           Backtrace::current_frame().traverse(|_, vaddr: VAddr<'memory>| {
    |  _____________________________________________^
114 | |             if let Some(symbol) = resolve_symbol(vaddr) {
115 | |                 let _ = trace.try_push(CapturedBacktraceFrame::<'memory> {
116 | |                     vaddr,
...   |
120 | |             }
121 | |         });
    | |_________^
note: ...does not necessarily outlive the lifetime `'memory` as defined here
   --> runtime/backtrace.rs:111:43
    |
111 |     pub fn capture() -> CapturedBacktrace<'memory> {
    |                                           ^^^^^^^

I'm not the expert of lifetimes, but I read this a problem with the lifetime of the closure as argument of traverse(). Any suggestions welcome.

Pre-Submission Checklist

When you submit a PR, please make sure your PR satisfies the following checklist:

nuta commented 2 years ago

I'm not the expert of lifetimes, but I read this a problem with the lifetime of the closure as argument of traverse(). Any suggestions welcome.

I haven't tested locally but how about deleting : VAddr<'_>? Doesn't rustc infer it?