summary refs log tree commit diff
path: root/src/libcore/cmp.rs
AgeCommit message (Collapse)AuthorLines
2019-10-25Migrate from `#[structural_match]` attribute a lang-item trait.Felix S. Klock II-2/+2
(Or more precisely, a pair of such traits: one for `derive(PartialEq)` and one for `derive(Eq)`.) ((The addition of the second marker trait, `StructuralEq`, is largely a hack to work-around `fn (&T)` not implementing `PartialEq` and `Eq`; see also issue rust-lang/rust#46989; otherwise I would just check if `Eq` is implemented.)) Note: this does not use trait fulfillment error-reporting machinery; it just uses the trait system to determine if the ADT was tagged or not. (Nonetheless, I have kept an `on_unimplemented` message on the new trait for structural_match check, even though it is currently not used.) Note also: this does *not* resolve the ICE from rust-lang/rust#65466, as noted in a comment added in this commit. Further work is necessary to resolve that and other problems with the structural match checking, especially to do so without breaking stable code (adapted from test fn-ptr-is-structurally-matchable.rs): ```rust fn r_sm_to(_: &SM) {} fn main() { const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to); let input: Wrap<fn(&SM)> = Wrap(r_sm_to); match Wrap(input) { Wrap(CFN6) => {} Wrap(_) => {} }; } ``` where we would hit a problem with the strategy of unconditionally checking for `PartialEq` because the type `for <'a> fn(&'a SM)` does not currently even *implement* `PartialEq`. ---- added review feedback: * use an or-pattern * eschew `return` when tail position will do. * don't need fresh_expansion; just add `structural_match` to appropriate `allow_internal_unstable` attributes. also fixed example in doc comment so that it actually compiles.
2019-09-25Snap cfgs to new betaMark Rousskov-4/+0
2019-09-23Move `--cfg bootstrap` out of `rustc.rs`Alex Crichton-4/+4
Instead let's do this via `RUSTFLAGS` in `builder.rs`. Currently requires a submodule update of `stdarch` to fix a problem with previous compilers.
2019-09-14Add cmp::{min_by, min_by_key, max_by, max_by_key}Tim Vermeulen-2/+88
2019-09-04Fix doc links in `std::cmp` moduleLzu Tao-6/+14
These links are rendered in `core::cmp` but not in `std::cmp`.
2019-08-29Small improvement for Ord implementation of integersLzu Tao-2/+2
2019-08-21Add comment to avoid accidentally remove the changes.Lzu Tao-0/+2
2019-08-21Use more optimal Ord implementation for integersLzu Tao-3/+3
2019-08-17Make built-in derives opaque macrosMatthew Jasper-4/+4
2019-08-14Handle cfg(bootstrap) throughoutMark Rousskov-4/+0
2019-08-10Give built-in macros stable addresses in the standard libraryVadim Petrochenkov-0/+32
2019-07-26Remove redundant `mut` from variable declaration.Tomasz Różański-1/+1
2019-04-18libcore => 2018Taiki Endo-2/+2
2019-04-09Remove strange formatting in `Ordering` docs.Eric Huss-3/+3
2019-03-25Clarify `{Ord,f32,f64}::clamp` docs a littleTobias Bucher-4/+9
Explicitly call out when it returns NaN, adhere to the panic doc guidelines.
2019-03-18Replaced self-reflective explicit types with clearer `Self` or `Self::…` ↵Vincent Esche-7/+7
in stdlib docs
2019-03-15Auto merge of #58710 - EdorianDark:master, r=sfacklerbors-0/+26
Add clamp for ranges. Implements #44095 Ready for merge
2019-03-09Use lifetime contravariance to elide more lifetimes in core+alloc+stdScott McMurray-24/+24
2019-03-09Revert "Revert "Add clamp functions""Dirk Leifeld-0/+26
2019-02-10tests: doc commentsAlexander Regueiro-1/+1
2019-01-18Rollup merge of #57357 - frewsxcv:frewsxcv-partial-eq, r=QuietMisdreavusMazdak Farrokhzad-16/+22
Cleanup PartialEq docs. - Cleanup the `impl PartialEq<BookFormat> for Book` implementation - Implement `impl PartialEq<Book> for BookFormat` so it’s symmetric - Fixes https://github.com/rust-lang/rust/issues/53844. - Removes the last example since it appears to be redundant with the previous two examples.
2019-01-15demonstrate symmetryCorey Farwell-1/+1
2019-01-12whitespaceCorey Farwell-6/+6
2019-01-12bring back the example i removed, also add symmetry and simplify implCorey Farwell-0/+42
2019-01-12add comment explaining what the derive doesCorey Farwell-0/+1
2019-01-11re-do docs for core::cmpSteve Klabnik-20/+15
Fixes #32934
2019-01-06Update cmp.rsCorey Farwell-1/+1
2019-01-06add missing derive to fix compile errorCorey Farwell-0/+1
2019-01-05Fix compile errorCorey Farwell-1/+1
2019-01-05Cleanup PartialEq docs.Corey Farwell-47/+9
- Cleanup the `impl PartialEq<BookFormat> for Book` implementation - Implement `impl PartialEq<Book> for BookFormat` so it’s symmetric - Fixes https://github.com/rust-lang/rust/issues/53844. - Removes the last example since it appears to be redundant with the previous two examples.
2018-12-29Specify criterion for PartialOrdCzipperz-2/+3
2018-12-29Make std::cmp::Ord documentation specify what it means to agree with PartialEqCzipperz-3/+4
2018-12-25Remove licensesMark Rousskov-10/+0
2018-09-29Use impl_header_lifetime_elision in libcoreScott McMurray-6/+6
2018-08-21Add another PartialEq exampleGuillaume Gomez-1/+84
2018-08-09inline some short functionsM Farkas-Dyck-0/+2
2018-06-19Add message to `rustc_on_unimplemented` attributes in coreEsteban Küber-2/+8
2018-04-26Add more doc aliasesGuillaume Gomez-0/+12
2018-04-20Revert stabilization of `feature(never_type)`.Felix S. Klock II-4/+4
This commit is just covering the feature gate itself and the tests that made direct use of `!` and thus need to opt back into the feature. A follow on commit brings back the other change that motivates the revert: Namely, going back to the old rules for falling back to `()`.
2018-04-05Bump the bootstrap compiler to 1.26.0 betaAlex Crichton-3/+2
Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language features!
2018-03-14change never_type stabilisation versionAndrew Cann-4/+4
2018-03-14Fix version numberAndrew Cann-4/+4
2018-03-14stabilise feature(never_type)Andrew Cann-4/+4
Replace feature(never_type) with feature(exhaustive_patterns). feature(exhaustive_patterns) only covers the pattern-exhaustives checks that used to be covered by feature(never_type)
2018-03-08Produce instead of pointersOliver Schneider-1/+3
2018-02-28impl Default + Hash for ::core::cmp::ReverseM Farkas-Dyck-1/+1
2018-01-12Derive std::cmp::Reverse as Copy or CloneDan Aloni-1/+1
If the type parameter is Copy or Clone, then `Reverse` should be too.
2017-12-12Rename never_type_impls gate to never_typeAndrew Cann-4/+4
2017-10-05Auto merge of #44943 - nivkner:fixme_fixup, r=dtolnaybors-2/+2
address some FIXME whose associated issues were marked as closed part of #44366
2017-09-30address some `FIXME`s whose associated issues were marked as closedNiv Kaminer-2/+2
remove FIXME(#13101) since `assert_receiver_is_total_eq` stays. remove FIXME(#19649) now that stability markers render. remove FIXME(#13642) now the benchmarks were moved. remove FIXME(#6220) now that floating points can be formatted. remove FIXME(#18248) and write tests for `Rc<str>` and `Rc<[u8]>` remove reference to irelevent issues in FIXME(#1697, #2178...) update FIXME(#5516) to point to getopts issue 7 update FIXME(#7771) to point to RFC 628 update FIXME(#19839) to point to issue 26925
2017-09-24Backport libs stabilizations to 1.21 betaDavid Tolnay-2/+2
This includes the following stabilizations: - tcpstream_connect_timeout https://github.com/rust-lang/rust/pull/44563 - iterator_for_each https://github.com/rust-lang/rust/pull/44567 - ord_max_min https://github.com/rust-lang/rust/pull/44593 - compiler_fences https://github.com/rust-lang/rust/pull/44595 - needs_drop https://github.com/rust-lang/rust/pull/44639 - vec_splice https://github.com/rust-lang/rust/pull/44640