Commit Graph

182 Commits

Author SHA1 Message Date
Nick Hamann
a1898f890d Convert #[lang="..."] to #[lang = "..."]
In my opinion this looks nicer, but also it matches the whitespace generally
used for stability markers more closely.
2015-05-09 14:50:28 -05:00
Tamir Duberstein
69abc12b00 Register new snapshots 2015-04-28 17:23:45 -07:00
Ulrik Sverdrup
709b5e8c89 Fix Debug impl for RangeFull
The Debug impl was using quotes, which was inconsistent:

    => (.., 1.., 2..3, ..4)
    ("..", 1.., 2..3, ..4)

Fix to use just ..
2015-04-16 10:02:22 +02:00
Tobias Bucher
3b9847e886 Fix code formatting in core::ops::Add example 2015-04-06 16:01:01 +02:00
Alex Crichton
f92e7abefd rollup merge of #23860: nikomatsakis/copy-requires-clone
Conflicts:
	src/test/compile-fail/coherence-impls-copy.rs
2015-04-01 18:37:54 -07:00
Alex Crichton
9edbf42a34 rollup merge of #23945: pnkfelix/gate-u-negate
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-01 18:36:21 -07:00
Felix S. Klock II
a98e4713bf removed impls of Neg for u{8,16,32,64,size}. 2015-04-01 22:35:50 +02:00
Felix S. Klock II
3225b04c7d fallout from feature-gating unary negation on unsigned integers. 2015-04-01 22:34:27 +02:00
Manish Goregaokar
debac97a10 Rollup merge of #23895 - nikomatsakis:fn-trait-inheritance-add-impls, r=pnkfelix
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-02 00:40:39 +05:30
Niko Matsakis
c35c46821a Fallout in public-facing and semi-public-facing libs 2015-04-01 11:23:45 -04:00
Niko Matsakis
35c261aea0 Add #[fundamental] annotations into libcore so that Sized and the
`Fn` traits are considered fundamental, along with `Box` (though that is
mostly for show; the real type is `~T` in the compiler).
2015-04-01 11:21:42 -04:00
Niko Matsakis
27b7841bb1 Add blanket impls for references to the Fn traits. 2015-03-31 09:51:35 -04:00
Niko Matsakis
d6466ff13a Driveby cleanup of the impl for negation, which had some kind of
surprising casts. This version more obviously corresponds to the builtin
semantics.
2015-03-30 04:59:56 -04:00
Alex Crichton
36ef29abf7 Register new snapshots 2015-03-26 09:57:05 -07:00
bors
a3b13610c5 Auto merge of #23434 - alexcrichton:misc-stab, r=aturon
Now that we check the stability of fields, the fields of this struct should also
be stable.
2015-03-25 18:59:00 +00:00
Alex Crichton
8f6c879d2a rollup merge of #23282: nikomatsakis/fn-trait-inheritance
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-24 14:50:44 -07:00
Niko Matsakis
b4d4daf007 Adjust Index/IndexMut impls. For generic collections, we take
references. For collections whose keys are integers, we take both
references and by-value.
2015-03-23 16:55:43 -04:00
Niko Matsakis
bc1dde468c Compiler and trait changes to make indexing by value. 2015-03-23 16:54:28 -04:00
Niko Matsakis
37601131a0 Make the Fn traits inherit from one another and remove the bridging
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-23 16:46:02 -04:00
Alex Crichton
5749a1f9dc std: Add missing stability on Range
Now that we check the stability of fields, the fields of this struct should also
be stable.
2015-03-18 11:39:29 -07:00
Joseph Crail
fcf3f3209a Remove explicit syntax highlight from docs. 2015-03-13 19:25:18 -04:00
Steve Klabnik
64ab111b53 Example -> Examples
This brings comments in line with https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#using-markdown
2015-03-11 21:11:40 -04:00
Alex Crichton
da03392e1f std: Mark Index::Output as a stable associated type
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-03-03 11:28:57 -08:00
Ivan Petkov
dab394c2db Add documentation to associated types in libcore, libstd 2015-02-23 11:05:55 -08:00
Niko Matsakis
d7f673c82e Audit integer types in ops. 2015-02-15 10:22:43 -05:00
Alex Crichton
bbbb571fee rustc: Fix a number of stability lint holes
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:👿: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-11 12:14:59 -08:00
Jorge Aparicio
724bf7bce2 make IndexMut a super trait over Index
closes #21630
2015-02-06 21:11:59 -05:00
Jorge Aparicio
134cf707df register snapshots 2015-02-02 13:38:32 -05:00
Jorge Aparicio
c3841b9c9f remove Copy impls from remaining iterators 2015-01-31 09:09:22 -05:00
Alex Crichton
64dd7be2c5 Merge remote-tracking branch 'origin/master' into rollup
Conflicts:
	src/liballoc/lib.rs
	src/libcore/ops.rs
2015-01-30 14:55:34 -08:00
Alex Crichton
8397217629 rollup merge of #21760: brson/snaps 2015-01-30 13:26:42 -08:00
bors
3fbfad3519 Auto merge of #21604 - nikomatsakis:closure-move-indiv-vars, r=eddyb
r? @eddyb
2015-01-30 15:32:27 +00:00
Niko Matsakis
a962bdb3da Use #[rustc_paren_sugar] as a more extensible way of deciding when
paren sugar is legal.
2015-01-30 05:57:57 -05:00
Brian Anderson
03b9995be9 Register snaps 2015-01-29 15:02:00 -08:00
Nick Cameron
bf2b473816 Rename FullRange to RangeFull 2015-01-30 12:01:08 +13:00
Jorge Aparicio
788181d405 s/Show/Debug/g 2015-01-29 07:49:02 -05:00
Manish Goregaokar
c709ed2faf Merge remote-tracking branch 'origin/master' into rollup
Conflicts:
	src/libcollections/slice.rs
	src/libcore/nonzero.rs
	src/libcore/ops.rs
2015-01-28 23:31:03 +05:30
Niko Matsakis
07cdb85331 Move return type an associated type of the Fn* traits. Mostly this 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-28 05:15:23 -05:00
Manish Goregaokar
28b0271f89 Rollup merge of #21658 - Manishearth:index_on_unimplemented, r=Gankro
Helps issues like [these](http://www.reddit.com/r/rust/comments/2tpefm/unable_to_access_array_elements/)

r? @Gankro

rollup-worthy
2015-01-28 04:32:20 +05:30
Manish Goregaokar
6a90eca8fc Add on_unimplemented note to Index 2015-01-27 02:19:52 +05:30
Jorge Aparicio
bff462302b cleanup: s/impl Copy/#[derive(Copy)]/g 2015-01-25 11:20:38 -05:00
Brian Anderson
63fcbcf3ce Merge remote-tracking branch 'rust-lang/master'
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-25 01:20:55 -08:00
Brian Anderson
b44ee371b8 grandfathered -> rust1 2015-01-23 21:48:20 -08:00
Brian Anderson
cd6d9eab5d Set unstable feature names appropriately
* `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-23 13:28:40 -08:00
Brian Anderson
41278c5441 Remove 'since' from unstable attributes 2015-01-21 19:25:55 -08:00
Brian Anderson
94ca8a3610 Add 'feature' and 'since' to stability attributes 2015-01-21 16:16:18 -08:00
Alex Crichton
886c6f3534 rollup merge of #21258: aturon/stab-3-index
Conflicts:
	src/libcore/ops.rs
	src/librustc_typeck/astconv.rs
	src/libstd/io/mem.rs
	src/libsyntax/parse/lexer/mod.rs
2015-01-21 11:53:49 -08:00
Alex Crichton
87c3ee861e rollup merge of #21457: alexcrichton/issue-21436
Conflicts:
	src/liballoc/boxed.rs
	src/librustc/middle/traits/error_reporting.rs
	src/libstd/sync/mpsc/mod.rs
2015-01-21 09:20:35 -08:00
Alex Crichton
ecc9dccc15 rollup merge of #21367: steveklabnik/remove_gate
This gate was `Accepted`, so we shouldn't need these.
2015-01-21 09:13:57 -08:00
Aaron Turon
fba0bf63a9 Stabilize Index traits and most range notation
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-21 07:45:45 -08:00