-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Start using pattern types in libcore #136006
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
e3e2cbd
to
ff4d569
Compare
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.
Well r=me when/if it does get unblocked.
This comment has been minimized.
This comment has been minimized.
#[repr(transparent)] | ||
$(#[$m])* | ||
#[cfg(not(bootstrap))] | ||
$vis struct $name(pattern_type!($int is $low..=$high)); |
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.
Unsure: at least for the NonZeroBlahInner
ones, it'd be nicer if these could just be type $name = pattern_type!($int is $low..=$high);
, without the extra wrapper. Is that feasible, or are the trait implementations too far off?
(Relatedly, I'd love to be able to just derive traits on these again, particularly to not have to manually StructuralPartialEq
.)
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.
Yea... I wanna get there, but directly using pattern types is not a great experience at present
ff4d569
to
0409353
Compare
This comment has been minimized.
This comment has been minimized.
0409353
to
4db40b9
Compare
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Re rust-analyzer blocker, as it turns out to implement pattern types (to a degree that would unblock this) it comes down to the same architecture changes required as for rust-lang/rust-analyzer#7434 (which I am currently looking into), so that will take a bit. |
This comment has been minimized.
This comment has been minimized.
4db40b9
to
0afd16b
Compare
This comment has been minimized.
This comment has been minimized.
0afd16b
to
ed90eb8
Compare
This comment has been minimized.
This comment has been minimized.
ed90eb8
to
9514a86
Compare
This comment has been minimized.
This comment has been minimized.
9514a86
to
9774687
Compare
This comment has been minimized.
This comment has been minimized.
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
This comment has been minimized.
This comment has been minimized.
@@ -763,6 +763,9 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> { | |||
} | |||
interp_ok(true) | |||
} | |||
ty::Pat(base_ty, ..) => self.try_visit_primitive( | |||
&value.transmute(self.ecx().layout_of(*base_ty)?, self.ecx())?, |
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.
Primitive types basically by definition do not have fields, so having recursion here is very odd. This should probably be handled elsewhere.
Does the pattern not affect validity?
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.
it does, and validity checking is still handling it accidentally because all use cases have the pattern type wrapped in a struct 🤦
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.
gonna pull this all out into a separate PR with separate tests
b73b224
to
c62873e
Compare
This comment has been minimized.
This comment has been minimized.
c62873e
to
90fc7a4
Compare
This comment has been minimized.
This comment has been minimized.
90fc7a4
to
68c596f
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
cc #135996
blocked on rust-analyzer getting support for computing the right layout for pattern types
cc @Veykril no rush here, as long as we can't replace
NonNull
, there's no point in doing this change just yet