]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #14259 : alexcrichton/rust/core-mem, r=brson
bors [Wed, 21 May 2014 06:31:30 +0000 (23:31 -0700)]
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.

10 years agocore: Stabilize the mem module
Alex Crichton [Sat, 17 May 2014 07:56:00 +0000 (00:56 -0700)]
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]

10 years agoauto merge of #14293 : alexcrichton/rust/weak-lang-items, r=brson
bors [Wed, 21 May 2014 04:36:25 +0000 (21:36 -0700)]
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

10 years agoauto merge of #13823 : pnkfelix/rust/fsk-fix-13805, r=alexcrichton
bors [Wed, 21 May 2014 02:16:15 +0000 (19:16 -0700)]
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.

10 years agoauto merge of #14305 : tbu-/rust/pr_doc_bytes, r=huonw
bors [Wed, 21 May 2014 00:36:18 +0000 (17:36 -0700)]
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.

10 years agoauto merge of #13975 : nikomatsakis/rust/issue-13794-fn-subtyping-and-static, r=pnkfelix
bors [Tue, 20 May 2014 22:41:20 +0000 (15:41 -0700)]
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.

10 years agoAdd non-utf8 byte to the bytes!() example
Tobias Bucher [Tue, 20 May 2014 20:53:30 +0000 (22:53 +0200)]
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.

10 years agoauto merge of #14304 : brson/rust/moredocs, r=kballard
bors [Tue, 20 May 2014 20:21:18 +0000 (13:21 -0700)]
auto merge of #14304 : brson/rust/moredocs, r=kballard

Includes module docs for `cell`.

10 years agoMake configure respect (and save) values for `CC`, `CXX`, `CFLAGS`, etc.
Felix S. Klock II [Mon, 28 Apr 2014 16:57:26 +0000 (18:57 +0200)]
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`.

10 years agoauto merge of #14283 : Ryman/rust/commented_compile_fail_error, r=kballard
bors [Tue, 20 May 2014 18:46:24 +0000 (11:46 -0700)]
auto merge of #14283 : Ryman/rust/commented_compile_fail_error, r=kballard

Edit: This now only covers refactoring to regex.

10 years agoAddress review comments
Brian Anderson [Tue, 20 May 2014 18:39:40 +0000 (11:39 -0700)]
Address review comments

10 years agocore: Convert TODOs to FIXMEs
Brian Anderson [Tue, 20 May 2014 17:40:14 +0000 (10:40 -0700)]
core: Convert TODOs to FIXMEs

10 years agostd: Alphabetize crate reexports for rustdoc
Brian Anderson [Tue, 20 May 2014 17:38:05 +0000 (10:38 -0700)]
std: Alphabetize crate reexports for rustdoc

10 years agocore: Spruce up the crate description
Brian Anderson [Tue, 20 May 2014 04:53:00 +0000 (21:53 -0700)]
core: Spruce up the crate description

10 years agocore: More concise description for mod ops
Brian Anderson [Tue, 20 May 2014 04:52:24 +0000 (21:52 -0700)]
core: More concise description for mod ops

10 years agostd: Fix broken link
Brian Anderson [Tue, 20 May 2014 04:51:21 +0000 (21:51 -0700)]
std: Fix broken link

10 years agocore: Improve docs for cell
Brian Anderson [Mon, 19 May 2014 04:47:51 +0000 (21:47 -0700)]
core: Improve docs for cell

10 years agocompiletest: Refactor compile-fail to regex.
Kevin Butler [Tue, 20 May 2014 17:15:34 +0000 (18:15 +0100)]
compiletest: Refactor compile-fail to regex.

10 years agoauto merge of #14277 : pczarn/rust/manual-grammar, r=alexcrichton
bors [Tue, 20 May 2014 17:11:20 +0000 (10:11 -0700)]
auto merge of #14277 : pczarn/rust/manual-grammar, r=alexcrichton

The grammar for use declarations was outdated. Corrected some other mistakes.

10 years agoCorrect EBNF grammar in the manual
Piotr Czarnecki [Tue, 20 May 2014 13:50:03 +0000 (15:50 +0200)]
Correct EBNF grammar in the manual

The grammar for use declarations was outdated.

10 years agoauto merge of #14296 : kballard/rust/diagnostic_color_newline, r=alexcrichton
bors [Tue, 20 May 2014 06:41:20 +0000 (23:41 -0700)]
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.

10 years agoauto merge of #14289 : TyOverby/rust/master, r=alexcrichton
bors [Tue, 20 May 2014 05:01:21 +0000 (22:01 -0700)]
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.

10 years agoauto merge of #14265 : Ryman/rust/issue-14254, r=alexcrichton
bors [Tue, 20 May 2014 02:11:24 +0000 (19:11 -0700)]
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.

10 years agoReset the terminal color before the newline for diagnostics
Kevin Ballard [Mon, 19 May 2014 21:37:52 +0000 (14:37 -0700)]
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.

10 years agocore::iter::order functions now take two types of iterators.
TyOverby [Mon, 19 May 2014 06:31:23 +0000 (23:31 -0700)]
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.

10 years agorustc: Better resolve errors for &T, &mut T, remove failure condition.
Kevin Butler [Mon, 19 May 2014 21:27:03 +0000 (22:27 +0100)]
rustc: Better resolve errors for &T, &mut T, remove failure condition.

10 years agoauto merge of #14295 : aturon/rust/hide-init_to_vec, r=alexcrichton
bors [Tue, 20 May 2014 00:06:36 +0000 (17:06 -0700)]
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]

10 years agoauto merge of #14286 : cmr/rust/shard-benches, r=alexcrichton
bors [Mon, 19 May 2014 22:31:34 +0000 (15:31 -0700)]
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

10 years agotest: index shards at 1, not 0
Corey Richardson [Mon, 19 May 2014 02:35:45 +0000 (19:35 -0700)]
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

10 years agolibcollections: remove `init_to_vec`
Aaron Turon [Mon, 19 May 2014 18:46:29 +0000 (11:46 -0700)]
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]

10 years agoauto merge of #14294 : kballard/rust/result_unwrap_or_else, r=alexcrichton
bors [Mon, 19 May 2014 20:36:22 +0000 (13:36 -0700)]
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]

10 years agoRename Result.unwrap_or_handle() to .unwrap_or_else()
Kevin Ballard [Mon, 19 May 2014 20:11:49 +0000 (13:11 -0700)]
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]

10 years agoauto merge of #14292 : limeburst/rust/master, r=alexcrichton
bors [Mon, 19 May 2014 18:56:32 +0000 (11:56 -0700)]
auto merge of #14292 : limeburst/rust/master, r=alexcrichton

10 years agorustc: Add official support for weak failure
Alex Crichton [Mon, 19 May 2014 16:30:09 +0000 (09:30 -0700)]
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

10 years agoauto merge of #14291 : Sawyer47/rust/doc-fixes, r=alexcrichton
bors [Mon, 19 May 2014 17:16:31 +0000 (10:16 -0700)]
auto merge of #14291 : Sawyer47/rust/doc-fixes, r=alexcrichton

10 years agoFix typo in libcore
Jihyeok Seo [Mon, 19 May 2014 15:51:16 +0000 (00:51 +0900)]
Fix typo in libcore

10 years agoauto merge of #14279 : aochagavia/rust/pr2, r=huonw
bors [Mon, 19 May 2014 14:51:31 +0000 (07:51 -0700)]
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]

10 years agoMinor doc fixes in various places
Piotr Jawniak [Mon, 19 May 2014 13:39:16 +0000 (15:39 +0200)]
Minor doc fixes in various places

10 years agoauto merge of #14251 : alexcrichton/rust/hierarchy, r=huonw
bors [Mon, 19 May 2014 13:11:33 +0000 (06:11 -0700)]
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]

10 years agoauto merge of #14288 : zwarich/rust/euv-underscore, r=alexcrichton
bors [Mon, 19 May 2014 06:01:27 +0000 (23:01 -0700)]
auto merge of #14288 : zwarich/rust/euv-underscore, r=alexcrichton

10 years agoRemove leading underscores in function signatures in a trait definition.
Cameron Zwarich [Mon, 19 May 2014 05:53:01 +0000 (22:53 -0700)]
Remove leading underscores in function signatures in a trait definition.

10 years agoauto merge of #14276 : aochagavia/rust/pr, r=alexcrichton
bors [Mon, 19 May 2014 02:51:26 +0000 (19:51 -0700)]
auto merge of #14276 : aochagavia/rust/pr, r=alexcrichton

10 years agoauto merge of #14122 : dagitses/rust/master, r=alexcrichton
bors [Mon, 19 May 2014 01:11:27 +0000 (18:11 -0700)]
auto merge of #14122 : dagitses/rust/master, r=alexcrichton

This is my first patch and hopefully nothing controversial: just a straightforward forwarding of TreeMap::move_iter() as TreeSet::move_iter().

10 years agoFix insert_ordered in DList
Adolfo OchagavĂ­a [Sun, 18 May 2014 23:34:01 +0000 (16:34 -0700)]
Fix insert_ordered in DList

10 years agoFix dead code warnings
Adolfo OchagavĂ­a [Sun, 18 May 2014 23:33:30 +0000 (16:33 -0700)]
Fix dead code warnings

10 years agoauto merge of #14263 : cmr/rust/termex, r=kballard
bors [Sun, 18 May 2014 23:31:31 +0000 (16:31 -0700)]
auto merge of #14263 : cmr/rust/termex, r=kballard

10 years agoRefactored and renamed functions to avoid failure
Adolfo OchagavĂ­a [Sun, 18 May 2014 22:54:19 +0000 (15:54 -0700)]
Refactored and renamed functions to avoid failure

10 years agoRename to_vec and to_sorted_vec
Adolfo OchagavĂ­a [Sun, 18 May 2014 22:04:43 +0000 (15:04 -0700)]
Rename to_vec and to_sorted_vec

10 years agoauto merge of #14000 : pnkfelix/rust/fsk-fix-issue13732, r=alexcrichton
bors [Sun, 18 May 2014 21:41:35 +0000 (14:41 -0700)]
auto merge of #14000 : pnkfelix/rust/fsk-fix-issue13732, r=alexcrichton

Fix #13732.

This is a revised, much less hacky form of PR #13753

The changes here:

 * add instrumentation to aid debugging of linkage errors,
 * fine tune some things in the Makefile where we are telling binaries to use a host-oriented path for finding dynamic libraries, when it should be feeding the binaries a target-oriented path for dynamic libraries.
 * pass along the current stage number to run-make tests, and
 * skip certain tests when running atop stage1.

Fix #13746 as well.

10 years agoReplaced Ord by TotalOrd in priority queue
Adolfo OchagavĂ­a [Sun, 18 May 2014 21:37:15 +0000 (14:37 -0700)]
Replaced Ord by TotalOrd in priority queue

10 years agoRefactoring: Introduce distinct host and target rpath var setters.
Felix S. Klock II [Fri, 25 Apr 2014 16:22:23 +0000 (18:22 +0200)]
Refactoring: Introduce distinct host and target rpath var setters.

Two line summary: Distinguish HOST_RPATH and TARGET_RPATH; added
RPATH_LINK_SEARCH; skip tests broken in stage1; general cleanup.

`HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)` and `TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3)`
both match the format of the old `RPATH_VAR$(1)_T_$(2)_H_$(3)` (which
is still being set the same way that it was before, to one of either
HOST/TARGET depending on what stage we are building).  Namely, the format
is <XXX>_RPATH_VAR = "<LD_LIB_PATH_ENVVAR>=<COLON_SEP_PATH_ENTRIES>"

What this commit does:

* Pass both of the (newly introduced) HOST and TARGET rpath setup vars
  to `maketest.py`

* Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself
  Instead, it passes along the HOST and TARGET rpath setup vars in
  environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV`

* Also, pass the current stage number to maketest.py; it in turn
  passes it (via an env var) to run-make tests.

  This allows the run-make tests to selectively change behavior
  (e.g. turn themselves off) to deal with incompatibilities with
  e.g. stage1.

* Cleanup: Distinguish in tools.mk between the command to run (`RUN`)
  and the file to generate to drive that command (`RUN_BINFILE`).  The
  main thing this enables is that `RUN` can now setup the
  `TARGET_RPATH_ENV` without having to dirty up the runner code in
  each of the `run-make` Makefiles.

* Cleanup: Factored out commands to delete dylib/rlib into
  REMOVE_DYLIBS/REMOVE_RLIBS.

  There were places where we were only calling `rm $(call DYLIB,foo)`
  even though we really needed to get rid of the whole glob (at least
  based on alex's findings on #13753 that removing the symlink does not
  suffice).

  Therefore rather than peppering the code with the awkward
  `rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common
  `REMOVE_DYLIBS` user function that expands into that when called.
  After I adding an analogous `REMOVE_RLIBS`, I changed all of the
  existing calls that rm dylibs or rlibs to use these routines
  instead.

  Note that the latter is not a true refactoring since I may have
  changed cases where it was our intent to only remove the sym-link.
  (But if that is the case, then we need to more deeply investigate
  alex's findings on #13753 where the system was still dynamically
  loading up the non-symlinked libraries that it finds on the load
  path.)

* Added RPATH_LINK_SEARCH command and use it on Linux.

  On some platforms, namely Linux, when you have libboot.so that has
  its internal rpath set (to e.g. $(ORIGIN)/path/to/HOSTDIR), the
  linker still complains when you do the link step and it does not
  know where to find libraries that libboot.so depends upon that live
  in HOSTDIR (think e.g. librustuv.so).

  As far as I can tell, the GNU linker will consult the
  LD_LIBRARY_PATH as part of the linking process to find such
  libraries.  But if you want to be more careful and not override
  LD_LIBRARY_PATH for the `gcc` invocation, then you need some other
  way to tell the linker where it can find the libraries that
  libboot.so needs.  The solution to this on Linux is the
  `-Wl,-rpath-link` command line option.

  However, this command line option does not exist on Mac OS X, (which
  appears to be figuring out how to resolve the libboot.dylib
  dependency by some other means, perhaps by consulting the rpath
  setting within libboot.dylib).

  So, in order to abstract over this distinction, I added the
  RPATH_LINK_SEARCH macro to the run-make infrastructure and added
  calls to it where necessary to get Linux working.  On architectures
  other than Linux, the macro expands to nothing.

* Disable miscellaneous tests atop stage1.

* An especially interesting instance of the previous bullet point:
  Excuse regex from doing rustdoc tests atop stage1.

  This was a (nearly-) final step to get `make check-stage1` working
  again.

  The use of a special-case check for regex here is ugly but is
  analogous other similar checks for regex such as the one that landed
  in PR #13844.

  The way this is written, the user will get a reminder that
  doc-crate-regex is being skipped whenever their rules attempt to do
  the crate documentation tests.  This is deliberate: I want people
  running `make check-stage1` to be reminded about which cases are
  being skipped.  (But if such echo noise is considered offensive, it
  can obviously be removed.)

* Got windows working with the above changes.

  This portion of the commit is a cleanup revision of the (previously
  mentioned on try builds) re-architecting of how the LD_LIBRARY_PATH
  setup and extension is handled in order to accommodate Windows' (1.)
  use of `$PATH` for that purpose and (2.) use of spaces in `$PATH`
  entries (problematic for make and for interoperation with tools at
  the shell).

* In addition, since the code has been rearchitected to pass the
  HOST_RPATH_DIR/TARGET_RPATH_DIR rather than a whole sh
  environment-variable setting command, there is no need to for the
  convert_path_spec calls in maketest.py, which in fact were put in
  place to placate Windows but were now causing the Windows builds to
  fail.  Instead we just convert the paths to absolute paths just like
  all of the other path arguments.

Also, note for makefile hackers: apparently you cannot quote operands
to `ifeq` in Makefile (or at least, you need to be careful about
adding them, e.g. to only one side).

10 years agoOutput debug info on how `#[phase] extern crate foo;` gets resolved.
Felix S. Klock II [Fri, 25 Apr 2014 16:33:07 +0000 (18:33 +0200)]
Output debug info on how `#[phase] extern crate foo;` gets resolved.

10 years agoInclude file paths when dumping the list of resolved crates via `debug!`.
Felix S. Klock II [Fri, 25 Apr 2014 16:06:49 +0000 (18:06 +0200)]
Include file paths when dumping the list of resolved crates via `debug!`.

10 years agoFixing rustdoc stage1.
Felix S. Klock II [Thu, 15 May 2014 17:28:46 +0000 (19:28 +0200)]
Fixing rustdoc stage1.

See #13983 and #14000.

Fix was originally authored by alexcrichton and then rebased a couple
times by pnkfelix, most recently atop PR 13954.

----

Regarding the change to librustdoc/lib.rs, to do `map_err` before
unwrapping a `TqskResult`: I do not understand how master is passing
without this change or something like it, since `Box<Any:Send>` does
not implement `Show`.  (Is this something that is only a problem for
the snapshot stage0 compiler?)  Still, the change I have put in here
(which was added as part of a rebase after alex's review) seems
harmless to me to apply to rustdoc at all stages, since a call to
`unwrap` is just going to `fail!` on the err case anyway.

10 years agoauto merge of #14275 : kballard/rust/bytes-return-static, r=huonw
bors [Sun, 18 May 2014 20:06:30 +0000 (13:06 -0700)]
auto merge of #14275 : kballard/rust/bytes-return-static, r=huonw

Change `bytes!()` to return

    {
        static BYTES: &'static [u8] = &[...];
        BYTES
    }

This gives it the `'static` lifetime, whereas before it had an rvalue
lifetime. Until recently this would have prevented assigning `bytes!()`
to a static, as in

    static FOO: &'static [u8] = bytes!(1,2,3);

but #14183 fixed it so blocks are now allowed in constant expressions
(with restrictions).

Fixes #11641.

10 years agoMake bytes!() return 'static
Kevin Ballard [Sat, 18 Jan 2014 06:30:36 +0000 (22:30 -0800)]
Make bytes!() return 'static

Change `bytes!()` to return

    {
        static BYTES: &'static [u8] = &[...];
        BYTES
    }

This gives it the `'static` lifetime, whereas before it had an rvalue
lifetime. Until recently this would have prevented assigning `bytes!()`
to a static, as in

    static FOO: &'static [u8] = bytes!(1,2,3);

but #14183 fixed it so blocks are now allowed in constant expressions
(with restrictions).

Fixes #11641.

10 years agoRemoved unnecessary transmute
Adolfo OchagavĂ­a [Sun, 18 May 2014 18:21:47 +0000 (11:21 -0700)]
Removed unnecessary transmute

10 years agoauto merge of #14274 : youknowone/rust/advice-tilt-to-box, r=thestinger
bors [Sun, 18 May 2014 12:36:27 +0000 (05:36 -0700)]
auto merge of #14274 : youknowone/rust/advice-tilt-to-box, r=thestinger

10 years agoauto merge of #14258 : alexcrichton/rust/dox-format-writer, r=cmr
bors [Sun, 18 May 2014 09:51:30 +0000 (02:51 -0700)]
auto merge of #14258 : alexcrichton/rust/dox-format-writer, r=cmr

This commit fills in the documentation holes for the FormatWriter trait which
were previously accidentally left blank. Additionally, this adds the `write_fmt`
method to the trait to allow usage of the `write!` macro with implementors of
the `FormatWriter` trait. This is not useful for consumers of the standard
library who should generally avoid the `FormatWriter` trait, but it is useful
for consumers of the core library who are not using the standard library.

10 years agoauto merge of #14121 : luqmana/rust/option-ffi, r=alexcrichton
bors [Sun, 18 May 2014 08:16:27 +0000 (01:16 -0700)]
auto merge of #14121 : luqmana/rust/option-ffi, r=alexcrichton

This slightly adjusts the NullablePointer representation for some enums in the case where the non-nullable variant has a single field (the ptr field) to be just that, the pointer. This is in contrast to the current behaviour where we'd wrap that single pointer in a LLVM struct.

Fixes #11040 & #11303.

10 years agoUpdate debuginfo tests.
Luqman Aden [Sun, 18 May 2014 07:04:50 +0000 (03:04 -0400)]
Update debuginfo tests.

10 years agoauto merge of #14249 : alexcrichton/rust/issue-14246, r=huonw
bors [Sun, 18 May 2014 06:41:28 +0000 (23:41 -0700)]
auto merge of #14249 : alexcrichton/rust/issue-14246, r=huonw

Closes #14246

10 years agoAdvice to use Box<T> not ~T
Jeong YunWon [Sun, 18 May 2014 06:30:41 +0000 (15:30 +0900)]
Advice to use Box<T> not ~T

10 years agocore: Document FormatWriter and allow `write!`
Alex Crichton [Sat, 17 May 2014 05:40:38 +0000 (22:40 -0700)]
core: Document FormatWriter and allow `write!`

This commit fills in the documentation holes for the FormatWriter trait which
were previously accidentally left blank. Additionally, this adds the `write_fmt`
method to the trait to allow usage of the `write!` macro with implementors of
the `FormatWriter` trait. This is not useful for consumers of the standard
library who should generally avoid the `FormatWriter` trait, but it is useful
for consumers of the core library who are not using the standard library.

10 years agocore: Clarify the documentation on core's prelude
Alex Crichton [Fri, 16 May 2014 20:22:08 +0000 (13:22 -0700)]
core: Clarify the documentation on core's prelude

Closes #14246

10 years agoauto merge of #14230 : alexcrichton/rust/liballoc, r=cmr,huonw
bors [Sun, 18 May 2014 05:01:28 +0000 (22:01 -0700)]
auto merge of #14230 : alexcrichton/rust/liballoc, r=cmr,huonw

This commit is part of the libstd facade RFC, issue #13851. This creates a new
library, liballoc, which is intended to be the core allocation library for all
of Rust. It is pinned on the basic assumption that an allocation failure is an
abort or failure.

This module has inherited the heap/libc_heap modules from std::rt, the owned/rc
modules from std, and the arc module from libsync. These three pointers are
currently the three most core pointer implementations in Rust.

The UnsafeArc type in std::sync should be considered deprecated and replaced by
`Arc<Unsafe<T>>`. This commit does not currently migrate to this type, but future
commits will continue this refactoring.

10 years agoRegister new snapshots
Alex Crichton [Sun, 18 May 2014 04:54:11 +0000 (21:54 -0700)]
Register new snapshots

10 years agostd: Refactor liballoc out of lib{std,sync}
Alex Crichton [Tue, 13 May 2014 23:10:05 +0000 (16:10 -0700)]
std: Refactor liballoc out of lib{std,sync}

This commit is part of the libstd facade RFC, issue #13851. This creates a new
library, liballoc, which is intended to be the core allocation library for all
of Rust. It is pinned on the basic assumption that an allocation failure is an
abort or failure.

This module has inherited the heap/libc_heap modules from std::rt, the owned/rc
modules from std, and the arc module from libsync. These three pointers are
currently the three most core pointer implementations in Rust.

The UnsafeArc type in std::sync should be considered deprecated and replaced by
Arc<Unsafe<T>>. This commit does not currently migrate to this type, but future
commits will continue this refactoring.

10 years agoadding move_iter() function to collections::treemap::TreeSet
Michael Dagitses [Mon, 12 May 2014 02:34:44 +0000 (22:34 -0400)]
adding move_iter() function to collections::treemap::TreeSet

10 years agoterm: update example to be right (thanks @SiegeLord)
Corey Richardson [Sat, 17 May 2014 18:53:38 +0000 (11:53 -0700)]
term: update example to be right (thanks @SiegeLord)

10 years agoauto merge of #14253 : alexcrichton/rust/issue-14221, r=pcwalton
bors [Sat, 17 May 2014 12:06:27 +0000 (05:06 -0700)]
auto merge of #14253 : alexcrichton/rust/issue-14221, r=pcwalton

This plugs a leak where resolve was treating enums defined in parent modules as
in-scope for all children modules when resolving a pattern identifier. This
eliminates the code path in resolve entirely.

If this breaks any existing code, then it indicates that the variants need to be
explicitly imported into the module.

Closes #14221

10 years agoauto merge of #14247 : Ryman/rust/minor_ptr_nit, r=alexcrichton
bors [Sat, 17 May 2014 09:41:20 +0000 (02:41 -0700)]
auto merge of #14247 : Ryman/rust/minor_ptr_nit, r=alexcrichton

Not too hot on the second change, welcome a better suggestion/wording.

10 years agosyntax: Tighten search paths for inner modules
Alex Crichton [Fri, 16 May 2014 21:23:04 +0000 (14:23 -0700)]
syntax: Tighten search paths for inner modules

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]

10 years agoauto merge of #14239 : alexcrichton/rust/issue-14225, r=huonw
bors [Sat, 17 May 2014 08:01:22 +0000 (01:01 -0700)]
auto merge of #14239 : alexcrichton/rust/issue-14225, r=huonw

These are taken care of with compiler errors later on, no need to spam with
extra unformatted information unconditionally.

Closes #14225

10 years agoauto merge of #14224 : michaelwoerister/rust/simd-update, r=alexcrichton
bors [Sat, 17 May 2014 06:16:22 +0000 (23:16 -0700)]
auto merge of #14224 : michaelwoerister/rust/simd-update, r=alexcrichton

This is a small change that improves the DWARF description of SIMD types by exposing their type name to debuginfo.

10 years agoauto merge of #14236 : alexcrichton/rust/issue-14082, r=brson
bors [Sat, 17 May 2014 04:36:23 +0000 (21:36 -0700)]
auto merge of #14236 : alexcrichton/rust/issue-14082, r=brson

The reexport didn't switch the privacy, so the reexport was actually considered
private, erroneously failing to resolve imports later on.

Closes #14082

10 years agoauto merge of #14257 : alexcrichton/rust/fix-snap, r=huonw
bors [Sat, 17 May 2014 02:21:26 +0000 (19:21 -0700)]
auto merge of #14257 : alexcrichton/rust/fix-snap, r=huonw

This is blocking a snapshot because apparently the test fails on the bots.

10 years agoterm: Don't run the code example, just compile it
Alex Crichton [Sat, 17 May 2014 01:45:59 +0000 (18:45 -0700)]
term: Don't run the code example, just compile it

This is blocking a snapshot because apparently the test fails on the bots.

10 years agoauto merge of #14216 : kballard/rust/macos_precise_time_ns, r=alexcrichton
bors [Fri, 16 May 2014 23:31:24 +0000 (16:31 -0700)]
auto merge of #14216 : kballard/rust/macos_precise_time_ns, r=alexcrichton

Use sync::one::Once to fetch the mach_timebase_info only once when
running precise_time_ns(). This helps because mach_timebase_info() is
surprisingly inefficient. Also fix the order of operations when applying
the timebase to the mach absolute time value.

This improves the time on my machine from

```
test tests::bench_precise_time_ns ... bench:       157 ns/iter (+/- 4)
```

to

```
test tests::bench_precise_time_ns ... bench:        38 ns/iter (+/- 3)
```

and it will get even faster once #14174 lands.

10 years agorustc: Stop leaking enum variants into children
Alex Crichton [Fri, 16 May 2014 22:44:14 +0000 (15:44 -0700)]
rustc: Stop leaking enum variants into children

This plugs a leak where resolve was treating enums defined in parent modules as
in-scope for all children modules when resolving a pattern identifier. This
eliminates the code path in resolve entirely.

If this breaks any existing code, then it indicates that the variants need to be
explicitly imported into the module.

Closes #14221

[breaking-change]

10 years agoauto merge of #14135 : gereeter/rust/two-way-search, r=brson
bors [Fri, 16 May 2014 21:46:24 +0000 (14:46 -0700)]
auto merge of #14135 : gereeter/rust/two-way-search, r=brson

This changes the previously naive string searching algorithm to a two-way search like glibc, which should be faster on average while still maintaining worst case linear time complexity. This fixes #14107. Note that I don't think this should be merged yet, as this is the only approach to speeding up search I've tried - it's worth considering options like Boyer-Moore or adding a bad character shift table to this. However, the benchmarks look quite good so far:

    test str::bench::bench_contains_bad_naive                   ... bench:       290 ns/iter (+/- 12)     from 1309 ns/iter (+/- 36)
    test str::bench::bench_contains_equal                       ... bench:       479 ns/iter (+/- 10)     from  137 ns/iter (+/- 2)
    test str::bench::bench_contains_short_long                  ... bench:      2844 ns/iter (+/- 105)    from 5473 ns/iter (+/- 14)
    test str::bench::bench_contains_short_short                 ... bench:        55 ns/iter (+/- 4)      from   57 ns/iter (+/- 6)

Except for the case specifically designed to be optimal for the naive case (`bench_contains_equal`), this gets as good or better performance as the previous code.

10 years agolibrustc: Separate NullablePointer into RawNullablePointer and StructWrappedNullableP...
Luqman Aden [Fri, 16 May 2014 00:55:23 +0000 (20:55 -0400)]
librustc: Separate NullablePointer into RawNullablePointer and StructWrappedNullablePointer.

10 years agoMake some NullablePointer enums FFI-compatible with the base pointer type.
Luqman Aden [Mon, 12 May 2014 01:56:53 +0000 (21:56 -0400)]
Make some NullablePointer enums FFI-compatible with the base pointer type.

10 years agoOptimize and fix time::precise_time_ns() on macos
Kevin Ballard [Thu, 15 May 2014 00:54:36 +0000 (17:54 -0700)]
Optimize and fix time::precise_time_ns() on macos

Use sync::one::Once to fetch the mach_timebase_info only once when
running precise_time_ns(). This helps because mach_timebase_info() is
surprisingly inefficient. Also fix the order of operations when applying
the timebase to the mach absolute time value.

This improves the time on my machine from

```
test tests::bench_precise_time_ns ... bench:       157 ns/iter (+/- 4)
```

to

```
test tests::bench_precise_time_ns ... bench:        38 ns/iter (+/- 3)
```

and it will get even faster once #14174 lands.

10 years agoauto merge of #14233 : pcwalton/rust/detildestr-morelibs, r=alexcrichton
bors [Fri, 16 May 2014 20:11:23 +0000 (13:11 -0700)]
auto merge of #14233 : pcwalton/rust/detildestr-morelibs, r=alexcrichton

r? @alexcrichton

10 years agoauto merge of #13401 : cmr/rust/docs, r=brson
bors [Fri, 16 May 2014 18:41:30 +0000 (11:41 -0700)]
auto merge of #13401 : cmr/rust/docs, r=brson

Adds docs where previously there were no docs. Also adds windows support to libterm.

10 years agodoc: Remove all uses of `~str` from the documentation.
Patrick Walton [Thu, 15 May 2014 05:09:21 +0000 (22:09 -0700)]
doc: Remove all uses of `~str` from the documentation.

10 years agolibgetopts: Remove all uses of `~str` from `libgetopts`
Patrick Walton [Thu, 15 May 2014 04:39:11 +0000 (21:39 -0700)]
libgetopts: Remove all uses of `~str` from `libgetopts`

10 years agolibserialize: Remove all uses of `~str` from `libserialize`.
Patrick Walton [Thu, 15 May 2014 04:16:44 +0000 (21:16 -0700)]
libserialize: Remove all uses of `~str` from `libserialize`.

Had to make `struct Tm` in `libtime` not serializable for now.

10 years agolibfmt_macros: Remove all uses of `~str` from `libfmt_macros`
Patrick Walton [Thu, 15 May 2014 04:01:21 +0000 (21:01 -0700)]
libfmt_macros: Remove all uses of `~str` from `libfmt_macros`

10 years agolibrustuv: Remove all uses of `~str` from `librustuv`
Patrick Walton [Thu, 15 May 2014 03:55:16 +0000 (20:55 -0700)]
librustuv: Remove all uses of `~str` from `librustuv`

10 years agocompiletest: Remove all uses of `~str` from `compiletest`
Patrick Walton [Thu, 15 May 2014 03:47:24 +0000 (20:47 -0700)]
compiletest: Remove all uses of `~str` from `compiletest`

10 years agoSome fixes
Corey Richardson [Fri, 16 May 2014 17:59:25 +0000 (10:59 -0700)]
Some fixes

10 years agoFix example
Corey Richardson [Mon, 12 May 2014 00:10:03 +0000 (20:10 -0400)]
Fix example

10 years agoFlush before applying console attributes
Corey Richardson [Mon, 12 May 2014 00:08:49 +0000 (20:08 -0400)]
Flush before applying console attributes

10 years agoAdd a bang
Corey Richardson [Thu, 8 May 2014 17:13:57 +0000 (13:13 -0400)]
Add a bang

10 years agoUpdate for Box
Corey Richardson [Wed, 7 May 2014 15:12:04 +0000 (11:12 -0400)]
Update for Box

10 years agoUpdate for master
Corey Richardson [Wed, 7 May 2014 13:45:53 +0000 (09:45 -0400)]
Update for master

10 years agoAdd WinConsole docs
Corey Richardson [Mon, 14 Apr 2014 14:20:24 +0000 (10:20 -0400)]
Add WinConsole docs

10 years agotest: update for term fallout
Corey Richardson [Tue, 8 Apr 2014 16:18:16 +0000 (12:18 -0400)]
test: update for term fallout