-
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 Deref<Target = [T]>
for [T; N]
, and fix const infer variable canonicalization (fix Deref<Target=[T; N]>
ICEs)
#92652
Conversation
// FIXME: this is a hack to allow us to evaluate `<[T; N]>::deref` as const, since | ||
// it's really just a pointer unsize from `&[T; N]` -> `&[T]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Deref
for[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