Commit Graph

256 Commits

Author SHA1 Message Date
cad97
ac57e1b647 Remove ord lang item 2019-12-01 16:09:07 -05:00
Guanqun Lu
55d725884b follow the same function order in the trait
This removes several warnings in IDE.
2019-11-26 22:55:38 +08:00
Mazdak Farrokhzad
afc78e19dd Rollup merge of #66566 - robamler:issue-66476, r=rkruppe
Document pitfall with `impl PartialEq<B> for A`

Fixes #66476 by turning the violating example into an explicit
counterexample.
2019-11-22 19:57:46 +01:00
Robert Bamler
5028fd8ab9 Document pitfall with impl PartialEq<B> for A
Fixes #66476 by turning the violating example into an explicit
counterexample.
2019-11-21 23:16:44 -08:00
Mazdak Farrokhzad
15c30ddd69 Stabilize the never_type, written !. 2019-11-21 14:55:32 +01:00
Felix S. Klock II
98f5b11b6b Migrate from #[structural_match] attribute a lang-item trait.
(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-10-25 14:52:07 +02:00
Mark Rousskov
f359a94849 Snap cfgs to new beta 2019-09-25 08:42:46 -04:00
Alex Crichton
b3f95f460f Move --cfg bootstrap out of rustc.rs
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-23 09:34:44 -07:00
Tim Vermeulen
6e5ada43bf Add cmp::{min_by, min_by_key, max_by, max_by_key} 2019-09-14 21:52:08 +02:00
Lzu Tao
b6f9523dc6 Fix doc links in std::cmp module
These links are rendered in `core::cmp` but not in `std::cmp`.
2019-09-04 13:52:28 +00:00
Lzu Tao
ade191c70a Small improvement for Ord implementation of integers 2019-08-29 03:52:18 +00:00
Lzu Tao
96983fc530 Add comment to avoid accidentally remove the changes. 2019-08-21 06:25:37 +00:00
Lzu Tao
0337cc117d Use more optimal Ord implementation for integers 2019-08-21 00:37:17 +00:00
Matthew Jasper
6ee60af1ab Make built-in derives opaque macros 2019-08-17 08:59:36 +01:00
Mark Rousskov
2601c86487 Handle cfg(bootstrap) throughout 2019-08-14 05:39:53 -04:00
Vadim Petrochenkov
cbcc7dd182 Give built-in macros stable addresses in the standard library 2019-08-10 00:05:37 +03:00
Tomasz Różański
4a2f9b6d62 Remove redundant mut from variable declaration. 2019-07-26 15:07:55 +02:00
Taiki Endo
360432f1e8 libcore => 2018 2019-04-18 14:47:35 +09:00
Eric Huss
3e01901fcd Remove strange formatting in Ordering docs. 2019-04-09 15:41:38 -07:00
Tobias Bucher
0bb36a2f90 Clarify {Ord,f32,f64}::clamp docs a little
Explicitly call out when it returns NaN, adhere to the panic doc
guidelines.
2019-03-25 12:52:42 +01:00
Vincent Esche
698bbe5253 Replaced self-reflective explicit types with clearer Self or Self::… in stdlib docs 2019-03-18 13:57:51 +01:00
bors
70d1150478 Auto merge of #58710 - EdorianDark:master, r=sfackler
Add clamp for ranges. Implements #44095

Ready for merge
2019-03-15 06:23:21 +00:00
Scott McMurray
df4ea90b39 Use lifetime contravariance to elide more lifetimes in core+alloc+std 2019-03-09 19:10:28 -08:00
Dirk Leifeld
bd2e12609f Revert "Revert "Add clamp functions"" 2019-03-09 19:16:54 +01:00
Alexander Regueiro
b87363e763 tests: doc comments 2019-02-10 23:42:32 +00:00
Mazdak Farrokhzad
bca490808f Rollup merge of #57357 - frewsxcv:frewsxcv-partial-eq, r=QuietMisdreavus
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-18 18:06:30 +01:00
Corey Farwell
32b28340b2 demonstrate symmetry 2019-01-15 21:21:24 -05:00
Corey Farwell
0394dce788 whitespace 2019-01-12 11:19:02 -05:00
Corey Farwell
1445a065de bring back the example i removed, also add symmetry and simplify impl 2019-01-12 11:17:49 -05:00
Corey Farwell
423a5bb5c4 add comment explaining what the derive does 2019-01-12 11:00:14 -05:00
Steve Klabnik
186d5d7fd4 re-do docs for core::cmp
Fixes #32934
2019-01-11 12:00:09 -05:00
Corey Farwell
bbbabdfc52 Update cmp.rs 2019-01-06 15:18:22 -05:00
Corey Farwell
319a2c1cc2 add missing derive to fix compile error 2019-01-06 11:08:34 -05:00
Corey Farwell
0d3dfdf6aa Fix compile error 2019-01-05 22:52:13 -05:00
Corey Farwell
96678df838 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-05 12:41:12 -05:00
Czipperz
445dadca33 Specify criterion for PartialOrd 2018-12-29 19:14:06 -05:00
Czipperz
cf3959c5b0 Make std::cmp::Ord documentation specify what it means to agree with PartialEq 2018-12-29 17:48:43 -05:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Scott McMurray
0a3bd9b6ab Use impl_header_lifetime_elision in libcore 2018-09-29 21:33:35 -07:00
Guillaume Gomez
3995bff26c Add another PartialEq example 2018-08-21 23:24:23 +02:00
M Farkas-Dyck
b78201aee5 inline some short functions 2018-08-09 01:27:48 -08:00
Esteban Küber
776544f011 Add message to rustc_on_unimplemented attributes in core 2018-06-19 15:19:13 -07:00
Guillaume Gomez
30e3f1a620 Add more doc aliases 2018-04-26 12:56:10 +02:00
Felix S. Klock II
fadabd6fbb Revert stabilization of feature(never_type).
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-20 18:09:28 +02:00
Alex Crichton
8958815916 Bump the bootstrap compiler to 1.26.0 beta
Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language
features!
2018-04-05 07:13:45 -07:00
Andrew Cann
a704624ef5 change never_type stabilisation version 2018-03-14 12:44:51 +08:00
Andrew Cann
32ddb30715 Fix version number 2018-03-14 12:44:51 +08:00
Andrew Cann
a9fc3901b0 stabilise feature(never_type)
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-14 12:44:51 +08:00
Oliver Schneider
918b6d7633 Produce instead of pointers 2018-03-08 08:08:14 +01:00
M Farkas-Dyck
25b69c4ede impl Default + Hash for ::core::cmp::Reverse 2018-02-28 21:00:48 -08:00