I noticed that I apparently cannot upcast from e.g &dyn T + Send to &dyn T. This seems to make it impossible to use dyn T receiver functions for objects of type dyn T + Send.
I understand why this doesn't work from a type theoretic standpoint; My question is: What's the underlying reason that Rust was designed this way? Intuitively, it seems to me that types implementing Send are a subset of all types, and so any object implementing Send sholuld also be usable "as a non-Send object". Is that reasoning wrong? Why does Rust dissalow this?
Here's an example where this might become a problem:
If a function was written as taking an &dyn T, it is (apparently) impossible to pass any object that was at some point marked with Send: &dyn T + Send is an invalid expression; taking &Box<dyn T + Send> isn't exactly clear code (as it apparenly is only needed to satisfy Rust's type system), and further requires allocation on the heap, which might be undesirable.
Coercion to a dyn is a type of unsize coercion which can only take place behind a single layer of indirection -- Box<T> or &T, but not multiple layers like Box<&T>. That includes coercion from one dyn to another.
There is no deep reason, it's just something which wasn't implemented so far EDIT: actually it was, as several people noted. There is a recently accepted RFC for trait object upcasting, which would cover this case.
Note that you can always use unsafe casts if you really need to erase Send bound on current Rust:
Of course, it's unsafe and not ergonomic: this function needs to be written separately for every trait and set of autotraits (Send, Sync, Unpin), but at least you're not blocked.
Upcasting to remove auto-traits is already part of the (safe) language.
Allowing such upcasting in places where unsizing coercion can not apply more generally (ala subtyping) seems like a possible enhancement to me (since AFAIK an auto-trait won't influence a vtable), but isn't part of RFC 3324.