Object safety check fixes#18527
Conversation
This also fixes #18490 as a side-effect by avoiding a later out-of-bounds slice.
|
Part of the motivation for the object safety change was that if (That said, static methods weren't discussed when making the decision, and seem to be a significant downside to this change, so we may need to reconsider the whole thing.) |
|
That's a good point. The current behavior permits static methods as long as they follow the other rules (e.g. not referring to Self), so I erred on the side of permissivity. Should I tweak the patch to just avoid the panic and maintain the status quo otherwise? |
|
@aturon to be precise with the static method issue, is this the situation you worry about: Where the monomorphised version of |
|
@nick29581 Yes, that's one example. More generally, there have been a lot of complaints about the new object safety rules not allowing you to have constructors-like methods (that produce Unlike other examples we've seen, where splitting the trait made things more flexible, this seems to unequivocally make the API worse. Some real-life examples where the splitting up is having to occur: https://github.com/hyperium/hyper/blob/master/src/header/mod.rs#L26-L43 |
|
@bkoropoff Yeah, I think taking a patch like this is the thing to do for now - given that we don't use object safety for the auto-impl stuff, this seems like the right fix (and brings us as close as possible to the old situation of per-method object safety). We do need to think about object safety in general though, it seems like all static methods object-unsafe once we do the auto-impls. |
|
I opened rust-lang/rfcs#428 to discuss the proper fix for the object-safety/static method issue. |
Closes #18490
r? @nick29581