Commit Graph

29050 Commits

Author SHA1 Message Date
Alex Crichton
1ccc51ce3b doc: Fix some broken links 2014-05-21 20:33:00 -07:00
Alex Crichton
799ddba8da Change static.rust-lang.org to doc.rust-lang.org
The new documentation site has shorter urls, gzip'd content, and index.html
redirecting functionality.
2014-05-21 19:55:39 -07:00
bors
1edb0e5364 auto merge of #14324 : zecozephyr/rust/docfix, r=luqmana 2014-05-21 06:21:25 -07:00
bors
a400b31ff5 auto merge of #14319 : kballard/rust/rename_rng_choose_option, r=alexcrichton
Rng.choose() is used so rarely that it doesn't necessitate having two
methods, especially since the failing, non-option variant also requires
Clone.

[breaking-change]
2014-05-21 04:26:23 -07:00
Jonathan Bailey
e549601bc8 Updated doc with correct type. 2014-05-21 02:48:23 -07:00
bors
082075d050 auto merge of #14316 : kballard/rust/range_inclusive_no_toprimitive, r=alexcrichton 2014-05-21 02:46:23 -07:00
bors
4605232f26 auto merge of #14315 : kballard/rust/stdreader_isatty, r=alexcrichton
StdWriter has .isatty(). StdReader can trivially vend the same function,
and someone asked today on IRC how to call isatty() on stdin.
2014-05-21 01:11:25 -07:00
bors
4afc15e30c auto merge of #14259 : alexcrichton/rust/core-mem, r=brson
Excluding the functions inherited from the cast module last week (with marked
stability levels), these functions received the following treatment.

* size_of - this method has become #[stable]
* nonzero_size_of/nonzero_size_of_val - these methods have been removed
* min_align_of - this method is now #[stable]
* pref_align_of - this method has been renamed without the
  `pref_` prefix, and it is the "default alignment" now. This decision is in line
  with what clang does (see url linked in comment on function). This function
  is now #[stable].
* init - renamed to zeroed and marked #[stable]
* uninit - marked #[stable]
* move_val_init - renamed to overwrite and marked #[stable]
* {from,to}_{be,le}{16,32,64} - all functions marked #[stable]
* swap/replace/drop - marked #[stable]
* size_of_val/min_align_of_val/align_of_val - these functions are marked
  #[unstable], but will continue to exist in some form. Concerns have been
  raised about their `_val` prefix.
2014-05-20 23:31:30 -07:00
Alex Crichton
19dc3b50bd core: Stabilize the mem module
Excluding the functions inherited from the cast module last week (with marked
stability levels), these functions received the following treatment.

* size_of - this method has become #[stable]
* nonzero_size_of/nonzero_size_of_val - these methods have been removed
* min_align_of - this method is now #[stable]
* pref_align_of - this method has been renamed without the
  `pref_` prefix, and it is the "default alignment" now. This decision is in line
  with what clang does (see url linked in comment on function). This function
  is now #[stable].
* init - renamed to zeroed and marked #[stable]
* uninit - marked #[stable]
* move_val_init - renamed to overwrite and marked #[stable]
* {from,to}_{be,le}{16,32,64} - all functions marked #[stable]
* swap/replace/drop - marked #[stable]
* size_of_val/min_align_of_val/align_of_val - these functions are marked
  #[unstable], but will continue to exist in some form. Concerns have been
  raised about their `_val` prefix.

[breaking-change]
2014-05-20 23:06:54 -07:00
bors
feb9f302ca auto merge of #14293 : alexcrichton/rust/weak-lang-items, r=brson
This commit is part of the ongoing libstd facade efforts (cc #13851). The
compiler now recognizes some language items as "extern { fn foo(...); }" and
will automatically perform the following actions:

1. The foreign function has a pre-defined name.
2. The crate and downstream crates can only be built as rlibs until a crate
   defines the lang item itself.
3. The actual lang item has a pre-defined name.

This is essentially nicer compiler support for the hokey
core-depends-on-std-failure scheme today, but it is implemented the same way.
The details are a little more hidden under the covers.

In addition to failure, this commit promotes the eh_personality and
rust_stack_exhausted functions to official lang items. The compiler can generate
calls to these functions, causing linkage errors if they are left undefined. The
checking for these items is not as precise as it could be. Crates compiling with
`-Z no-landing-pads` will not need the eh_personality lang item, and crates
compiling with no split stacks won't need the stack exhausted lang item. For
ease, however, these items are checked for presence in all final outputs of the
compiler.

It is quite easy to define dummy versions of the functions necessary:

    #[lang = "stack_exhausted"]
    extern fn stack_exhausted() { /* ... */ }

    #[lang = "eh_personality"]
    extern fn eh_personality() { /* ... */ }

cc #11922, rust_stack_exhausted is now a lang item
cc #13851, libcollections is blocked on eh_personality becoming weak
2014-05-20 21:36:25 -07:00
Kevin Ballard
b8270c8db2 Remove Rng.choose(), rename Rng.choose_option() to .choose()
Rng.choose() is used so rarely that it doesn't necessitate having two
methods, especially since the failing, non-option variant also requires
Clone.

[breaking-change]
2014-05-20 20:44:45 -07:00
Kevin Ballard
c7454853d2 Remove useless ToPrimitive bound on range_inclusive() 2014-05-20 20:27:34 -07:00
Kevin Ballard
dc921c1433 Add .isatty() method to StdReader
StdWriter has .isatty(). StdReader can trivially vend the same function,
and someone asked today on IRC how to call isatty() on stdin.
2014-05-20 20:05:05 -07:00
bors
f30382d624 auto merge of #13823 : pnkfelix/rust/fsk-fix-13805, r=alexcrichton
Make configure script respect (and save) values for `CC`, `CXX`, `CFLAGS` etc.

I mostly tried to remain backwards compatible with old invocations of
the `configure` script; if you do not want to use `CC` et al., you
should not have to; you can keep using `--enable-clang` and/or
`--enable-ccache`.

The overall intention is to capture the following precedences for
guessing the C compiler:

 1. Value of `CC` at `make` invocation time.
 2. Value of `CC` at `configure` invocation time.
 3. Compiler inferred at configure invocation time (`gcc` or `clang`).

The strategy is to check (at `configure` time) if each of the
environment variables is set, and if so, save its value in a
corresponding `CFG_` variable (e.g. `CFG_CC`).

The `configure` script also does not attempt to infer the compiler if
`CC` is set; but if `--enable-clang` was passed, then it *does* still
attempt to validate that the clang version is compatible.

Then, in the makefiles, if `CC` is not set but `CFG_CC` is, then we
use the `CFG_CC` setting as `CC`.

Fix #13805.
2014-05-20 19:16:15 -07:00
bors
e546452727 auto merge of #14305 : tbu-/rust/pr_doc_bytes, r=huonw
Only an example was needed, as the ability to write uints into the string is
already mentioned.

Fix #7102.
2014-05-20 17:36:18 -07:00
bors
6ecf7d97d0 auto merge of #13975 : nikomatsakis/rust/issue-13794-fn-subtyping-and-static, r=pnkfelix
Tweak region inference to ignore constraints like `'a <= 'static`, since they
have no value. This also ensures that we can handle some obscure cases of fn
subtyping with bound regions that we didn't used to handle correctly.

Fixes #13974.
2014-05-20 15:41:20 -07:00
Tobias Bucher
84f43c6acd Add non-utf8 byte to the bytes!() example
Only an example was needed, as the ability to write uints into the string is
already mentioned.

Fix #7102.
2014-05-20 22:53:30 +02:00
bors
4dff9cbf58 auto merge of #14304 : brson/rust/moredocs, r=kballard
Includes module docs for `cell`.
2014-05-20 13:21:18 -07:00
Felix S. Klock II
ae67b74ec8 Make configure respect (and save) values for CC, CXX, CFLAGS, etc.
I mostly tried to remain backwards compatible with old invocations of
the `configure` script; if you do not want to use `CC` et al., you
should not have to; you can keep using `--enable-clang` and/or
`--enable-ccache`.

The overall intention is to capture the following precedences for
guessing the C compiler:

 1. Value of `CC` at make invocation time.
 2. Value of `CC` at configure invocation time.
 3. Compiler inferred at configure invocation time (`gcc` or `clang`).

The strategy is to check (at `configure` time) if each of the
environment variables is set, and if so, save its value in a
corresponding `CFG_` variable (e.g. `CFG_CC`).

Then, in the makefiles, if `CC` is not set but `CFG_CC` is, then we
use the `CFG_CC` setting as `CC`.

Also, I fold the potential user-provided `CFLAGS` and `CXXFLAGS`
values into all of the per-platform `CFLAGS` and `CXXFLAGS` settings.
(This was opposed to adding `$(CFLAGS)` in an ad-hoc manner to various
parts of the mk files.)

Fix #13805.

----

Note that if you try to set the compiler to clang via the `CC` and
`CXX` environment variables, you will probably need to also set
`CXXFLAGS` to `--enable-libcpp` so that LLVM will be configured
properly.

----

Introduce CFG_USING_CLANG, which is distinguished from
CFG_ENABLE_CLANG because the former represents "we think we're using
clang, choose appropriate warning-control options" while the latter
represents "we asked configure (or the host required) that we attempt
to use clang, so check that we have an appropriate version of clang."

The main reason I added this is that I wanted to allow the user to
choose clang via setting the `CC` environment variable, but I did not
want that method of selection to get confused with the user passing
the `--enable-clang` option.

----

A digression: The `configure` script does not infer the compiler
setting if `CC` is set; but if `--enable-clang` was passed, then it
*does* still attempt to validate that the clang version is compatible.

Supporting this required revising `CLANG_VERSION` check to be robust
in face of user-provided `CC` value.

In particular, on Travis, the `CC` is set to `gcc` and so the natural
thing to do is to attempt to use `gcc` as the compiler, but Travis is
also passing `--enable-clang` to configure.  So, what is the right
answer in the face of these contradictory requests?

One approach would be to have `--enable-clang` supersede the setting
for `CC` (and instead just call whatever we inferred for `CFG_CLANG`).
That sounds maximally inflexible to me (pnkfelix): a developer
requesting a `CC` value probably wants it respected, and should be
able to set it to something else; it is harder for that developer to
hack our configure script to change its inferred path to clang.

A second approach would be to blindly use the `CC` value but keep
going through the clang version check when `--enable-clang` is turned
on.  But on Travis (a Linux host), the `gcc` invocation won't print a
clang version, so we would not get past the CLANG_VERSION check in
that context.

A third approach would be to never run the CLANG_VERSION check if `CC`
is explicitly set.  That is not a terrible idea; but if the user uses
`CC` to pass in a path to some other version of clang that they want
to test, probably should still send that through the `CLANG_VERSION`
check.

So in the end I (pnkfelix) took a fourth approach: do the
CLANG_VERSION check if `CC` is unset *or* if `CC` is set to a string
ending with `clang`.  This way setting `CC` to things like
`path/to/clang` or `ccache clang` will still go through the
CLANG_VERSION check, while setting `CC` to `gcc` or some unknown
compiler will skip the CLANG_VERSION check (regardless of whether the
user passed --enable-clang to `configure`).

----

Drive-by fixes:

* The call that sets `CFG_CLANG_VERSION` was quoting `"$CFG_CC"` in
  its invocation, but that does not play nicely with someone who sets
  `$CFG_CC` to e.g. `ccache clang`, since you do not want to intepret
  that whole string as a command.

  (On the other hand, a path with spaces might need the quoted
  invocation.  Not sure which one of these corner use-cases is more
  important to support.)

* Fix chk_cc error message to point user at `gcc` not `cc`.
2014-05-20 21:37:08 +02:00
bors
f9bd6b4e39 auto merge of #14283 : Ryman/rust/commented_compile_fail_error, r=kballard
Edit: This now only covers refactoring to regex.
2014-05-20 11:46:24 -07:00
Brian Anderson
c9ab33a8fd Address review comments 2014-05-20 11:39:40 -07:00
Brian Anderson
26e4680ae5 core: Convert TODOs to FIXMEs 2014-05-20 10:40:14 -07:00
Brian Anderson
1b8deb293e std: Alphabetize crate reexports for rustdoc 2014-05-20 10:38:22 -07:00
Brian Anderson
cea4c27806 core: Spruce up the crate description 2014-05-20 10:38:22 -07:00
Brian Anderson
220313e5e6 core: More concise description for mod ops 2014-05-20 10:38:21 -07:00
Brian Anderson
900b33a4e3 std: Fix broken link 2014-05-20 10:38:21 -07:00
Brian Anderson
8f2a2e2dd8 core: Improve docs for cell 2014-05-20 10:38:21 -07:00
Kevin Butler
66d8c3cb2b compiletest: Refactor compile-fail to regex. 2014-05-20 18:15:34 +01:00
bors
84320a4f4b auto merge of #14277 : pczarn/rust/manual-grammar, r=alexcrichton
The grammar for use declarations was outdated. Corrected some other mistakes.
2014-05-20 10:11:20 -07:00
Piotr Czarnecki
6674913c02 Correct EBNF grammar in the manual
The grammar for use declarations was outdated.
2014-05-20 15:50:03 +02:00
bors
629195582b auto merge of #14296 : kballard/rust/diagnostic_color_newline, r=alexcrichton
When printing colored diagnostics, we need to reset the terminal before
emitting the newline, not after. Otherwise it gets line-buffered and the
color won't reset until the next line is printed or the compiler exits.

Normally this isn't a problem, but when running rustc in parallel with
other processes (e.g. `make -j4`) this can cause the color to leak
to other lines.
2014-05-19 23:41:20 -07:00
bors
ec8ec54192 auto merge of #14289 : TyOverby/rust/master, r=alexcrichton
Closes #14278.

Previously the type signatures of the ordering functions in `core::iter::order` took two iterators, but only if they were the same type of iterator.  This commit loosens that restriction and allows different kinds of iterators (but with the same type of elements) to be compared.
2014-05-19 22:01:21 -07:00
bors
ffe2686063 auto merge of #14265 : Ryman/rust/issue-14254, r=alexcrichton
This is hard coding `Box` into this, as it doesn't seem to parse as `TyUniq` like `~` did. This may not be correct for all usages of the box keyword. 

Closes #14254.
2014-05-19 19:11:24 -07:00
Kevin Ballard
b991bbe2d0 Reset the terminal color before the newline for diagnostics
When printing colored diagnostics, we need to reset the terminal before
emitting the newline, not after. Otherwise it gets line-buffered and the
color won't reset until the next line is printed or the compiler exits.

Normally this isn't a problem, but when running rustc in parallel with
other processes (e.g. `make -j4`) this can cause the color to leak
to other lines.
2014-05-19 18:45:36 -07:00
TyOverby
3001450f95 core::iter::order functions now take two types of iterators.
Previously the type signatures of the ordering functions in
`core::iter::order` took two iterators, but only if they were
the same type of iterator.  This commit loosens that restriction
and allows different kinds of iterators (but with the same type
of elements) to be compared.
2014-05-19 17:37:39 -07:00
Kevin Butler
f9695a6256 rustc: Better resolve errors for &T, &mut T, remove failure condition. 2014-05-20 01:08:05 +01:00
bors
e9018f9c75 auto merge of #14295 : aturon/rust/hide-init_to_vec, r=alexcrichton
The `init_to_vec` function in `collections::bitv` was exposed as an
inherent method, but appears to just be a helper function for the
`to_vec` method. This patch inlines the definition, removing
`init_to_vec` from the public API.

[breaking-change]
2014-05-19 17:06:36 -07:00
bors
1ba7bd10c9 auto merge of #14286 : cmr/rust/shard-benches, r=alexcrichton
This has no tests because it's near impossible to test -- since TestFn uses
`proc`s, they can not be cloned or tested for equality. The only way to really
test this is making sure that for a given number of shards `a`, sharding from
1 to `a` yields the complete set of tests. But `filter_tests` takes its vector
by value and `proc`s cannot be compared.

[breaking-change]

Closes #10898
2014-05-19 15:31:34 -07:00
Corey Richardson
2eeb4992df test: index shards at 1, not 0
This has no tests because it's near impossible to test -- since TestFn uses
`proc`s, they can not be cloned or tested for equality. The only way to really
test this is making sure that for a given number of shards `a`, sharding from
1 to `a` yields the complete set of tests. But `filter_tests` takes its vector
by value and `proc`s cannot be compared.

[breaking-change]

Closes #10898
2014-05-19 14:27:29 -07:00
Aaron Turon
a211907f88 libcollections: remove init_to_vec
The `init_to_vec` function in `collections::bitv` was exposed as an
inherent method, but appears to just be a helper function for the
`to_vec` method. This patch inlines the definition, removing
`init_to_vec` from the public API.

[breaking-change]
2014-05-19 13:50:03 -07:00
bors
1c4a9b98b9 auto merge of #14294 : kballard/rust/result_unwrap_or_else, r=alexcrichton
Result.unwrap_or_handle() is the equivalent of Option.unwrap_or_else().
In the interests of naming consistency, call it the same thing.

[breaking-change]
2014-05-19 13:36:22 -07:00
Kevin Ballard
24468278fd Rename Result.unwrap_or_handle() to .unwrap_or_else()
Result.unwrap_or_handle() is the equivalent of Option.unwrap_or_else().
In the interests of naming consistency, call it the same thing.

[breaking-change]
2014-05-19 13:11:49 -07:00
bors
44fcf46b00 auto merge of #14292 : limeburst/rust/master, r=alexcrichton 2014-05-19 11:56:32 -07:00
Alex Crichton
6efd16629c rustc: Add official support for weak failure
This commit is part of the ongoing libstd facade efforts (cc #13851). The
compiler now recognizes some language items as "extern { fn foo(...); }" and
will automatically perform the following actions:

1. The foreign function has a pre-defined name.
2. The crate and downstream crates can only be built as rlibs until a crate
   defines the lang item itself.
3. The actual lang item has a pre-defined name.

This is essentially nicer compiler support for the hokey
core-depends-on-std-failure scheme today, but it is implemented the same way.
The details are a little more hidden under the covers.

In addition to failure, this commit promotes the eh_personality and
rust_stack_exhausted functions to official lang items. The compiler can generate
calls to these functions, causing linkage errors if they are left undefined. The
checking for these items is not as precise as it could be. Crates compiling with
`-Z no-landing-pads` will not need the eh_personality lang item, and crates
compiling with no split stacks won't need the stack exhausted lang item. For
ease, however, these items are checked for presence in all final outputs of the
compiler.

It is quite easy to define dummy versions of the functions necessary:

    #[lang = "stack_exhausted"]
    extern fn stack_exhausted() { /* ... */ }

    #[lang = "eh_personality"]
    extern fn eh_personality() { /* ... */ }

cc #11922, rust_stack_exhausted is now a lang item
cc #13851, libcollections is blocked on eh_personality becoming weak
2014-05-19 11:04:44 -07:00
bors
e8c579e01d auto merge of #14291 : Sawyer47/rust/doc-fixes, r=alexcrichton 2014-05-19 10:16:31 -07:00
Jihyeok Seo
564b925036 Fix typo in libcore 2014-05-20 00:51:16 +09:00
bors
42be687fa1 auto merge of #14279 : aochagavia/rust/pr2, r=huonw
The breaking changes are:

* Changed `DList::insert_ordered` to use `TotalOrd`, not `Ord`
* Changed `PriorityQueue` to use `TotalOrd`, not `Ord`
* Deprecated `PriorityQueue::maybe_top()` (renamed to replace `PriorityQueue::top()`)
* Deprecated `PriorityQueue::maybe_pop()` (renamed to replace `PriorityQueue::pop()`)
* Deprecated `PriorityQueue::to_vec()` (renamed to `PriorityQueue::into_vec()`)
* Deprecated `PriorityQueue::to_sorted_vec()` (renamed to `PriorityQueue::into_sorted_vec()`)
* Changed `PriorityQueue::replace(...)` to return an `Option<T>` instead of failing when the queue is empty.


[breaking-change]
2014-05-19 07:51:31 -07:00
Piotr Jawniak
cea63ecfb1 Minor doc fixes in various places 2014-05-19 15:41:06 +02:00
bors
ed156772bd auto merge of #14251 : alexcrichton/rust/hierarchy, r=huonw
This is an implementation of RFC 16. A module can now only be loaded if the
module declaring `mod name;` "owns" the current directory. A module is
considered as owning its directory if it meets one of the following criteria:

* It is the top-level crate file
* It is a `mod.rs` file
* It was loaded via `#[path]`
* It was loaded via `include!`
* The module was declared via an inline `mod foo { ... }` statement

For example, this directory structure is now invalid

    // lib.rs
    mod foo;

    // foo.rs
    mod bar;

    // bar.rs;
    fn bar() {}

With this change `foo.rs` must be renamed to `foo/mod.rs`, and `bar.rs` must be
renamed to `foo/bar.rs`. This makes it clear that `bar` is a submodule of `foo`,
and can only be accessed through `foo`.

RFC: 0016-module-file-system-hierarchy
Closes #14180

[breaking-change]
2014-05-19 06:11:33 -07:00
bors
5d2edddc30 auto merge of #14288 : zwarich/rust/euv-underscore, r=alexcrichton 2014-05-18 23:01:27 -07:00