Skip to content

subst of region var for region param not happening on iface  #3010

Closed
@nikomatsakis

Description

@nikomatsakis

Compiling this code gives you an error message, but not the right one. I get

reference is not valid outside of its lifetime, &self

which suggests that some substitution is not occuring, as I would expect &self to be replaced with the free & region defined in the callback. Maybe the same bug as @catamorphism diagnosed regarding the replacement of ty params with tyvars in the vtable code.

iface deref {
    fn get() -> int;
}

impl of deref for &int {
    fn get() -> int {
        *self
    }
}

fn with<R: deref>(f: fn(x: &int) -> R) -> int {
    f(&3).get()
}

fn return_it() -> int {
    with(|o| o)
}

fn main() {
    let x = return_it();
    #debug["foo=%d", x];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions