Commit graph

27391 commits

Author SHA1 Message Date
Cadence Marseille
5db7f7ed24 Add method Vec<T>::as_mut_ptr() 2014-03-16 17:20:44 -04:00
bors
9e89ffc60e auto merge of #12931 : aochagavia/rust/option-take_unwrap, r=cmr
Using pattern matching instead of is_some + unwrap
2014-03-16 14:11:26 -07:00
Alan Andrade
6b2888aeec getopts missing docs 2014-03-16 14:06:23 -07:00
Davis Silverman
8b6592ef1a Asked if missing (), then asks about an anonymous function. Also added test. 2014-03-16 16:46:02 -04:00
bors
76478492ef auto merge of #12933 : edwardw/rust/fallout, r=huonw
The same test was missed in chan/port renaming PR #12815 and was fixed in #12880:

> This was missed because it is skipped on linux and windows, and the mac bots were moving at the time the PR landed.

It seems the same happened to the liblog PR.
2014-03-16 12:21:26 -07:00
Edward Wang
cdd4f6e65d Fix a test that was missed in the liblog PR 2014-03-16 21:18:17 +08:00
bors
7156ded5bc auto merge of #12924 : Florob/rust/bigint, r=alexcrichton
This is a minor optimization of the bignum module. The improvements mostly come from avoiding allocations and boundary checks. This also switches all of libnum to vec_ng::Vec.
2014-03-16 05:11:18 -07:00
aochagavia
ea8da6ed97 Refactored take_unwrap (libstd/option.rs)
Using pattern matching instead of is_some + unwrap
2014-03-16 12:11:13 +01:00
bors
d73c899383 auto merge of #12929 : sfackler/rust/automatically-derived, r=cmr
This will enable rustdoc to treat them specially.

I also got rid of `std::cmp::cmp2`, which is isomorphic to the `TotalOrd` impl for 2-tuples and never used.
2014-03-16 03:21:21 -07:00
bors
d956975e7d auto merge of #12899 : brson/rust/cleanbacktrace, r=alexcrichton
After `make clean` I'm seeing the build break with

```
cp: cannot stat ‘x86_64-unknown-linux-gnu/rt/libbacktrace/.libs/libbacktrace.a’: No such file or directory
```

Deleteing the libbacktrace dir entirely on clean fixes.
2014-03-16 01:36:21 -07:00
bors
f6fcdbb687 auto merge of #12791 : alexcrichton/rust/liblog, r=brson
The rationale and modifications can be found in the first commit message.

This does make logging a bit more painful to use initially because it involves a feature gate and some `phase` attributes, but I think it may be reasonable to not require the `phase` attribute for loading `macro_rules!` macros because defining them will still be gated.
2014-03-15 23:01:24 -07:00
Alex Crichton
0015cab1fd Test fixes and rebase conflicts
This commit switches over the backtrace infrastructure from piggy-backing off
the RUST_LOG environment variable to using the RUST_BACKTRACE environment
variable (logging is now disabled in libstd).
2014-03-15 22:56:46 -07:00
Steven Fackler
05c73233e4 Tag derived impls with #[automatically_derived]
This will enable rustdoc to treat them specially.
2014-03-15 22:49:41 -07:00
Alex Crichton
17ad504fef rustc: Topographically sort rust dependencies
This commit starts to topographically sort rust dependencies on the linker
command line. The reason for this is that linkers use right-hand libraries to
resolve left-hand libraries symbols, which is especially crucial for us because
we're using --as-needed on linux.
2014-03-15 22:26:36 -07:00
Alex Crichton
0b3df19c6a rustc: Tweak where -lmorestack is on link commands
In removing many fields from the crate map, executables no longer always have an
explicit dependency on all upstream libraries. This means that the linker is no
longer picking them up as it used to.

To the best of my knowledge, the current situation is happening:

* On linux, we're passing the --as-needed flag to the linker, meaning that
  libraries are stripped out if there are no references to symbols in them.
* Executables may not reference libstd at all, such as "fn main() {}"
* When linking, the linker will discard libstd because there are no references
  to symbols in it. I presume that this means that all previous libs have had
  all their symbols resolved, so none of the libs are pulling in libstd as a
  dependency.
* The only real dependence on libstd comes from the rust_stack_exhausted symbol
  (which comes from libmorestack), but -lmorestack is at the end so by the time
  this comes up libstd is completely gone, leading to undefined references to
  rust_stack_exhausted

I'm not entirely convinced that this is what's happening, but it appears to be
along these lines. The one thing that I'm sure of is that removing the crate map
(and hence implicit dependency on all upstream libraries) has changed how
objects depend on upstream libraries.
2014-03-15 22:26:36 -07:00
Alex Crichton
a921dc4873 rustc: Remove compiler support for __log_level()
This commit removes all internal support for the previously used __log_level()
expression. The logging subsystem was previously modified to not rely on this
magical expression. This also removes the only other function to use the
module_data map in trans, decl_gc_metadata. It appears that this is an ancient
function from a GC only used long ago.

This does not remove the crate map entirely, as libgreen still uses it to hook
in to the event loop provided by libgreen.
2014-03-15 22:26:36 -07:00
Alex Crichton
cc6ec8df95 log: Introduce liblog, the old std::logging
This commit moves all logging out of the standard library into an external
crate. This crate is the new crate which is responsible for all logging macros
and logging implementation. A few reasons for this change are:

* The crate map has always been a bit of a code smell among rust programs. It
  has difficulty being loaded on almost all platforms, and it's used almost
  exclusively for logging and only logging. Removing the crate map is one of the
  end goals of this movement.

* The compiler has a fair bit of special support for logging. It has the
  __log_level() expression as well as generating a global word per module
  specifying the log level. This is unfairly favoring the built-in logging
  system, and is much better done purely in libraries instead of the compiler
  itself.

* Initialization of logging is much easier to do if there is no reliance on a
  magical crate map being available to set module log levels.

* If the logging library can be written outside of the standard library, there's
  no reason that it shouldn't be. It's likely that we're not going to build the
  highest quality logging library of all time, so third-party libraries should
  be able to provide just as high-quality logging systems as the default one
  provided in the rust distribution.

With a migration such as this, the change does not come for free. There are some
subtle changes in the behavior of liblog vs the previous logging macros:

* The core change of this migration is that there is no longer a physical
  log-level per module. This concept is still emulated (it is quite useful), but
  there is now only a global log level, not a local one. This global log level
  is a reflection of the maximum of all log levels specified. The previously
  generated logging code looked like:

    if specified_level <= __module_log_level() {
        println!(...)
    }

  The newly generated code looks like:

    if specified_level <= ::log::LOG_LEVEL {
        if ::log::module_enabled(module_path!()) {
            println!(...)
        }
    }

  Notably, the first layer of checking is still intended to be "super fast" in
  that it's just a load of a global word and a compare. The second layer of
  checking is executed to determine if the current module does indeed have
  logging turned on.

  This means that if any module has a debug log level turned on, all modules
  with debug log levels get a little bit slower (they all do more expensive
  dynamic checks to determine if they're turned on or not).

  Semantically, this migration brings no change in this respect, but
  runtime-wise, this will have a perf impact on some code.

* A `RUST_LOG=::help` directive will no longer print out a list of all modules
  that can be logged. This is because the crate map will no longer specify the
  log levels of all modules, so the list of modules is not known. Additionally,
  warnings can no longer be provided if a malformed logging directive was
  supplied.

The new "hello world" for logging looks like:

    #[phase(syntax, link)]
    extern crate log;

    fn main() {
        debug!("Hello, world!");
    }
2014-03-15 22:26:36 -07:00
bors
abd844e4df auto merge of #12927 : sfackler/rust/test-warn, r=huonw
The use of `std::os::args` creates a deprecated_owned_vector warning
with a bogus span.
2014-03-15 21:16:29 -07:00
Steven Fackler
2c372201d4 Remove std::cmp::cmp2.
It isn't used anywhere and `cmp2(a, b, c, d)` is identical to
`(a, b).cmp(&(c, d))`.
2014-03-15 21:04:56 -07:00
Steven Fackler
2a35c08501 Squash test ~[] warning
The use of `std::os::args` creates a deprecated_owned_vector warning
with a bogus span.
2014-03-15 20:03:29 -07:00
bors
e49c30a89a auto merge of #12923 : sfackler/rust/vecify, r=brson 2014-03-15 19:26:31 -07:00
bors
de78d7f56c auto merge of #12922 : luqmana/rust/fix-arm, r=alexcrichton 2014-03-15 17:51:35 -07:00
Brian Anderson
94078f750a mk: Clean libbacktrace w/ gusto
After `make clean' I'm seeing the build break with

```
cp: cannot stat ‘x86_64-unknown-linux-gnu/rt/libbacktrace/.libs/libbacktrace.a’: No such file or directory
```

Deleteing the libbacktrace dir entirely on clean fixes.
2014-03-15 17:48:04 -07:00
bors
4444f49f63 auto merge of #12921 : alexcrichton/rust/no-extra, r=sfackler
Forgot to remove this as part of the previous removal of libextra
2014-03-15 16:11:32 -07:00
Florian Zeitz
ce2ce2410f num: Migrate ~[T] to std::vec_ng::Vec 2014-03-16 00:01:49 +01:00
Florian Zeitz
f496ab6a6f num: Slightly optimize bigint 2014-03-16 00:01:49 +01:00
Luqman Aden
15b962a9b9 libstd: Fix a typo. s/target_os/target_arch/ 2014-03-15 18:45:26 -04:00
Steven Fackler
a37ca8ce38 Remove ~[] from libsemver 2014-03-15 15:41:51 -07:00
Alex Crichton
cdd8d4854e doc: Remove reference to the 'extra' library
Forgot to remove this as part of the previous removal of libextra
2014-03-15 15:37:16 -07:00
Steven Fackler
b1f523525a Remove most ~[] usage in liburl 2014-03-15 15:13:00 -07:00
bors
5cd17b8150 auto merge of #12918 : sfackler/rust/doc-html-attr, r=alexcrichton 2014-03-15 14:31:38 -07:00
Steven Fackler
9106c15ffd Add rustdoc html crate info 2014-03-15 14:26:12 -07:00
bors
352c5e7eb7 auto merge of #12908 : alexcrichton/rust/issue-12897, r=thestinger
This is mostly just an implementation detail, and anyone worried about the stack
bounds doesn't need to be bothered with the red zone because it's not usable
anyway.

Closes #12897
2014-03-15 02:21:26 -07:00
bors
1d828eb3a4 auto merge of #12906 : sfackler/rust/timespec-total, r=thestinger 2014-03-15 00:46:28 -07:00
bors
fc7a112808 auto merge of #12896 : alexcrichton/rust/goodbye-extra, r=brson
This commit shreds all remnants of libextra from the compiler and standard
distribution. Two modules, c_vec/tempfile, were moved into libstd after some
cleanup, and the other modules were moved to separate crates as seen fit.

Closes #8784
Closes #12413
Closes #12576
2014-03-14 23:11:31 -07:00
Alex Crichton
bf67783332 green: Don't return the red zone in stack_bounds()
This is mostly just an implementation detail, and anyone worried about the stack
bounds doesn't need to be bothered with the red zone because it's not usable
anyway.

Closes #12897
2014-03-14 22:46:13 -07:00
Steven Fackler
8e53d61afe Implement TotalEq and TotalOrd for Timespec
There's a test making sure that Ord works, so the order dependence
shouldn't be an issue
2014-03-14 21:57:47 -07:00
bors
2682c47dfb auto merge of #12895 : michaelwoerister/rust/limited-debuginfo, r=alexcrichton
Very minor modification of just one test case. Fixes #12787.
2014-03-14 21:36:26 -07:00
bors
1218f6db77 auto merge of #12887 : huonw/rust/danger-guide, r=alexcrichton
docs: begin a "low-level & unsafe code" guide.

This aims to cover the basics of writing safe unsafe code. At the moment
it is just designed to be a better place for the `asm!()` docs than the
detailed release notes wiki page, and I took the time to write up some
other things.

More examples are needed, especially of things that can subtly go wrong;
and vast areas of `unsafe`-ty aren't covered, e.g. `static mut`s and
thread-safety in general.
2014-03-14 20:01:32 -07:00
Huon Wilson
3d6c28acd0 docs: begin a "low-level & unsafe code" guide.
This aims to cover the basics of writing safe unsafe code. At the moment
it is just designed to be a better place for the `asm!()` docs than the
detailed release notes wiki page, and I took the time to write up some
other things.

More examples are needed, especially of things that can subtly go wrong;
and vast areas of `unsafe`-ty aren't covered, e.g. `static mut`s and
thread-safety in general.
2014-03-15 13:51:53 +11:00
bors
58fb492f9c auto merge of #12893 : alexcrichton/rust/cfg-not, r=luqmana
The two commits have the details of the two fixes
2014-03-14 18:26:30 -07:00
bors
76e0e26603 auto merge of #12888 : aochagavia/rust/Fix-comment, r=alexcrichton
The old comment of as_mut_slice() did not describe the function correctly. The new one does.

Also refactored option::iter() and option::mut_iter() to use as_ref() and as_mut() instead of match.
2014-03-14 16:51:26 -07:00
bors
26fdfa124c auto merge of #12878 : crabtw/rust/mips, r=alexcrichton
I ignored AtomicU64 methods on MIPS target
because libgcc doesn't implement MIPS32 64-bit atomic operations.
Otherwise it would cause link failure.

By the way, the patched LLVM doesn't have MIPS split stack anymore.
Should I file an issue about that?
2014-03-14 15:16:31 -07:00
Alex Crichton
58e4ab2b33 extra: Put the nail in the coffin, delete libextra
This commit shreds all remnants of libextra from the compiler and standard
distribution. Two modules, c_vec/tempfile, were moved into libstd after some
cleanup, and the other modules were moved to separate crates as seen fit.

Closes #8784
Closes #12413
Closes #12576
2014-03-14 13:59:02 -07:00
bors
42fc32f293 auto merge of #12869 : thestinger/rust/cmp, r=brson
The `Float` trait provides correct `min` and `max` methods on floating
point types, providing a consistent result regardless of the order the
parameters are passed.

These generic functions do not take the necessary performance hit to
correctly support a partial order, so the true requirement should be
given as a type bound.

Closes #12712
2014-03-14 13:41:36 -07:00
Daniel Micay
4e1c2158f2 cmp: switch min and max to TotalOrd
The `Float` trait provides correct `min` and `max` methods on floating
point types, providing a consistent result regardless of the order the
parameters are passed.

These generic functions do not take the necessary performance hit to
correctly support a partial order, so the true requirement should be
given as a type bound.

Closes #12712
2014-03-14 15:26:05 -04:00
Michael Woerister
de03900464 debuginfo: Make limited-debuginfo test case more robust against GDB output variations.
Fixes issue #12787.
2014-03-14 19:11:02 +01:00
Alex Crichton
8e5ca4b793 std: Fix backtraces on arm linux
On android, libgcc is missing the _Unwind_GetIP symbol because it's defined as a
macro. This is the same case for arm linux, so this commit adds the necessary
cfgs in place to use the "expanded macro" in rust for arm linux.
2014-03-14 10:34:29 -07:00
Alex Crichton
770b6e2fc2 rustc: Fix cfg(not(a, b)) to be not(a && b)
Previously, the cfg attribute `cfg(not(a, b))` was translated to `(!a && !b)`,
but this isn't very useful because that can already be expressed as
`cfg(not(a), not(b))`. This commit changes the translation to `!(a && b)` which
is more symmetrical of the rest of the `cfg` attribute.

Put another way, I would expect `cfg(clause)` to be the opposite of
`cfg(not(clause))`, but this is not currently the case with multiple element
clauses.
2014-03-14 10:32:22 -07:00
aochagavia
a7d3637f67 Refactored iter and mut_iter
Replaced match by self.as_ref() and self.as_mut()
2014-03-14 17:29:47 +01:00