Commit Graph

38741 Commits

Author SHA1 Message Date
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
5a32b4a34f rollup merge of #22491: Gankro/into_iter
Conflicts:
	src/libcollections/bit.rs
	src/libcollections/linked_list.rs
	src/libcollections/vec_deque.rs
	src/libstd/sys/common/wtf8.rs
2015-02-18 14:34:08 -08:00
Alex Crichton
9aee389b6e rollup merge of #22485: pnkfelix/fsk-int-uint-audit
cc #22240
2015-02-18 14:32:14 -08:00
Alex Crichton
b90e40718f rollup merge of #22484: riginding/master 2015-02-18 14:32:12 -08:00
Alex Crichton
f3657170b1 rollup merge of #22482: alexcrichton/cstr-changes
This commit is an implementation of [RFC 592][r592] and [RFC 840][r840]. These
two RFCs tweak the behavior of `CString` and add a new `CStr` unsized slice type
to the module.

[r592]: https://github.com/rust-lang/rfcs/blob/master/text/0592-c-str-deref.md
[r840]: https://github.com/rust-lang/rfcs/blob/master/text/0840-no-panic-in-c-string.md

The new `CStr` type is only constructable via two methods:

1. By `deref`'ing from a `CString`
2. Unsafely via `CStr::from_ptr`

The purpose of `CStr` is to be an unsized type which is a thin pointer to a
`libc::c_char` (currently it is a fat pointer slice due to implementation
limitations). Strings from C can be safely represented with a `CStr` and an
appropriate lifetime as well. Consumers of `&CString` should now consume `&CStr`
instead to allow producers to pass in C-originating strings instead of just
Rust-allocated strings.

A new constructor was added to `CString`, `new`, which takes `T: IntoBytes`
instead of separate `from_slice` and `from_vec` methods (both have been
deprecated in favor of `new`). The `new` method returns a `Result` instead of
panicking.  The error variant contains the relevant information about where the
error happened and bytes (if present). Conversions are provided to the
`io::Error` and `old_io::IoError` types via the `FromError` trait which
translate to `InvalidInput`.

This is a breaking change due to the modification of existing `#[unstable]` APIs
and new deprecation, and more detailed information can be found in the two RFCs.
Notable breakage includes:

* All construction of `CString` now needs to use `new` and handle the outgoing
  `Result`.
* Usage of `CString` as a byte slice now explicitly needs a `.as_bytes()` call.
* The `as_slice*` methods have been removed in favor of just having the
  `as_bytes*` methods.

Closes #22469
Closes #22470
[breaking-change]
2015-02-18 14:32:10 -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
261364d45d rollup merge of #22452: nikomatsakis/issue-22040-18956-Self
The big change here is that we update the object-safety rules to prohibit references to `Self` in the supertrait listing. See #22040 for the motivation. The other change is to handle the interaction of defaults that reference `Self` and object types (where `Self` is erased). We force users to give an explicit type in that scenario.

r? @aturon
2015-02-18 14:32:02 -08:00
Alex Crichton
d8753a0ec3 rollup merge of #22438: dotdash/iter_vec_loop
No need to create a bunch of blocks and a stack allocated temporary just
to build a simple loop.
2015-02-18 14:32:01 -08:00
Alex Crichton
386d329ac5 rollup merge of #22437: dotdash/fix_array_type
In trans_slice_vec we currently use arrayalloca, which gives us a
pointer to the element type with enough memory allocated for the
requested number of elements.  This works, but everywhere else we use
the [n x T] type for fixed size arrays and so we have to bitcast the
pointer here. Let's directly use the proper type for the allocation and
remove some code duplication along the way.
2015-02-18 14:31:59 -08:00
Alex Crichton
754db0f7ac rollup merge of #22436: nikomatsakis/issue-22246-bound-lifetimes-of-assoc-types
Take 2. This PR includes a bunch of refactoring that was part of an experimental branch implementing [implied bounds]. That particular idea isn't ready to go yet, but the refactoring proved useful for fixing #22246. The implied bounds branch also exposed #22110 so a simple fix for that is included here. I still think some more refactoring would be a good idea here -- in particular I think most of the code in wf.rs is kind of duplicating the logic in implicator and should go, but I decided to post this PR and call it a day before diving into that. I'll write a bit more details about the solutions I adopted in the various bugs. I patched the two issues I was concerned about, which was the handling of supertraits and HRTB (the latter turned out to be fine, so I added a comment explaining why.)

r? @pnkfelix (for now, anyway)
cc @aturon

[implied bounds]: http://smallcultfollowing.com/babysteps/blog/2014/07/06/implied-bounds/
2015-02-18 14:31:58 -08:00
Alex Crichton
31166ecf79 rollup merge of #22395: brson/readme-cleanup
Just a few things to make the README ever more perfect.

r? @steveklabnik
2015-02-18 14:31:57 -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
c5fddd81ab rollup merge of #22118: fhahn/separate-parse-fail-2
After making `rustc` fail on errors at a stop point, like `-Z parse-only`, in #22117, the files in this PR also fail during the parse stage and should be moved as well. Sorry for spliting this move up in two PRs.
2015-02-18 14:31:23 -08:00
Alex Crichton
fa30c4f147 rollup merge of #21886: dotdash/fast_slice_iter
The data pointer used in the slice is never null, using assume() to tell
LLVM about it gets rid of various unneeded null checks when iterating
over the slice.

Since the snapshot compiler is still using an older LLVM version, omit
the call in stage0, because compile times explode otherwise.

Benchmarks from #18193
````
running 5 tests
test _range    ... bench:     33329 ns/iter (+/- 417)
test assembly  ... bench:     33299 ns/iter (+/- 58)
test enumerate ... bench:     33318 ns/iter (+/- 83)
test iter      ... bench:     33311 ns/iter (+/- 130)
test position  ... bench:     33300 ns/iter (+/- 47)

test result: ok. 0 passed; 0 failed; 0 ignored; 5 measured
````

Fixes #18193
2015-02-18 14:31:21 -08:00
Alex Crichton
1860ee521a std: Implement CString-related RFCs
This commit is an implementation of [RFC 592][r592] and [RFC 840][r840]. These
two RFCs tweak the behavior of `CString` and add a new `CStr` unsized slice type
to the module.

[r592]: https://github.com/rust-lang/rfcs/blob/master/text/0592-c-str-deref.md
[r840]: https://github.com/rust-lang/rfcs/blob/master/text/0840-no-panic-in-c-string.md

The new `CStr` type is only constructable via two methods:

1. By `deref`'ing from a `CString`
2. Unsafely via `CStr::from_ptr`

The purpose of `CStr` is to be an unsized type which is a thin pointer to a
`libc::c_char` (currently it is a fat pointer slice due to implementation
limitations). Strings from C can be safely represented with a `CStr` and an
appropriate lifetime as well. Consumers of `&CString` should now consume `&CStr`
instead to allow producers to pass in C-originating strings instead of just
Rust-allocated strings.

A new constructor was added to `CString`, `new`, which takes `T: IntoBytes`
instead of separate `from_slice` and `from_vec` methods (both have been
deprecated in favor of `new`). The `new` method returns a `Result` instead of
panicking.  The error variant contains the relevant information about where the
error happened and bytes (if present). Conversions are provided to the
`io::Error` and `old_io::IoError` types via the `FromError` trait which
translate to `InvalidInput`.

This is a breaking change due to the modification of existing `#[unstable]` APIs
and new deprecation, and more detailed information can be found in the two RFCs.
Notable breakage includes:

* All construction of `CString` now needs to use `new` and handle the outgoing
  `Result`.
* Usage of `CString` as a byte slice now explicitly needs a `.as_bytes()` call.
* The `as_slice*` methods have been removed in favor of just having the
  `as_bytes*` methods.

Closes #22469
Closes #22470
[breaking-change]
2015-02-18 14:15:43 -08:00
Brian Anderson
c273571bfd Remove mention of wiki from README 2015-02-18 13:48:46 -08:00
Brian Anderson
7430e58e65 Address review feedback 2015-02-18 13:46:55 -08:00
Brian Anderson
73cc4ed4da README: Simplify markdown 2015-02-18 13:46:55 -08:00
Brian Anderson
aaabdbfe04 README: Add one sentence about what Rust is.
Most people don't know what Rust is.
2015-02-18 13:46:55 -08:00
Brian Anderson
46189559a9 README: Add a link to #rust 2015-02-18 13:46:55 -08:00
Brian Anderson
9265e13867 README: Make the wiki links more useful.
The page we want them to find is 'getting started developing'.
2015-02-18 13:46:55 -08:00
Brian Anderson
21ed20baf9 README: Give a hint about how to build Cargo from source.
Just a hint.
2015-02-18 13:46:55 -08:00
Brian Anderson
4acc483106 Simplify README by not talking about the source tarball option
I believe that few enough people build from source tarballs that
we don't have to talk about it explicitly.
2015-02-18 13:46:55 -08:00
Niko Matsakis
9bb3b3772d Add rustc_attrs feature to test. 2015-02-18 15:24:20 -05:00
Niko Matsakis
a994a99ec4 Always prefer where-clauses over impls in trait selection. Fixes #22110. 2015-02-18 15:23:34 -05:00
Niko Matsakis
2939e483fd Extend the implicator so it produces general obligations and also so
that it produces "outlives" relations for associated types. Add
several tests relating to #22246.
2015-02-18 15:23:34 -05:00
Niko Matsakis
5511add742 traits: break apart the "full normalization" code used for normalizing
parameter environments so that it can be used elsewhere.
2015-02-18 15:23:34 -05:00
Niko Matsakis
7134ad4d64 Move tcx from Typer into ClosureTyper 2015-02-18 15:23:34 -05:00
Niko Matsakis
e84a719e37 Misc. cleanup in regionck: Remove a one-variant enum for some reason. 2015-02-18 15:23:34 -05:00
Niko Matsakis
48c70d6863 Replace assert_no_late_bound_regions with
`no_late_bound_regions().unwrap()`, which allows us to write code that
doesn't necessarily *fail* when there are higher-ranked trait bounds.
2015-02-18 15:23:34 -05:00
Niko Matsakis
92d65ab2e9 Rename various things to "implications" 2015-02-18 15:23:33 -05:00
Niko Matsakis
df92fe3c96 Rename regionmanip to implicator. 2015-02-18 15:23:33 -05:00
Niko Matsakis
811c48fe22 For now, accept the i, u, is, and us suffixes, but warn when
they are used without a feature-gate. This is both kinder to existing
code and should make it easier to land this PR, since we don't
have to catch EVERY SINGLE SUFFIX.
2015-02-18 15:08:40 -05:00
Alexis
66613e26b9 make FromIterator use IntoIterator
This breaks all implementors of FromIterator, as they must now accept IntoIterator instead of Iterator. The fix for this is generally trivial (change the bound, and maybe call into_iter() on the argument to get the old argument).

Users of FromIterator should be unaffected because Iterators are IntoIterator.

[breaking-change]
2015-02-18 14:01:47 -05:00
Alexis
4a9d190423 make Extend use IntoIterator
This breaks all implementors of Extend, as they must now accept IntoIterator instead of Iterator. The fix for this is generally trivial (change the bound, and maybe call into_iter() on the argument to get the old argument).

Users of Extend should be unaffected because Iterators are IntoIterator.

[breaking-change]
2015-02-18 14:01:47 -05:00
Aaron Turon
5fa9de16df Implement RFC 580
This commit implements RFC 580 by renaming:

* DList -> LinkedList
* Bitv -> BitVec
* BitvSet -> BitSet
* RingBuf -> VecDeque

More details are in [the
RFC](https://github.com/rust-lang/rfcs/pull/580)

[breaking-change]
2015-02-18 14:01:46 -05: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
362d713026 Fix remaining bench/debuginfo tests (and a few stragglers) 2015-02-18 09:11:02 -05:00
Niko Matsakis
72eb214ee4 Update suffixes en masse in tests using perl -p -i -e 2015-02-18 09:10:10 -05:00
Niko Matsakis
8c34b26606 Update docs by dropping suffixes except where they served to instruct. 2015-02-18 09:09:14 -05:00
Niko Matsakis
1f4ee20dda Tweak pretty printing. 2015-02-18 09:09:13 -05:00
Niko Matsakis
01615b04c6 Convert required suffixes into a use of as. 2015-02-18 09:09:13 -05:00
Niko Matsakis
2b5720a15f Remove i, is, u, or us suffixes that are not necessary. 2015-02-18 09:09:12 -05:00
Niko Matsakis
700c518f2a Modify parser to require isize/usize suffixes. 2015-02-18 09:07:56 -05:00
Felix S. Klock II
fc0f6e86b6 Audit core::intrinsics for int/uint: size_of/align_of use usize.
Likewise, `fn offset` takes an `isize`.
2015-02-18 14:45:35 +01:00
Felix S. Klock II
e240cb919b Audit core::default for int/uint usage.
* Use `i32` (`u32`) in doc examples, not `int` (`u32`).

* Switch impl macros to use `isize`/`usize` rather than `int`/`uint`.
2015-02-18 14:41:13 +01:00
Felix S. Klock II
343909bca1 Audit core::cmp for int/uint.
* cast 3-valued `core::cmp::Ordering` to `i32`, not `int`.

* use `isize`/`usize` in the impl macros.
2015-02-18 14:39:06 +01:00
Felix S. Klock II
f82e2310b3 Audit core::borrow for use of int/uint: use i32 in doc example. 2015-02-18 14:37:05 +01:00
Björn Steinbrink
7412d1b2ef Eliminate excessive null-checks from slice iterators
The data pointer used in the slice is never null, using assume() to tell
LLVM about it gets rid of various unneeded null checks when iterating
over the slice.

Since the snapshot compiler is still using an older LLVM version, omit
the call in stage0, because compile times explode otherwise.

Benchmarks from #18193
````
running 5 tests
test _range    ... bench:     33329 ns/iter (+/- 417)
test assembly  ... bench:     33299 ns/iter (+/- 58)
test enumerate ... bench:     33318 ns/iter (+/- 83)
test iter      ... bench:     33311 ns/iter (+/- 130)
test position  ... bench:     33300 ns/iter (+/- 47)

test result: ok. 0 passed; 0 failed; 0 ignored; 5 measured
````

Fixes #18193
2015-02-18 14:04:46 +01:00
Björn Steinbrink
52b5150cfd Avoid ptrtoint when checking if a pointer is null
Casting the pointer to an integer requires a ptrtoint, while casting 0
to a pointer is directly folded to a `null` value.
2015-02-18 14:04:46 +01:00