-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Stop emitting UbChecks on every Vec→Slice #150265
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,13 +13,14 @@ impl<T, U> const PartialEq<[U]> for [T] | |
| where | ||
| T: [const] PartialEq<U>, | ||
| { | ||
| // It's not worth trying to inline the loops underneath here *in MIR*, | ||
| // and preventing it encourages more useful inlining upstream, | ||
| // such as in `<str as PartialEq>::eq`. | ||
| // The codegen backend can still inline it later if needed. | ||
| #[rustc_no_mir_inline] | ||
|
Comment on lines
+16
to
+20
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the problem is the loop, why not put the attribute on the generic form that actually has a loop in it, instead of covering the entire entrypoint into the specialized-upon trait? |
||
| fn eq(&self, other: &[U]) -> bool { | ||
| SlicePartialEq::equal(self, other) | ||
| } | ||
|
|
||
| fn ne(&self, other: &[U]) -> bool { | ||
| SlicePartialEq::not_equal(self, other) | ||
| } | ||
| } | ||
|
|
||
| #[stable(feature = "rust1", since = "1.0.0")] | ||
|
|
@@ -99,10 +100,6 @@ impl<T: PartialOrd> PartialOrd for [T] { | |
| #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] | ||
| const trait SlicePartialEq<B> { | ||
| fn equal(&self, other: &[B]) -> bool; | ||
|
|
||
| fn not_equal(&self, other: &[B]) -> bool { | ||
| !self.equal(other) | ||
| } | ||
|
Comment on lines
-103
to
-105
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annot: nothing actually overrode this anywhere, so removed it in favour of the usual |
||
| } | ||
|
|
||
| // Generic slice equality | ||
|
|
||
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.
I wouldn't say "hot" here, I think some readers might take this comment to mean there is runtime overhead to UB checks.