Why do you think they should have the same lifetime? What guarantees that the owner of the str you receive (which could come from anywhere) is going to be the same scope that takes ownership of the Box that you're returning?
This is a slight oversimplification. When you have a fn that takes a &'a dyn Debug, then it actually desugars to &'a (dyn Debug + 'a). This is a rather specific exception, and in most cases the omitted lifetime is inferred to 'static. âŠī¸