-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement revised coercion rules #18469
Comments
Nominating: this contains backwards-incompatible changes. For triage purposes, we probably want to pull out the DST coercions part of this as P-High. |
Summary of changes to make from the RFC:
We should double check that these changes actually get us to the right destination as defined by the RFC. I filed bugs for the larger pieces of work, the rest are pretty minor and can be tracked here. Those marked with an asterisk are backwards incompatible. |
Assigning myself for misc back-compat parts of this, I don't intend to do the rest right now. |
Assigning P-backcompat-lang, 1.0. |
Part of rust-lang#18469 [breaking-change] A receiver will only ever get a single auto-reference. Previously arrays and strings would get two, e.g., [T] would be auto-ref'ed to &&[T]. This is usually apparent when a trait is implemented for `&[T]` and has a method takes self by reference. The usual solution is to implement the trait for `[T]` (the DST form).
Part of #18469 [breaking-change] A receiver will only ever get a single auto-reference. Previously arrays and strings would get two, e.g., [T] would be auto-ref'ed to &&[T]. This is usually apparent when a trait is implemented for `&[T]` and has a method takes self by reference. The usual solution is to implement the trait for `[T]` (the DST form). r? @nikomatsakis (or anyone else, really)
@nick29581 Are the back-compat parts done? If so, let's re-nominate. |
Yep, should no longer block |
No more back incompat stuff; just usability issues. P-high. |
Triage: ancient RFC tracking bug slipping through the cracks cc @rust-lang/lang what's up? |
Discussed at the lang meeting. I will go through the checklist to make sure it is up to date. We think it should remain p-medium since periodic check ins will be worthwhile. |
Looking through rust-lang/rfcs#401, #37685, #32702, #34451, and this, it seems that tuple DSTs and their coercion should be allowed but the coercion is not implemented. Am I right? |
@qnighy I think that is correct. I'm not sure just how much implementation work would be needed, there may be random bits of the compiler that need to be updated scattered around. |
@nikomatsakis Thank you. I'm working on it. |
Another question: |
@qnighy not that I'm aware of; I don't think we necessarily need an RFC for such a thing though |
Unsized tuple coercions Part of #18469. Fixes #32702. #37685 and #34451 might also be related. This PR does the following: - Introduce explicit `Sized` constraints on tuple initializers, similar to that of record-struct initializers. Not much relevant to the main contribution but I noticed this when making tests for unsized tuple coercions. - Implement `(.., T): Unsize<(.., U)>` where `T: Unsize<U>`. - Assume `(.., T)` is MaybeUnsizedUnivariant. - Modify `src/librustc/ty/util.rs` and `src/librustc_trans/glue.rs` so that tuples and structs are uniformly traversed when translating.
Implement Eq/Hash/Debug etc. for unsized tuples. As I mentioned in [the comment in rust-lang#18469](rust-lang#18469 (comment)), the implementations of `PartialEq`, `Eq`, `PartialOrd`, `Ord`, `Debug`, `Hash` can be generalized to unsized tuples. This is consistent with the `derive` behavior for unsized structs. ```rust #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)] struct MyTuple<X, Y, Z: ?Sized>(X, Y, Z); fn f(x: &MyTuple<i32, i32, [i32]>) { x == x; x < x; println!("{:?}", x); } ``` Questions: - Need an RFC? - Need a feature gate? I don't think it does because the unsized tuple coercion rust-lang#42527 is feature-gated. - I changed `builder.field($name);` into `builder.field(&$name);` in the `Debug` implementation to pass compilation. This won't affect the behavior because `Debug for &'a T` is a mere redirection to `Debug for T`. However, I don't know if it affects code size / performance.
Can I use any workaround until this is resolved? I have a custom type that I want to convert from |
cc @rust-lang/lang Do we want to close this and all the unfinished sub-issues, and require a new RFC for any new features in this area, even if the old RFC covers them? |
@eddyb What exactly remains to be done here; could you clarify the unfinished sub-issues? |
@Centril I'm just referring to this comment #18469 (comment) and the unchecked checkboxes in it. |
Closing this issue -- anything from RFC 401 that isn't already implemented probably requires a fresh RFC by now, or should at least have its own issue. |
feat: Show `static` values on hover
Tracking issue for RFC 401.
The text was updated successfully, but these errors were encountered: