Implement Deref<Target = [T]> for [T; N], and fix const infer variable canonicalization (fix Deref<Target=[T; N]> ICEs)#92652
Conversation
There was a problem hiding this comment.
This is the only part of the PR I am somewhat unhappy with, but it works.
This comment has been minimized.
This comment has been minimized.
Deref<Target=[T; N]> on newtypes (attempt 2)Deref<Target = [T]> for [T; N], and fix const infer variable canonicalization (fix Deref<Target=[T; N]> ICEs)
5205639 to
595657d
Compare
|
Trait impls are insta-stable and I strongly disagree with a (click to expand my reasons - they're not really relevant outside of a FCP/RFC discussion)The reason deref impls like Array unsizing (to slice) is in a different coercion category than deref coercions, and more flexible at that (e.g. Something this significant requires at least an FCP by @rust-lang/lang, if not an RFC. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
I misunderstood what exactly is happening here and after @eddyb's comment i am now also not in favor of will review #92640 and am in favor of only going forward with |
|
I agree with @eddyb that a Deref impl for |
|
Alright, I'll close this out then |
Stash a const infer's type into the canonical var during canonicalization, so we can recreate the fresh const infer with that same type.
For example, given
[T; _]we know_is ausize. If we go from infer => canonical => infer, we shouldn't forget that variable is a usize.Fixes Inferring const parameters to wrapper type causes rustc to panic. #92626
Fixes ICE on Rust 1.51 with min const generics and Deref<Target=[T; N]> #83704
Implement
Dereffor[T; N]which allows us to remove some custom array unsizing logic that was leaking an inference variable during method selection.Fixes Calling slice method on newtype wrapper that implements
Deref<Target=[_; 1]>causes ICE #92637r? @lcnr