rust/library/core/src
bors 816f958ac3 Auto merge of #108157 - scottmcm:tuple-gt-via-partialcmp, r=dtolnay
Use `partial_cmp` to implement tuple `lt`/`le`/`ge`/`gt`

In today's implementation, `(A, B)::gt` contains calls to *both* `A::eq` *and* `A::gt`.

That's fine for primitives, but for things like `String`s it's kinda weird -- `(String, usize)::gt` has a call to both `bcmp` and `memcmp` (<https://rust.godbolt.org/z/7jbbPMesf>) because when `bcmp` says the `String`s aren't equal, it turns around and calls `memcmp` to find out which one's bigger.

This PR changes the implementation to instead implement `(A, …, C, Z)::gt` using `A::partial_cmp`, `…::partial_cmp`, `C::partial_cmp`, and `Z::gt`.  (And analogously for `lt`, `le`, and `ge`.)  That way expensive comparisons don't need to be repeated.

Technically this is an observable change on stable, so I've marked it `needs-fcp` + `T-libs-api` and will
r? rust-lang/libs-api

I'm hoping that this will be non-controversial, however, since it's very similar to the observable changes that were made to the derives (#81384 #98655) -- like those, this only changes behaviour if a type overrode behaviour in a way inconsistent with the rules for the various traits involved.

(The first commit here is #108156, adding the codegen test, which I used to make sure this doesn't regress behaviour for primitives.)

Zulip conversation about this change: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60.3E.60.20on.20Tuples/near/328392927>.
2023-03-05 22:02:26 +00:00
..
alloc Clarify new_size for realloc means bytes 2023-02-09 23:56:20 -08:00
array Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
async_iter use consistent terminology 2022-10-29 09:23:12 +02:00
cell Add OnceCell<T>: !Sync impl for diagnostics 2023-01-19 20:14:21 +01:00
char Auto merge of #105671 - lukas-code:depreciate-char, r=scottmcm 2023-02-12 11:09:06 +00:00
cmp Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
convert Remove from_fn lang item 2023-02-26 09:15:54 +00:00
ffi Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubilee 2023-03-02 02:41:42 +00:00
fmt Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk 2023-01-26 12:44:47 +00:00
future Remove GenFuture from core 2023-01-29 15:20:03 +01:00
hash Fix some ~const usage in libcore 2022-12-20 15:01:37 +00:00
intrinsics Match unmatched backticks in library/ 2023-03-03 03:03:29 +01:00
iter Rollup merge of #107890 - obeis:mapping-to-unit, r=cjgillot 2023-02-26 00:46:25 +01:00
macros Remove HTML tags around warning 2023-01-06 13:20:58 +01:00
mem stage-step cfgs 2023-01-30 13:09:09 -05:00
net Add tracking issue 2023-02-26 13:50:10 +01:00
num Require literals for some (u)int_impl! parameters 2023-02-22 23:26:22 -08:00
ops Constify RangeBounds, RangeX::contains and RangeX::is_empty. 2023-02-15 15:50:54 +01:00
panic Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
prelude Replace libstd, libcore, liballoc in docs. 2022-12-30 14:00:40 +01:00
ptr Match unmatched backticks in library/ 2023-03-03 03:03:29 +01:00
slice Auto merge of #105117 - pitaj:debug_asserts, r=the8472 2023-03-05 19:35:44 +00:00
str Auto merge of #105117 - pitaj:debug_asserts, r=the8472 2023-03-05 19:35:44 +00:00
sync Fill-in tracking issue for feature("atomic_from_ptr") 2023-03-02 12:00:26 +00:00
task Inline Poll methods 2023-02-13 14:17:45 +08:00
unicode Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
any.rs Match unmatched backticks in library/ 2023-03-03 03:03:29 +01:00
arch.rs move core::arch into separate file 2022-11-20 10:28:14 +01:00
ascii.rs Inline <EscapeDefault as Iterator>::next 2022-03-10 15:35:22 +01:00
asserting.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
bool.rs Add missing assertion 2022-09-22 02:12:06 -04:00
borrow.rs Minor grammar nit. 2022-12-12 16:22:01 -07:00
cell.rs Match unmatched backticks in library/ 2023-03-03 03:03:29 +01:00
clone.rs Make some trivial functions #[inline(always)] 2022-12-07 17:11:17 +01:00
cmp.rs Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
default.rs cfg-step code 2022-11-06 17:21:21 -05:00
error.md Small round of typo fixes 2022-11-04 20:06:18 -07:00
error.rs Remove a couple of #[doc(hidden)] pub fn and their #[feature] gates 2023-02-10 08:06:35 +01:00
hint.rs clarify correctness of black_box 2023-02-15 16:22:08 +00:00
internal_macros.rs ignore a doctest for the non-exported macro 2022-05-03 18:33:56 +09:00
intrinsics.rs Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
lib.rs Revert "Stabilize #![feature(target_feature_11)]" 2023-03-02 13:41:17 +01:00
marker.rs add a #[rustc_coinductive] attribute 2023-02-14 11:53:22 +01:00
option.rs Add Option::as_slice(_mut) 2023-03-01 00:05:31 +01:00
panic.rs Replace libstd, libcore, liballoc in docs. 2022-12-30 14:00:40 +01:00
panicking.rs stage-step cfgs 2023-01-30 13:09:09 -05:00
pin.rs Set version placeholders to 1.68 2023-01-25 09:44:29 -05:00
primitive.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
primitive_docs.rs Clarify that Copy is a trait in array docs 2023-02-27 15:16:39 +00:00
result.rs "Basic usage" is redundant for there is just one example 2023-02-16 19:49:31 +02:00
time.rs Bump version placeholders to release 2022-11-06 17:11:02 -05:00
tuple.rs Use partial_cmp to implement tuple lt/le/ge/gt 2023-02-16 23:59:13 -08:00
unit.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00