Weird compiler behavior when implementing trait


#1

Why does compiler allow me to define function fn print<P: Tr> (...); in some trait and then implement that trait as follows: fn print<P: Tr + 'static> (...) {}?

I thought Tr + 'static where Tr is some other trait is stronger requirement for a type than just Tr. So why does it happen?


#2

Playground URL: https://play.rust-lang.org/?gist=34921a37e957f625ab16e326a0d26a12&version=stable&backtrace=2

use std::fmt::Display;

trait Printer {
    fn print<P: Display>(&self, printable: P);
}

struct TestObj;

impl Printer for TestObj {
    fn print<P: Display + 'static>(&self, printable: P) {}
}

fn main() {}

#3

this can cause a use after free in safe code, seems to be a bug