'Rust code of lifetime constrains not work?

fn do_sth<'a, 'b, 'c>(arg1: &'a i32, arg2: &'b i32) -> &'c i32
where
    'a: 'b,
    'b: 'c,
{
    arg2
}


fn do_sth2<'a, 'b>(arg1: &'a i32, arg2: &'b i32) -> i32
where
    'a: 'b    
{
    10
}


fn main() {
    let mario = 1;
    let ref1 = &mario;
    {
        let luigi = 2;
        let ref2 = &luigi;
        {
            let peach = do_sth(&ref2, &ref1);
            let test = do_sth2(&ref2, &ref1);
        }
    }
}

For function do_sth, lifetime parameter 'a should longer than lifetime parameter 'b( where 'a: 'b,), my question is why the compiler allow statement below

let peach = do_sth(&ref2, &ref1) 

to compile ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source