about summary refs log tree commit diff
path: root/src/libcore/ops.rs
AgeCommit message (Collapse)AuthorLines
2015-04-16Fix Debug impl for RangeFullUlrik Sverdrup-1/+1
The Debug impl was using quotes, which was inconsistent: => (.., 1.., 2..3, ..4) ("..", 1.., 2..3, ..4) Fix to use just ..
2015-04-06Fix code formatting in `core::ops::Add` exampleTobias Bucher-4/+4
2015-04-01rollup merge of #23860: nikomatsakis/copy-requires-cloneAlex Crichton-14/+14
Conflicts: src/test/compile-fail/coherence-impls-copy.rs
2015-04-01rollup merge of #23945: pnkfelix/gate-u-negateAlex Crichton-4/+20
Feature-gate unsigned unary negate. Discussed in weekly meeting here: https://github.com/rust-lang/meeting-minutes/blob/master/weekly-meetings/2015-03-31.md#feature-gate--expr and also in the internals thread here: http://internals.rust-lang.org/t/forbid-unsigned-integer/752
2015-04-01removed impls of `Neg` for `u{8,16,32,64,size}`.Felix S. Klock II-1/+1
2015-04-01fallout from feature-gating unary negation on unsigned integers.Felix S. Klock II-4/+20
2015-04-02Rollup merge of #23895 - nikomatsakis:fn-trait-inheritance-add-impls, r=pnkfelixManish Goregaokar-0/+49
The primary purpose of this PR is to add blanket impls for the `Fn` traits of the following (simplified) form: impl<F:Fn> Fn for &F impl<F:FnMut> FnMut for &mut F However, this wound up requiring two changes: 1. A slight hack so that `x()` where `x: &mut F` is translated to `FnMut::call_mut(&mut *x, ())` vs `FnMut::call_mut(&mut x, ())`. This is achieved by just autoderef'ing one time when calling something whose type is `&F` or `&mut F`. 2. Making the infinite recursion test in trait matching a bit more tailored. This involves adding a notion of "matching" types that looks to see if types are potentially unifiable (it's an approximation). The PR also includes various small refactorings to the inference code that are aimed at moving the unification and other code into a library (I've got that particular change in a branch, these changes just lead the way there by removing unnecessary dependencies between the compiler and the more general unification code). Note that per rust-lang/rfcs#1023, adding impls like these would be a breaking change in the future. cc @japaric cc @alexcrichton cc @aturon Fixes #23015.
2015-04-01Fallout in public-facing and semi-public-facing libsNiko Matsakis-14/+14
2015-04-01Add `#[fundamental]` annotations into libcore so that `Sized` and theNiko Matsakis-0/+3
`Fn` traits are considered fundamental, along with `Box` (though that is mostly for show; the real type is `~T` in the compiler).
2015-03-31Add blanket impls for references to the `Fn` traits.Niko Matsakis-0/+49
2015-03-30Driveby cleanup of the impl for negation, which had some kind ofNiko Matsakis-22/+2
surprising casts. This version more obviously corresponds to the builtin semantics.
2015-03-26Register new snapshotsAlex Crichton-62/+0
2015-03-25Auto merge of #23434 - alexcrichton:misc-stab, r=aturonbors-3/+4
Now that we check the stability of fields, the fields of this struct should also be stable.
2015-03-24rollup merge of #23282: nikomatsakis/fn-trait-inheritanceAlex Crichton-0/+24
The primary motivation here is to sidestep #19032 -- for a time, I thought that we should improve coherence or otherwise extend the language, but I now think that any such changes will require more time to bake. In the meantime, inheritance amongst the fn traits is both logically correct *and* a simple solution to that obstacle. This change introduces inheritance and modifies the compiler so that it can properly generate impls for closures and fns. Things enabled by this PR (but not included in this PR): 1. An impl of `FnMut` for `&mut F` where `F : FnMut` (https://github.com/rust-lang/rust/issues/23015). 2. A better version of `Thunk` I've been calling `FnBox`. I did not include either of these in the PR because: 1. Adding the impls in 1 currently induces a coherence conflict with the pattern trait. This is interesting and merits some discussion. 2. `FnBox` deserves to be a PR of its own. The main downside to this design is (a) the need to write impls by hand; (b) the possibility of implementing `FnMut` with different semantics from `Fn`, etc. Point (a) is minor -- in particular, it does not affect normal closure usage -- and could be addressed in the future in many ways (better defaults; convenient macros; specialization; etc). Point (b) is unfortunate but "just a bug" from my POV, and certainly not unique to these traits (c.f. Copy/Clone, PartialEq/Eq, etc). (Until we lift the feature-gate on implementing the Fn traits, in any case, there is room to correct both of these if we find a nice way.) Note that I believe this change is reversible in the future if we decide on another course of action, due to the feature gate on implementing the `Fn` traits, though I do not (currently) think we should reverse it. Fixes #18835. r? @nrc
2015-03-23Adjust Index/IndexMut impls. For generic collections, we takeNiko Matsakis-3/+3
references. For collections whose keys are integers, we take both references and by-value.
2015-03-23Compiler and trait changes to make indexing by value.Niko Matsakis-0/+12
2015-03-23Make the `Fn` traits inherit from one another and remove the bridgingNiko Matsakis-0/+24
impls. This requires: 1. modifying trait selection a bit so that when we synthesize impls for fn pointers and closures; 2. adding code to trans so that we can synthesize a `FnMut`/`FnOnce` impl for a `Fn` closure and so forth.
2015-03-18std: Add missing stability on RangeAlex Crichton-3/+4
Now that we check the stability of fields, the fields of this struct should also be stable.
2015-03-13Remove explicit syntax highlight from docs.Joseph Crail-4/+4
2015-03-11Example -> ExamplesSteve Klabnik-18/+18
This brings comments in line with https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#using-markdown
2015-03-03std: Mark `Index::Output` as a stable associated typeAlex Crichton-0/+1
This stability attribute was left out by accident and the stability pass has since picked up the ability to check for this. As a result, crates are currently getting warnings for implementations of `Index`.
2015-02-23Add documentation to associated types in libcore, libstdIvan Petkov-0/+17
2015-02-15Audit integer types in ops.Niko Matsakis-13/+13
2015-02-11rustc: Fix a number of stability lint holesAlex Crichton-6/+3
There are a number of holes that the stability lint did not previously cover, including: * Types * Bounds on type parameters on functions and impls * Where clauses * Imports * Patterns (structs and enums) These holes have all been fixed by overriding the `visit_path` function on the AST visitor instead of a few specialized cases. This change also necessitated a few stability changes: * The `collections::fmt` module is now stable (it was already supposed to be). * The `thread_local::imp::Key` type is now stable (it was already supposed to be). * The `std::rt::{begin_unwind, begin_unwind_fmt}` functions are now stable. These are required via the `panic!` macro. * The `std::old_io::stdio::{println, println_args}` functions are now stable. These are required by the `print!` and `println!` macros. * The `ops::{FnOnce, FnMut, Fn}` traits are now `#[stable]`. This is required to make bounds with these traits stable. Note that manual implementations of these traits are still gated by default, this stability only allows bounds such as `F: FnOnce()`. Additionally, the compiler now has special logic to ignore its own generated `__test` module for the `--test` harness in terms of stability. Closes #8962 Closes #16360 Closes #20327 [breaking-change]
2015-02-06make `IndexMut` a super trait over `Index`Jorge Aparicio-10/+14
closes #21630
2015-02-02register snapshotsJorge Aparicio-17/+0
2015-01-31remove Copy impls from remaining iteratorsJorge Aparicio-2/+2
2015-01-30Merge remote-tracking branch 'origin/master' into rollupAlex Crichton-0/+3
Conflicts: src/liballoc/lib.rs src/libcore/ops.rs
2015-01-30rollup merge of #21760: brson/snapsAlex Crichton-53/+0
2015-01-30Auto merge of #21604 - nikomatsakis:closure-move-indiv-vars, r=eddybbors-0/+3
r? @eddyb
2015-01-30Use `#[rustc_paren_sugar]` as a more extensible way of deciding whenNiko Matsakis-0/+3
paren sugar is legal.
2015-01-29Register snapsBrian Anderson-53/+0
2015-01-30Rename FullRange to RangeFullNick Cameron-0/+17
2015-01-29s/Show/Debug/gJorge Aparicio-1/+1
2015-01-28Merge remote-tracking branch 'origin/master' into rollupManish Goregaokar-87/+157
Conflicts: src/libcollections/slice.rs src/libcore/nonzero.rs src/libcore/ops.rs
2015-01-28Move return type an associated type of the `Fn*` traits. Mostly this ↵Niko Matsakis-6/+69
involves tweaking things in the compiler that assumed two input types to assume two ouputs; we also have to teach `project.rs` to project `Output` from the unboxed closure and fn traits.
2015-01-28Rollup merge of #21658 - Manishearth:index_on_unimplemented, r=GankroManish Goregaokar-0/+2
Helps issues like [these](http://www.reddit.com/r/rust/comments/2tpefm/unable_to_access_array_elements/) r? @Gankro rollup-worthy
2015-01-27Add on_unimplemented note to IndexManish Goregaokar-0/+2
2015-01-25cleanup: s/impl Copy/#[derive(Copy)]/gJorge Aparicio-4/+2
2015-01-25Merge remote-tracking branch 'rust-lang/master'Brian Anderson-98/+17
Conflicts: mk/tests.mk src/liballoc/arc.rs src/liballoc/boxed.rs src/liballoc/rc.rs src/libcollections/bit.rs src/libcollections/btree/map.rs src/libcollections/btree/set.rs src/libcollections/dlist.rs src/libcollections/ring_buf.rs src/libcollections/slice.rs src/libcollections/str.rs src/libcollections/string.rs src/libcollections/vec.rs src/libcollections/vec_map.rs src/libcore/any.rs src/libcore/array.rs src/libcore/borrow.rs src/libcore/error.rs src/libcore/fmt/mod.rs src/libcore/iter.rs src/libcore/marker.rs src/libcore/ops.rs src/libcore/result.rs src/libcore/slice.rs src/libcore/str/mod.rs src/libregex/lib.rs src/libregex/re.rs src/librustc/lint/builtin.rs src/libstd/collections/hash/map.rs src/libstd/collections/hash/set.rs src/libstd/sync/mpsc/mod.rs src/libstd/sync/mutex.rs src/libstd/sync/poison.rs src/libstd/sync/rwlock.rs src/libsyntax/feature_gate.rs src/libsyntax/test.rs
2015-01-23grandfathered -> rust1Brian Anderson-62/+62
2015-01-23Set unstable feature names appropriatelyBrian Anderson-19/+19
* `core` - for the core crate * `hash` - hashing * `io` - io * `path` - path * `alloc` - alloc crate * `rand` - rand crate * `collections` - collections crate * `std_misc` - other parts of std * `test` - test crate * `rustc_private` - everything else
2015-01-21Remove 'since' from unstable attributesBrian Anderson-19/+19
2015-01-21Add 'feature' and 'since' to stability attributesBrian Anderson-81/+88
2015-01-21rollup merge of #21258: aturon/stab-3-indexAlex Crichton-59/+8
Conflicts: src/libcore/ops.rs src/librustc_typeck/astconv.rs src/libstd/io/mem.rs src/libsyntax/parse/lexer/mod.rs
2015-01-21rollup merge of #21457: alexcrichton/issue-21436Alex Crichton-9/+9
Conflicts: src/liballoc/boxed.rs src/librustc/middle/traits/error_reporting.rs src/libstd/sync/mpsc/mod.rs
2015-01-21rollup merge of #21367: steveklabnik/remove_gateAlex Crichton-30/+0
This gate was `Accepted`, so we shouldn't need these.
2015-01-21Stabilize Index traits and most range notationAaron Turon-63/+12
This commit marks as `#[stable]`: * The `Index` and `IndexMut` traits. These are stabilized as taking the index itself *by reference*; after extensive discussion it was determined that this is a better match with our choices elsewhere (e.g. making comparison operators auto-reference), and that the use cases for by-value indices are better handled through `IndexSet`. * The `Range`, `RangeFrom` and `RangeTo` structs, introduced for range notation. * Various impls of `Index` and `IndexMut`. The `FullRange` struct is left unstable as we may wish to rename it to `RangeFull` in the future. This commit also *removes* the `Step` trait in favor of direct implementation of iterator traits on ranges for integers. The `Step` trait was not a terribly useful factoring internally, and it is likely that external integer types are best off implementing range iterators directly. It was removed to simplify the API surface. We can always reintroduce `Step` later if it turns out to be useful. Due to this removal, this is a: [breaking-change]
2015-01-21Auto merge of #21227 - sellibitze:core-ops-for-references, r=aturonbors-4/+92
As discussed with @aturon I added implementations of various op traits for references to built-in types which was already suggested by the ops reform RFC. The 2nd commit updates the module documentation of core::ops to fully reflect the recent change from pass-by-reference to pass-by-value and expands on the implications for generic code.
2015-01-20std: Rename Show/String to Debug/DisplayAlex Crichton-9/+9
This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl<E: Error> FromError<E> for Box<Error>` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436