Commit Graph

235 Commits

Author SHA1 Message Date
bors
bdf6e4fcf5 Auto merge of #22920 - tshepang:remove-some-warnings, r=huonw 2015-03-04 12:16:51 +00:00
Felix S. Klock II
0d5bcb14ad Switched to Box::new in many places.
Many of the modifications putting in `Box::new` calls also include a
pointer to Issue 22405, which tracks going back to `box <expr>` if
possible in the future.

(Still tried to use `Box<_>` where it sufficed; thus some tests still
have `box_syntax` enabled, as they use a mix of `box` and `Box::new`.)

Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-03 21:05:55 +01:00
Felix S. Klock II
270f0eef73 Add : Box<_> or ::Box<_> type annotations to various places.
This is the kind of change that one is expected to need to make to
accommodate overloaded-`box`.

----

Note that this is not *all* of the changes necessary to accommodate
Issue 22181.  It is merely the subset of those cases where there was
already a let-binding in place that made it easy to add the necesasry
type ascription.

(For unnamed intermediate `Box` values, one must go down a different
route; `Box::new` is the option that maximizes portability, but has
potential inefficiency depending on whether the call is inlined.)

----

There is one place worth note, `run-pass/coerce-match.rs`, where I
used an ugly form of `Box<_>` type ascription where I would have
preferred to use `Box::new` to accommodate overloaded-`box`.  I
deliberately did not use `Box::new` here, because that is already done
in coerce-match-calls.rs.

----

Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-03 20:29:01 +01:00
bors
14f0942a49 Auto merge of #22532 - pnkfelix:arith-overflow, r=pnkfelix,eddyb
Rebase and follow-through on work done by @cmr and @aatch.

Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed.

The checks for division, remainder and bit-shifting have not been implemented yet.

See also PR #20795

cc @Aatch ; cc @nikomatsakis
2015-03-03 14:18:03 +00:00
Felix S. Klock II
c8db89aa82 Accommodate arith-overflow in core::num, std::num, coretest::num.
* `core::num`: adjust `UnsignedInt::is_power_of_two`,
   `UnsignedInt::next_power_of_two`, `Int::pow`.

   In particular for `Int::pow`: (1.) do not panic when `base`
   overflows if `acc` never observes the overflowed `base`, and (2.)
   if `acc` does observe the overflowed `base`, make sure we only
   panic if we would have otherwise (e.g. during a computation of
   `base * base`).

 * also in `core::num`: avoid underflow during computation of `uint::MAX`.

 * `std::num`: adjust tests `uint::test_uint_from_str_overflow`,
   `uint::test_uint_to_str_overflow`, `strconv`

 * `coretest::num`: adjust `test::test_int_from_str_overflow`.
2015-03-03 12:10:57 +01:00
Florian Zeitz
f35f973cb7 Use consts instead of statics where appropriate
This changes the type of some public constants/statics in libunicode.
Notably some `&'static &'static [(char, char)]` have changed
to `&'static [(char, char)]`. The regexp crate seems to be the
sole user of these, yet this is technically a [breaking-change]
2015-03-02 17:11:51 +01:00
Manish Goregaokar
fb19cd7fb7 Rollup merge of #22504 - GuillaumeGomez:audit-integer-libcore, r=Manishearth
Part of #22240.
2015-03-02 03:53:41 +05:30
Guillaume Gomez
df126589b9 Remove int/uint from libstd/lib.rs 2015-03-01 13:03:44 +01:00
Tshepang Lekhonkhobe
55ce45e7b5 remove some compiler warnings 2015-03-01 09:35:57 +02:00
Guillaume Gomez
1c4fb909ff Make Int::pow() take exp as u32 instead usize 2015-03-01 01:58:55 +01:00
Manish Goregaokar
cf29aa5300 Rollup merge of #22835 - tshepang:remove-some-warnings, r=jakub- 2015-02-27 22:07:04 +05:30
Manish Goregaokar
ce5f1b3216 Rollup merge of #22817 - jmesmon:result-or-type, r=huonw
Changes .or() so that it can return a Result with a different E type
than the one it is called on.

Essentially:

    fn or(self, res: Result<T, E>) -> Result<T, E>

becomes

    fn or<F>(self, res: Result<T, F>) -> Result<T, F>

This brings `or` in line with the existing `and` & `or_else`

This is a
[breaking-change]
Due to some code needing additional type annotations.
2015-02-27 22:07:03 +05:30
Tshepang Lekhonkhobe
8b2ff472cf remove some compiler warnings 2015-02-26 07:21:26 +02:00
Cody P Schafer
07dc8d67c9 Result::or : avoid over-specializing the type
Changes .or() so that it can return a Result with a different E type
than the one it is called on.

Essentially:

    fn or(self, res: Result<T, E>) -> Result<T, E>

becomes

    fn or<F>(self, res: Result<T, F>) -> Result<T, F>

This brings `or` in line with the existing `and` and `or_else` member
types.

This is a
[breaking-change]
Due to some code needing additional type annotations.
2015-02-25 17:38:28 -05:00
Manish Goregaokar
ad73cb0e18 Rollup merge of #22747 - krdln:fix-parsing-minus, r=alexcrichton
Makes Rust less amusing by fixing [#22745](https://github.com/rust-lang/rust/issues/22745)
2015-02-25 03:20:58 +05:30
Vadim Petrochenkov
2807a1ce02 Use arrays instead of vectors in tests 2015-02-24 21:15:45 +03:00
Michał Krasnoborski
a9f6f4b73e Add missing fn 2015-02-24 08:24:42 +01:00
Michał Krasnoborski
948a17ed1d Stop parsing "-" as integer, fixes #22745 2015-02-24 06:04:49 +01:00
bors
67eb38ee4c Auto merge of #22466 - Kimundi:str_pattern_ai_safe, r=aturon
This is not a complete implementation of the RFC:

- only existing methods got updated, no new ones added
- doc comments are not extensive enough yet
- optimizations got lost and need to be reimplemented

See https://github.com/rust-lang/rfcs/pull/528

Technically a

[breaking-change]
2015-02-22 22:45:46 +00:00
Alexis
97aa34046f try to reduce bajillion warnings 2015-02-20 19:55:00 -05:00
Marvin Löbel
a641996796 Fix tidy and rebase fallout
Added a few bugfixes and additional testcases
2015-02-20 00:58:07 +01:00
Marvin Löbel
c1de0a0f9e Added a Pattern impl that delegates to the dereference of a type.
This allows to match with a `&String` or `&&str`, for example.
2015-02-20 00:58:06 +01:00
Marvin Löbel
f9ef8cd555 Refactored code into Searcher traits with naive implementations
Made the family of Split iterators use the Pattern API

Renamed the Matcher traits into Searcher
2015-02-20 00:57:38 +01:00
Marvin Löbel
54f0bead81 Added string pattern traits and basic implementantions 2015-02-20 00:32:59 +01:00
Marvin Löbel
d68eb3d248 Added benchmarks for string pattern matching functions 2015-02-20 00:32:59 +01:00
Alex Crichton
1506b34e0c rollup merge of #22286: nikomatsakis/variance-4b
Conflicts:
	src/librustc/middle/infer/combine.rs
	src/librustc_typeck/check/wf.rs
2015-02-18 15:52:01 -08:00
Alex Crichton
231eeaa35b rollup merge of #22502: nikomatsakis/deprecate-bracket-bracket
Conflicts:
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/librustc/middle/lang_items.rs
	src/librustc_back/rpath.rs
	src/librustc_typeck/check/regionck.rs
	src/libstd/ffi/os_str.rs
	src/libsyntax/diagnostic.rs
	src/libsyntax/parse/parser.rs
	src/libsyntax/util/interner.rs
	src/test/run-pass/regions-refcell.rs
2015-02-18 15:48:40 -08:00
Alex Crichton
365bd9a9e3 Round 1 fixes and rebase conflicts 2015-02-18 15:27:42 -08:00
Niko Matsakis
9ea84aeed4 Replace all uses of &foo[] with &foo[..] en masse. 2015-02-18 17:36:03 -05:00
Alex Crichton
5250a82f79 rollup merge of #22497: nikomatsakis/suffixes
Conflicts:
	src/librustc_trans/trans/tvec.rs
2015-02-18 14:35:01 -08:00
Alex Crichton
9774b7e64b rollup merge of #22480: alexcrichton/hashv3
This commit is an implementation of [RFC 823][rfc] which is another pass over
the `std::hash` module for stabilization. The contents of the module were not
entirely marked stable, but some portions which remained quite similar to the
previous incarnation are now marked `#[stable]`. Specifically:

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0823-hash-simplification.md

* `std::hash` is now stable (the name)
* `Hash` is now stable
* `Hash::hash` is now stable
* `Hasher` is now stable
* `SipHasher` is now stable
* `SipHasher::new` and `new_with_keys` are now stable
* `Hasher for SipHasher` is now stable
* Many `Hash` implementations are now stable

All other portions of the `hash` module remain `#[unstable]` as they are less
commonly used and were recently redesigned.

This commit is a breaking change due to the modifications to the `std::hash` API
and more details can be found on the [RFC][rfc].

Closes #22467
[breaking-change]
2015-02-18 14:32:03 -08:00
Alex Crichton
c07ec507e2 rollup merge of #22287: Ryman/purge_carthographers
This overlaps with #22276 (I left make check running overnight) but covers a number of additional cases and has a few rewrites where the clones are not even necessary.

This also implements `RandomAccessIterator` for `iter::Cloned`

cc @steveklabnik, you may want to glance at this before #22281 gets the bors treatment
2015-02-18 14:31:55 -08:00
Alex Crichton
f83e23ad7c std: Stabilize the hash module
This commit is an implementation of [RFC 823][rfc] which is another pass over
the `std::hash` module for stabilization. The contents of the module were not
entirely marked stable, but some portions which remained quite similar to the
previous incarnation are now marked `#[stable]`. Specifically:

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0823-hash-simplification.md

* `std::hash` is now stable (the name)
* `Hash` is now stable
* `Hash::hash` is now stable
* `Hasher` is now stable
* `SipHasher` is now stable
* `SipHasher::new` and `new_with_keys` are now stable
* `Hasher for SipHasher` is now stable
* Many `Hash` implementations are now stable

All other portions of the `hash` module remain `#[unstable]` as they are less
commonly used and were recently redesigned.

This commit is a breaking change due to the modifications to the `std::hash` API
and more details can be found on the [RFC][rfc].

Closes #22467
[breaking-change]
2015-02-18 08:26:20 -08:00
Niko Matsakis
872ce47955 Fallout: tests. As tests frequently elide things, lots of changes
here.  Some of this may have been poorly rebased, though I tried to be
careful and preserve the spirit of the test.
2015-02-18 10:25:28 -05:00
Niko Matsakis
801bc48939 Rewrite Unique<T> so that it is covariant in T, implies NonZero and ownership,
and also follows the API of `NonZero` a bit more closely. More to do
here I think (including perhaps a new name).
2015-02-18 10:25:12 -05:00
Niko Matsakis
01615b04c6 Convert required suffixes into a use of as. 2015-02-18 09:09:13 -05:00
Kevin Butler
061206b9c7 Remove usage of .map(|&foo| foo) 2015-02-18 00:57:35 +00:00
Kevin Butler
2f586b9687 Opt for .cloned() over .map(|x| x.clone()) etc. 2015-02-18 00:56:07 +00:00
Aaron Turon
d0de2b46e9 Fallout from stabilization 2015-02-17 15:14:17 -08:00
Manish Goregaokar
f0f8be2a2e Fix rollup (remove slicing_syntax) 2015-02-15 19:26:39 +05:30
bors
cca1cf613b Auto merge of #21895 - alfie:libcoretest, r=pnkfelix 2015-02-12 14:58:13 +00:00
Felix S. Klock II
f90c3864b6 Add core::marker::PhantomData.
Port `core::ptr::Unique` to have `PhantomData`. Add `PhantomData` to
`TypedArena` and `Vec` as well.

As a drive-by, switch `ptr::Unique` from a tuple-struct to a struct
with fields.
2015-02-11 13:51:09 +01:00
Alfie John
bffbcb5729 Deprecating i/u suffixes in libcoretest 2015-02-10 22:56:31 +00:00
Alex Crichton
ba7b79008b rollup merge of #22142: Kimundi/unsized_unique
This is to allow for use cases like sending a raw pointer slice across thread boundaries.
2015-02-10 08:43:16 -08:00
Marvin Löbel
792dc8d067 Made the ptr::Unique type accept unsized types, to allow for use cases
like sending a raw pointer slice across thread boundaries.
2015-02-10 14:37:44 +01:00
Ulrik Sverdrup
4f61e16032 Fix std::ops::Range size_hint and ExactSizeIterator impls
When self.start > self.end, these iterators simply return None,
so we adjust the size_hint to just return zero in this case.

Certain optimizations can be implemented in and outside libstd if we
know we can trust the size_hint for all inputs to for example
Range<usize>.

This corrects the ExactSizeIterator implementations, which IMO were
unsound and incorrect previously, since they allowed a range like (2..1)
to return a size_hint of -1us in when debug assertions are turned off.
2015-02-08 00:17:04 +01:00
Jorge Aparicio
17bc7d8d5b cleanup: replace as[_mut]_slice() calls with deref coercions 2015-02-05 13:45:01 -05:00
Jorge Aparicio
571cc7f8e9 remove all kind annotations from closures 2015-02-04 20:06:08 -05:00
bors
c3e1f77291 Auto merge of #21892 - huonw:deprecate-rand, r=alexcrichton
Use [`rand`](https://crates.io/crates/rand) and [`derive_rand`](https://crates.io/crates/derive_rand) from crates.io.

[breaking-change]
2015-02-04 08:47:27 +00:00
Huon Wilson
df1ac7aa63 Deprecate in-tree rand, std::rand and #[derive(Rand)].
Use the crates.io crate `rand` (version 0.1 should be a drop in
replacement for `std::rand`) and `rand_macros` (`#[derive_Rand]` should
be a drop-in replacement).

[breaking-change]
2015-02-04 09:39:40 +11:00