Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC: DynSized without ?DynSized — Lint against use of `extern type` in `size_of_val`, and more #2310
Conversation
kennytm
referenced this pull request
Jan 25, 2018
Closed
Add DynSized trait (rebase of #44469) #46108
This comment has been minimized.
This comment has been minimized.
|
Tell me if I'm going crazy here, but given that...
and
the RFC's final alternative of a "post-monomorphization error" actually seems like a strong contender to me (I mean in addition to the proposed trait and/or lints, not instead of), since it seems to be the only way to make foreign types actually typesafe. Or is the proposed lint expected to be exhaustive/"actually typesafe", and the distinction between a lint and a post-monomorphization error merely academic here? |
eddyb
reviewed
Jan 25, 2018
| compile-time error and only affects the rare cases where foreign type is actually misused. | ||
|
|
||
| Rust currently has no post-monomorphization lints or type errors (except [E0511] or recursion | ||
| overflow). Introducing such errors marks a serious departure of this policy. |
This comment has been minimized.
This comment has been minimized.
eddyb
Jan 25, 2018
Member
Please don't refer to errors by error codes, or the error message, but rather for the semantic reason for the error.
Also note that other than resource limits, all the post-monomorphization errors come from unstable features (mostly inline assembly and platform intrinsics, both of which shouldn't have stabilized forms that don't move the errors to earlier checks).
withoutboats
added
the
T-lang
label
Jan 25, 2018
This comment has been minimized.
This comment has been minimized.
mikeyhew
commented
Jan 26, 2018
|
@kennytm, I have to say this RFC is really well written and researched. This kind of writing is painful for me, and when I write my first RFC, it's definitely going to be a lot shorter. I haven't fully read everything yet, so I'll probably add more comments later. It looks like your proposal is, basically, to still add the It seems rather complicated, but then again, most of the potential solutions, except maybe C++-style post-monomorphization errors, are fairly complicated. In RFC 1861 (extern types), @canndrew writes in the Drawbacks section:
Perhaps we should ask him what sort of implementation he had in mind |
This comment has been minimized.
This comment has been minimized.
|
@mikeyhew Thanks :) This proposal will add This RFC is complicated since we want to avoid default bound, i.e. This proposal does not make failing to fulfill The problem is that, as Thus we cheat by introducing Due to how epoch works, we could turn the lint into an error in the next epoch (2018). But the current epoch (2015) must still be supported, thus the |
This comment has been minimized.
This comment has been minimized.
mystor
commented
Jan 26, 2018
•
|
I'm not a big fan of the need to keep that hack around forever, but the rest of the system seems good to me. I didn't like the need for the My understanding is that we are not adding post-monomorphization errors, correct? Rather we're emitting a warning for almost all callers of |
This comment has been minimized.
This comment has been minimized.
|
@mystor Yeah, |
This comment has been minimized.
This comment has been minimized.
However, this also means that other libraries have no choice but do an API-breaking update by the time the lint becomes a hard error as they cannot benefit from this libstd-only hack, right? |
This comment has been minimized.
This comment has been minimized.
|
@RalfJung Yes, but it requires a new epoch. You could still stay in the 2015 epoch if a hard error is not wanted, but that's basically lying to yourself that "my code still works". From what I checked there isn't really a lot of public interfaces expecting DynSized, so hopefully not too many packages need to update the major version. |
kennytm
referenced this pull request
Mar 28, 2018
Open
Tracking issue for RFC 1861: Extern types #43467
kennytm
referenced this pull request
Apr 5, 2018
Open
`extern type` cannot support `size_of_val` and `align_of_val` #49708
This comment has been minimized.
This comment has been minimized.
comex
commented
Apr 11, 2018
•
|
Now that I've actually read this RFC properly... I don't think It falls out of specialization that we can write: trait HopefullyDynSized {}
impl<T: ?Sized> HopefullyDynSized for T {}
impl<T: ?Sized + DynSized> HopefullyDynSized for T {}Now, what if we mark the first impl as deprecated? #[deprecated(note = "how about adding a DynSized bound, dummy")]
impl<T: ?Sized> HopefullyDynSized for T {}Currently… it compiles but has no effect: the compiler doesn't seem to produce a lint in any scenario, even if the impl is used with fully concrete Relevant bug report: #39935: But ideally, rustc could lint whenever trait resolution chooses that impl during the type checking stage (as opposed to trans/monomorphization). This wouldn't require any special extra queries, 'just' linting based on something it already knows. That said, the implementation might be nontrivial: AFAICT, trait resolution currently has no lints at all, and I'm not sure whether it keeps track of which span(s) are responsible for a trait obligation, which it'd need in order to know where to attach the lint… But that's clearly a solvable problem. Then, instead of |
This comment has been minimized.
This comment has been minimized.
|
@comex Interesting. As you mentioned, this relies on rust-lang/rust#39935, which is also what forces us to insta-stable all new |
This comment has been minimized.
This comment has been minimized.
stevenblenkinsop
commented
Apr 16, 2018
•
|
One thing this RFC does is double down on the idea that anything with a known size can be moved, since as long as something is |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp postpone I am going to move to postpone this RFC. At present, there is only one kind of type for which this is relevant (extern types) and even more specifically one set of functions ( This doesn't however foreclose adding a |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 26, 2018
•
|
Team member @nikomatsakis has proposed to postpone this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
the
proposed-final-comment-period
label
Apr 26, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
May 24, 2018
|
|
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
May 24, 2018
Centril
added
the
disposition-postpone
label
May 24, 2018
rfcbot
added
the
finished-final-comment-period
label
Jun 3, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jun 3, 2018
|
The final comment period, with a disposition to postpone, as per the review above, is now complete. By the power vested in me by Rust, I hereby postpone this RFC. |
kennytm commentedJan 25, 2018
Rendered
cc #2255
cc @mikeyhew, @mystor (#1993), @withoutboats