If you return a non-'static reference, it must have been created from something you passed in (or you can return that reference alongside moving the newly created object it's derived from, but that's a different use case of returning two different things and doesn't apply here)
Unless &Task is owned by id or conn, the code you have here breaks that rule.
When you think about it, it makes sense from looking at what you have here... &Task is derived from all_tasks, but all_tasks is dropped when the function ends thereby invalidating the reference.
Here's a few options to consider:
Return Task not &Task. You may need to clone()
Return &'static Task if all_tasks is 'static
Refactor to use the &Task without returning it, within the scope of that function, i.e. instead of get() you could have map() and pass in a closure or other function, something like:
let foo = map(42, &conn, |task| {
// somehow get a String or whatever from the &Task
});
//foo is Option<String> or whatever the closure returned
println!("{:?}", foo)