Skip to content

region inference doesn't capture all dependencies between regions #3148

Closed
@nikomatsakis

Description

@nikomatsakis

In this test case (src/test/run-pass/region-return-interior-of-option-in-self.rs):

// xfail-test 

struct cell<T> {
    value: T;
}

struct cells<T> {
    vals: ~[option<cell<T>>];
}

impl<T> &cells<T> {
    fn get(idx: uint) -> &self/T {
        match self.vals[idx] {
          some(ref v) => &v.value,
          none => fail
        }
    }
}

fn main() {}

an error is reported. The reason is that the region R for v is inferred to be too narrow, because it doesn't realize R must be as wide as the region for &v.value.

Metadata

Metadata

Assignees

Labels

A-lifetimesArea: Lifetimes / regions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions