Commit Graph

27040 Commits

Author SHA1 Message Date
Alex Crichton
31e7e676e1 rustdoc: Add anchors to section headers
This commit adds a appear-on-over link to all section headers to generated
documentation. Each header also receives an id now, even those generated through
markdown. The purpose of this is to provide easy to link to sections.

This modifies the default header markdown generation because the default id
added looks like "toc_NN" which is difficult to reconcile among all sections (by
default each section gets a "toc_0" id), and it's also not very descriptive of
where you're going.

This chooses to adopt the github-style anchors by taking the contents of the
title and hyphen-separating them (after lower casing).

Closes #12681
2014-03-05 22:51:56 -08:00
bors
253dbcb8c0 auto merge of #12703 : jld/rust/issue-8506, r=alexcrichton
Closes #8506.
2014-03-05 22:11:42 -08:00
Alex Crichton
9668ab58f3 std: Move libnative task count bookkeeping to std
When using tasks in Rust, the expectation is that the runtime does not exit
before all tasks have exited. This is enforced in libgreen through the
`SchedPool` type, and it is enforced in libnative through a `bookkeeping` module
and a global count/mutex pair. Unfortunately, this means that a process which
originates with libgreen will not wait for spawned native tasks.

In order to fix this problem, the bookkeeping module was moved from libnative to
libstd so the runtime itself can wait for native tasks to exit. Green tasks do
not manage themselves through this bookkeeping module, but native tasks will
continue to manage themselves through this module.

Closes #12684
2014-03-05 21:48:08 -08:00
Jed Davis
d90830221e Fix ICE on statics with fancy nullable enums.
Closes #8506.

The `trans::adt` code for statics uses fields with `C_undef` values to
insert alignment padding (because LLVM's own alignment padding isn't
always sufficient for aggregate constants), and assumes that all fields
in the actual Rust value are represented by non-undef LLVM values, to
distinguish them from that padding.

But for nullable pointer enums, if non-null variant has fields other
than the pointer used as the discriminant, they would be set to undef in
the null case, to reflect that they're never accessed.

To avoid the obvious conflict between these two items, the latter undefs
were wrapped in unary LLVM structs to distinguish them from the former
undefs.  Except this doesn't actually work -- LLVM, not unreasonably,
treats the "wrapped undef" as a regular undef.

So this commit just sets all fields to null in the null pointer case of
a nullable pointer enum static, because the other fields don't really
need to be undef in the first place.
2014-03-05 21:23:33 -08:00
Alex Crichton
9396452592 rustc: Fix support for LLVM 3.3
The llvm.copysign and llvm.round intrinsics weren't added until LLVM 3.4, so if
we're on LLVM 3.3 we lower these to calls in libm instead of LLVM intrinsics.

This should fix our travis failures.
2014-03-05 18:05:05 -08:00
bors
67c5d793ad auto merge of #12718 : thestinger/rust/min_max, r=alexcrichton 2014-03-05 16:21:43 -08:00
Daniel Micay
a871068b47 stats: fix handling of NaN in min and max
The `cmp::min` and `cmp::max` functions are not correct with partially
ordered values. #12712
2014-03-05 19:20:06 -05:00
Daniel Micay
5973b0c4ad add tests for min and max from Float 2014-03-05 19:20:03 -05:00
bors
ff22e47c19 auto merge of #12715 : dmski/rust/no-extern-fn-pat, r=alexcrichton
Fixes #10877

There was another PR which attempted to fix this in the parser (#11804) and which was closed due to inactivity.
This PR modifies typeck instead (as suggested in #11804), which indeed seems to be simpler than modifying the parser and allows for a better error message.
2014-03-05 12:51:48 -08:00
Dmitry Promsky
53f3442ef7 Disallowed patterns in extern fn declarations.
Closes #10877
2014-03-06 00:01:16 +04:00
bors
8a55cd988f auto merge of #12711 : edwardw/rust/mtwt, r=pcwalton
- Moves mtwt hygiene code into its own file
- Fixes FIXME's which leads to ~2x speed gain in expansion pass
- It is now @-free
2014-03-05 11:11:42 -08:00
bors
db4f757367 auto merge of #12709 : aepsil0n/rust/update_man_version, r=alexcrichton
Just realized that these were quite outdated and quickly fixed it. I have to admit that I did not run the test suite on this one though…
2014-03-05 09:56:44 -08:00
Alex Crichton
e6acff8287 native: Fix usage of a deallocated mutex
When the timer_helper thread exited, it would attempt to re-acquire the global
task count mutex, but the mutex had previously been deallocated, leading to
undefined behavior of the mutex, and in some cases deadlock.

Another mutex is used to coordinate shutting down the timer helper thread.

Closes #12699
2014-03-05 09:11:11 -08:00
Alex Crichton
d8bd8de82e native: Move from usleep() to nanosleep()
Using nanosleep() allows us to gracefully recover from EINTR because on error it
fills in the second parameter with the remaining time to sleep.

Closes #12689
2014-03-05 09:11:10 -08:00
Alex Crichton
8334dd445f native: Stop using readdir()
This function is not threadsafe, and is deprecated in favor of the threadsafe
readdir_r variant.

Closes #12692
2014-03-05 09:11:10 -08:00
bors
a7da925b02 auto merge of #12700 : thestinger/rust/float, r=cmr 2014-03-05 08:38:10 -08:00
Daniel Micay
28d4f80836 consistently use LLVM floating point intrinsics 2014-03-05 11:21:00 -05:00
Daniel Micay
2760974ec0 add correct floating point min and max methods.
The `std::cmp` functions are not correct for floating point types.

`min(NaN, 2.0)` and `min(2.0, NaN)` return different values, because
these functions assume a total order. Floating point types need special
`min`, `max` and `clamp` functions.
2014-03-05 11:20:50 -05:00
Edward Wang
2302ce903d Refactor and fix FIXME's in mtwt hygiene code
- Moves mtwt hygiene code into its own file
- Fixes FIXME's which leads to ~2x speed gain in expansion pass
- It is now @-free
2014-03-05 22:45:51 +08:00
bors
ea71a08f6b auto merge of #12708 : SimonSapin/rust/patch-6, r=huonw
Feel free to reject this if I’m mistaken, but the `count` in the for loop does look like it’s going from 0 to `end`.
2014-03-05 02:51:45 -08:00
Eduard Bopp
a27501112a Update version and date info in man pages
Both for rustc and rustdoc the man pages contained out-of-date version info.
2014-03-05 11:22:58 +01:00
Simon Sapin
c92cdad3dd Str::slice_chars() is O(end), not O(end - begin) 2014-03-05 09:41:35 +00:00
bors
87a31f6f0f auto merge of #12491 : eddyb/rust/deref, r=nikomatsakis
Add the `Deref` and `DerefMut` traits and implement overloading explicit dereferences.
2014-03-04 23:21:42 -08:00
bors
712c630ab6 auto merge of #12300 : DaGenix/rust/uppercase-variable-lint, r=alexcrichton
I added a new lint for variables whose names contain uppercase characters, since, by convention, variable names should be all lowercase. What motivated me to work on this was when I ran into something like the following:

```rust
use std::io::File;
use std::io::IoError;

fn main() {
    let mut f = File::open(&Path::new("/something.txt"));
    let mut buff = [0u8, ..16];
    match f.read(buff) {
        Ok(cnt) => println!("read this many bytes: {}", cnt),
        Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {}", EndOfFile.to_str()),
    }
}
```

I then got compile errors when I tried to add a wildcard match pattern at the end which I found very confusing since I believed that the 2nd match arm was only matching the EndOfFile condition. The problem is that I hadn't imported io::EndOfFile into the local scope. So, I thought that I was using EndOfFile as a sub-pattern, however, what I was actually doing was creating a new local variable named EndOfFile. This lint makes this error easier to spot by providing a warning that the variable name EndOfFile contains a uppercase characters which provides a nice hint as to why the code isn't doing what is intended.

The lint warns on local bindings as well:

```rust
let Hi = 0;
```

And also struct fields:

```rust
struct Something {
    X: uint
}
```
2014-03-04 22:06:38 -08:00
Palmer Cox
258dbd09ba Emit the uppercase variable lint for struct fields that have names with uppercase characters 2014-03-05 00:22:19 -05:00
Palmer Cox
e3723dc4f1 Allow uppercase_variables in libstd/libc.rs 2014-03-05 00:22:09 -05:00
bors
3cc761f3f9 auto merge of #12671 : nick29581/rust/expand, r=sfackler
Fixes a regression from #4913 which causes items to be exanded with spans lacking expn_info from the context's current backtrace.
2014-03-04 19:41:38 -08:00
bors
f1955e028c auto merge of #12688 : alexcrichton/rust/fix-some-link-args, r=brson
Linker argument order with respect to libraries is important enough that we
shouldn't be attempting to filter out libraries getting passed through to the
linker. When linking with a native library that has multiple dependant native
libraries, it's useful to have control over the link argument order.
2014-03-04 18:26:40 -08:00
Palmer Cox
a9798c25df Rename struct fields with uppercase characters in their names to use lowercase 2014-03-04 21:23:37 -05:00
Palmer Cox
935c912335 Add lint for variable names that contain uppercase characters 2014-03-04 21:23:37 -05:00
Palmer Cox
6d9bdf975a Rename all variables that have uppercase characters in their names to use only lowercase characters 2014-03-04 21:23:36 -05:00
Nick Cameron
4a891fe80d Expand nested items within a backtrace.
Fixes a regression from #4913 which causes items to be exanded with spans lacking expn_info from the context's current backtrace.
2014-03-04 18:04:16 -08:00
bors
dcb24f5450 auto merge of #12697 : thestinger/rust/vec, r=huonw
This exists for the sake of compatibility during the ~[T] -> Vec<T>
transition. It will be removed in the future.
2014-03-04 17:11:39 -08:00
Daniel Micay
15adaf6f3e mark the map method on Vec<T> as deprecated
This exists for the sake of compatibility during the ~[T] -> Vec<T>
transition. It will be removed in the future.
2014-03-04 19:37:07 -05:00
bors
fe50c75d02 auto merge of #12694 : thestinger/rust/mut_iter, r=huonw
This become `Pod` when it was switched to using marker types.
2014-03-04 15:56:37 -08:00
Daniel Micay
4d8295df6c make MutItems iterator sound again
This become `Pod` when it was switched to using marker types.
2014-03-04 18:53:57 -05:00
Eduard Burtescu
bcc5486c17 Allow overloading explicit dereferences. 2014-03-05 00:26:51 +02:00
bors
0a5138c752 auto merge of #12667 : Kimundi/rust/any_improv, r=cmr
- Added `TraitObject` representation to `std::raw`.
- Added doc to `std::raw`.
- Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()`
  methods as they are uneccessary now after the removal of
  headers on owned boxes. This reduces the number of virtual calls needed from 2 to 1.
- Made the `..Ext` implementations work directly with the repr of
  a trait object.
- Removed `Any`-related traits from the prelude.
- Added bench.

Bench before/after:
~~~
7 ns/iter (+/- 0)
4 ns/iter (+/- 0)
~~~
2014-03-04 13:16:41 -08:00
Marvin Löbel
3158047a45 Cleaned up std::any
- Added `TraitObject` representation to `std::raw`.
- Added doc to `std::raw`.
- Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()`
  methods as they are uneccessary now after the removal of
  headers on owned boxes. This reduces the number of virtual calls needed.
- Made the `..Ext` implementations work directly with the repr of
  a trait object.
- Removed `Any`-related traits from the prelude.

- Added bench for `Any`
2014-03-04 21:10:23 +01:00
bors
a15448c85a auto merge of #12649 : adrientetar/rust/highlight, r=alexcrichton
[Here is](http://adrientetar.legtux.org/cached/rust-doc/to_str.rs.html) an example.

Closes #12648.

@alexcrichton, @huonw
2014-03-04 12:01:45 -08:00
Adrien Tétar
0106a04d70 doc: use the newer favicon 2014-03-04 18:37:51 +01:00
Adrien Tétar
fd09e91e00 rustdoc: tweak highlighting 2014-03-04 18:37:09 +01:00
Eduard Burtescu
52532d13a6 Implement DerefImm for Rc and DerefImm/DerefMut for RefCell's Ref/RefMut. 2014-03-04 16:41:48 +02:00
Eduard Burtescu
3b125ff3bb Add the DerefImm and DerefMut traits. 2014-03-04 16:41:48 +02:00
bors
19fadf6567 auto merge of #12678 : lifthrasiir/rust/pluralize, r=alexcrichton
While we are not yet ready for compiler i18n, this also keeps the error handling code clean. The set of altered error messages was obtained by grepping for `"s"` and `(s)`, so there might be some missing messages.
2014-03-04 00:31:40 -08:00
Kang Seonghoon
21454452b2 rustc: Streamline error messages for i18n, using plural whenever possible. 2014-03-04 16:41:57 +09:00
bors
dc18659160 auto merge of #12669 : huonw/rust/de-block-arms, r=alexcrichton
syntax: make match arms store the expr directly.

Previously `ast::Arm` was always storing a single `ast::Expr` wrapped in an
`ast::Block` (for historical reasons, AIUI), so we might as just store
that expr directly.

Closes #3085.
2014-03-03 23:16:40 -08:00
bors
062e950ae8 auto merge of #12672 : korenchkin/rust/checked-bigint, r=alexcrichton 2014-03-03 22:01:40 -08:00
bors
3c0d0987be auto merge of #12674 : alexcrichton/rust/snapshots, r=Aatch
This should fix the travis builds.
2014-03-03 18:06:42 -08:00
Alex Crichton
b0e0cb5e32 Register new snapshots
This should fix the travis builds.
2014-03-03 18:00:52 -08:00