Commit graph

39823 commits

Author SHA1 Message Date
Nick Cameron
1fd38c181a Reviewer changes 2015-03-16 17:01:12 +13:00
Nick Cameron
2df1ceb001 resolve: factor out resolve imports to its own module 2015-03-16 11:03:54 +13:00
Nick Cameron
432011d143 Fallout in testing. 2015-03-16 11:03:54 +13:00
Nick Cameron
170ccd615f Error if pub use references a private item.
[breaking-change]

Closes #23266
2015-03-16 11:03:54 +13:00
Nick Cameron
73afbef3aa Misc tidy ups in resolve 2015-03-16 11:03:54 +13:00
bors
542e2bb391 Auto merge of #23353 - alexcrichton:stabilize-os, r=aturon
This commit starts to organize the `std::os::$platform` modules and in the
process stabilizes some of the functionality contained within. The organization
of these modules will reflect the organization of the standard library itself
with extension traits for primitives in the same corresponding module.

The OS-specific modules will grow more functionality over time including
concrete types that are not extending functionality of other structures, and
these will either go into the closest module in `std::os::$platform` or they
will grow a new module in the hierarchy.

The following items are now stable:

* `os::{unix, windows}`
* `unix::ffi`
* `unix::ffi::OsStrExt`
* `unix::ffi::OsStrExt::{from_bytes, as_bytes, to_cstring}`
* `unix::ffi::OsString`
* `unix::ffi::OsStringExt::{from_vec, into_vec}`
* `unix::process`
* `unix::process::CommandExt`
* `unix::process::CommandExt::{uid, gid}`
* `unix::process::ExitStatusExt`
* `unix::process::ExitStatusExt::signal`
* `unix::prelude`
* `windows::ffi`
* `windows::ffi::OsStringExt`
* `windows::ffi::OsStringExt::from_wide`
* `windows::ffi::OsStrExt`
* `windows::ffi::OsStrExt::encode_wide`
* `windows::prelude`

The following items remain unstable:

* `unix::io`
* `unix::io::{Fd, AsRawFd}`
* `unix::fs::{PermissionsExt, OpenOptionsExt}`
* `windows::io`
* `windows::io::{Handle, AsRawHandle}`
* `windows::io::{Socket, AsRawSocket}`
* `windows::fs`
* `windows::fs::OpenOptionsExt`

Due to the reorgnization of the platform extension modules, this commit is a
breaking change. Most imports can be fixed by adding the relevant libstd module
in the `use` path (such as `ffi` or `fs`).

[breaking-change]
2015-03-15 18:42:54 +00:00
Alex Crichton
1f5f76adc3 std: Stabilize portions of std::os::$platform
This commit starts to organize the `std::os::$platform` modules and in the
process stabilizes some of the functionality contained within. The organization
of these modules will reflect the organization of the standard library itself
with extension traits for primitives in the same corresponding module.

The OS-specific modules will grow more functionality over time including
concrete types that are not extending functionality of other structures, and
these will either go into the closest module in `std::os::$platform` or they
will grow a new module in the hierarchy.

The following items are now stable:

* `os::{unix, windows}`
* `unix::ffi`
* `unix::ffi::OsStrExt`
* `unix::ffi::OsStrExt::{from_bytes, as_bytes, to_cstring}`
* `unix::ffi::OsString`
* `unix::ffi::OsStringExt::{from_vec, into_vec}`
* `unix::process`
* `unix::process::CommandExt`
* `unix::process::CommandExt::{uid, gid}`
* `unix::process::ExitStatusExt`
* `unix::process::ExitStatusExt::signal`
* `unix::prelude`
* `windows::ffi`
* `windows::ffi::OsStringExt`
* `windows::ffi::OsStringExt::from_wide`
* `windows::ffi::OsStrExt`
* `windows::ffi::OsStrExt::encode_wide`
* `windows::prelude`

The following items remain unstable:

* `unix::io`
* `unix::io::{Fd, AsRawFd}`
* `unix::fs::{PermissionsExt, OpenOptionsExt}`
* `windows::io`
* `windows::io::{Handle, AsRawHandle}`
* `windows::io::{Socket, AsRawSocket}`
* `windows::fs`
* `windows::fs::OpenOptionsExt`

Due to the reorgnization of the platform extension modules, this commit is a
breaking change. Most imports can be fixed by adding the relevant libstd module
in the `use` path (such as `ffi` or `fs`).

[breaking-change]
2015-03-15 10:28:34 -07:00
bors
b4f5e78b46 Auto merge of #23387 - Manishearth:rollup, r=Manishearth
- Successful merges: #23375, #23379, #23382, #23384
- Failed merges:
2015-03-15 16:06:04 +00:00
bors
95018eec69 Auto merge of #23372 - tamird:fix-ios-compilation, r=alexcrichton
r? @alexcrichton cc @vhbit
2015-03-15 13:32:21 +00:00
Manish Goregaokar
9f1240b665 Rollup merge of #23384 - daboross:patch-2, r=alexcrichton
This changed `an String` to `a String`. Very minor change!

The usage of `an String` was introduced in a828e79480 (diff-b596503c7c33ce457b6d047e351ac12bR423), which changed `an OsString` to `an String`.
2015-03-15 15:40:18 +05:30
Manish Goregaokar
9d8bafe742 Rollup merge of #23382 - FuGangqiang:typos, r=alexcrichton 2015-03-15 15:40:18 +05:30
Manish Goregaokar
f31d818739 Rollup merge of #23379 - kballard:tweak-stdio-docs-no-raw-constructors, r=alexcrichton
`std::io` does not currently expose the `stdin_raw`, `stdout_raw`, or
`stderr_raw` functions. According to the current plans for stdio (see
rust-lang/rfcs#517), raw access will likely be provided using the
platform-specific `std::os::{unix,windows}` modules. At the moment we
don't expose any way to do this. As such, delete all mention of the
`*_raw` functions from the `stdin`/`stdout`/`stderr` function
documentation.

While we're at it, remove a few `pub`s from items that aren't exposed.
This is done just to lessen the confusion experienced by anyone who
looks at the source in an attempt to find the `*_raw` functions.
2015-03-15 15:40:18 +05:30
Manish Goregaokar
3ebe24920b Rollup merge of #23375 - kballard:remove-old_io-recommendation-from-io, r=huonw
Now that `old_io` is deprecated and `std::io` is stable, we should stop
recommending the use of `old_io` in the module documentation.
2015-03-15 15:40:18 +05:30
bors
54660fc392 Auto merge of #23316 - alexcrichton:less-question-sized, r=aturon
It is a frequent pattern among I/O functions to take `P: AsPath + ?Sized` or
`AsOsStr` instead of `AsPath`. Most of these functions do not need to take
ownership of their argument, but for libraries in general it's much more
ergonomic to not deal with `?Sized` at all and simply require an argument `P`
instead of `&P`.

This change is aimed at removing unsightly `?Sized` bounds while retaining the
same level of usability as before. All affected functions now take ownership of
their arguments instead of taking them by reference, but due to the forwarding
implementations of `AsOsStr` and `AsPath` all code should continue to work as it
did before.

This is strictly speaking a breaking change due to the signatures of these
functions changing, but normal idiomatic usage of these APIs should not break in
practice.

[breaking-change]
2015-03-15 09:18:42 +00:00
Tamir Duberstein
04c947c13a Implement winsize() for {ios,dragonfly}
`sys/ttycom.h` in both:
`#define TIOCGWINSZ  _IOR('t', 104, struct winsize)  /* get window size */`
2015-03-15 01:29:13 -07:00
Tamir Duberstein
0b01a9bb4b Fallout of c933d44f7b 2015-03-15 01:29:12 -07:00
Dabo Ross
fe9bb26e78 Fix an String -> a String in env.rs documentation
Super minor change!

The `an String` was introduced in a828e79480 (diff-b596503c7c33ce457b6d047e351ac12bR423), which changed `an OsString` to `an String`.
2015-03-15 00:00:26 -07:00
Alex Crichton
60a4a2db88 std: Remove ?Sized bounds from many I/O functions
It is a frequent pattern among I/O functions to take `P: AsPath + ?Sized` or
`AsOsStr` instead of `AsPath`. Most of these functions do not need to take
ownership of their argument, but for libraries in general it's much more
ergonomic to not deal with `?Sized` at all and simply require an argument `P`
instead of `&P`.

This change is aimed at removing unsightly `?Sized` bounds while retaining the
same level of usability as before. All affected functions now take ownership of
their arguments instead of taking them by reference, but due to the forwarding
implementations of `AsOsStr` and `AsPath` all code should continue to work as it
did before.

This is strictly speaking a breaking change due to the signatures of these
functions changing, but normal idiomatic usage of these APIs should not break in
practice.

[breaking-change]
2015-03-14 23:23:54 -07:00
FuGangqiang
3be8380576 fix typos 2015-03-15 13:47:34 +08:00
bors
f59af75bd8 Auto merge of #23381 - Manishearth:rollup, r=Manishearth
r? @Manishearth
2015-03-15 05:42:41 +00:00
Manish Goregaokar
d66d0b3ac2 Rollup merge of #23368 - EduardoBautista:fix-closures-chapter, r=steveklabnik
"body": null,
2015-03-15 10:23:45 +05:30
Manish Goregaokar
09e5a7a04e Rollup merge of #23367 - EduardoBautista:fix-indentation-in-book, r=steveklabnik
It was using tabs.
2015-03-15 10:23:45 +05:30
Manish Goregaokar
34ce376140 Rollup merge of #23365 - dotdash:array_loop_panic, r=eddyb
[expr; 0] currently exhibits inconsistent behaviour and [expr; n] with n > 1 triggers an LLVM assertion in case that \"expr\" diverges.
2015-03-15 10:23:44 +05:30
Manish Goregaokar
911f7fec81 Rollup merge of #23363 - meqif:master, r=alexcrichton
There was a minor typo in the book's concurrency section (\"recieve\" instead of \"receive\").
2015-03-15 10:23:43 +05:30
Manish Goregaokar
4be0eaeb48 Rollup merge of #23362 - dotdash:llvm_req, r=alexcrichton
LLVM older that 3.6 has a bug that cause assertions when compiling certain
constructs. For 3.5 there's still a chance that the bug might get fixed
in 3.5.2, so let's keep allowing to compile with it for it for now.
2015-03-15 10:23:42 +05:30
Manish Goregaokar
6af2721466 Rollup merge of #23358 - rprichard:reject-empty-L, r=alexcrichton
This change closes #23303 by rejecting an empty search path.
2015-03-15 10:23:42 +05:30
Manish Goregaokar
7eb9c3765f Rollup merge of #23356 - bombless:camelcase, r=alexcrichton
non_camel_case_types lint suggests `ONETWOTHREE` for non-camel type `ONE_TWO_THREE`, which doesn't look good.
This patch fixes it.
2015-03-15 10:23:41 +05:30
Manish Goregaokar
01f10dead3 Rollup merge of #23351 - nagisa:rustdoc-lines-2, r=alexcrichton
Previously it would fail on a trivial case like

    /// Summary line
    /// <trailing space>
    /// Regular content

Compliant markdown preprocessor would render that as two separate paragraphs, but our summary line
extractor interprets both lines as the same paragraph and includes both into the short summary resulting in
![screenshot from 2015-03-13 22 47 08](https://cloud.githubusercontent.com/assets/679122/6648596/7ef792b2-c9e4-11e4-9c19-704c288ec4de.png)
2015-03-15 10:23:40 +05:30
bors
66853af9af Auto merge of #23351 - nagisa:rustdoc-lines-2, r=alexcrichton
Previously it would fail on a trivial case like

    /// Summary line
    /// <trailing space>
    /// Regular content

Compliant markdown preprocessor would render that as two separate paragraphs, but our summary line
extractor interprets both lines as the same paragraph and includes both into the short summary resulting in
![screenshot from 2015-03-13 22 47 08](https://cloud.githubusercontent.com/assets/679122/6648596/7ef792b2-c9e4-11e4-9c19-704c288ec4de.png)
2015-03-15 03:11:14 +00:00
Kevin Ballard
3453b5b4a8 Remove incorrect references to _raw stdio functions
std::io does not currently expose the stdin_raw, stdout_raw, or
stderr_raw functions. According to the current plans for stdio (see RFC
#517), raw access will likely be provided using the platform-specific
std::os::{unix,windows} modules. At the moment we don't expose any way
to do this. As such, delete all mention of the _raw functions from the
stdin/stdout/stderr function documentation.

While we're at it, remove a few `pub`s from items that aren't exposed.
This is done just to lessen the confusion experienced by anyone who
looks at the source in an attempt to find the _raw functions.
2015-03-14 18:08:09 -07:00
bors
8c85a9d20f Auto merge of #23313 - barosl:match-specialize-ice, r=jakub-
The arity of `ref x` is always 1, so it needs to be dereferenced before being compared with some other type whose arity is not 1.

Fixes #23009.
2015-03-15 00:39:54 +00:00
Kevin Ballard
3dd455d4e1 Stop recommending old_io in the module doc for std::io
Now that `old_io` is deprecated and `std::io` is stable, we should stop
recommending the use of `old_io` in the module documentation.
2015-03-14 17:36:36 -07:00
bors
30e1f9a1c2 Auto merge of #23289 - mihneadb:rustdoc-search-by-type, r=alexcrichton
This adds search by type (for functions/methods) support to Rustdoc. Target issue is at https://github.com/rust-lang/rfcs/issues/658.

I've described my approach here: https://github.com/rust-lang/rfcs/issues/658#issuecomment-76484200. I'll copy the text in here as well:

---

Hi, it took me longer than I wished, but I have implemented this in a not-too-complex way that I think can be extended to support more complex features (like the ones mentioned [here](https://github.com/rust-lang/rust/issues/12866#issuecomment-66945317)).

The idea is to generate a JSON representation of the types of methods/functions in the existing index, and then make the JS understand when it should look by type (and not by name).

I tried to come up with a JSON representation that can be extended to support generics, bounds, ref/mut annotations and so on. Here are a few samples:

Function:

```rust
fn to_uppercase(c: char) -> char
```

```json
{
    "inputs": [
        {"name": "char"}
    ],
    "output": {
        "name": "char",
    }
}
```

Method (implemented or defined in trait):

```rust
// in struct Vec
// self is considered an argument as well
fn capacity(&self) -> usize
```

```json
{
    "inputs": [
        {"name": "vec"}
    ],
    "output": {
        "name": "usize"
    }
}
```

This simple format can be extended by adding more fields, like `generic: bool`, a `bounds` mapping and so on.

I have a working implementation in https://github.com/rust-lang/rust/compare/master...mihneadb:rustdoc-search-by-type. You can check out a live demo [here](http://data.mihneadb.net/doc/std/index.html?search=charext%20-%3E%20char).

![screenshot from 2015-02-28 00 54 00](https://cloud.githubusercontent.com/assets/643127/6422722/7e5374ee-bee4-11e4-99a6-9aac3c9d5068.png)


The feature list is not that long:
- search by types (you *can* use generics as well, as long as you use the exact name - e.g. [`vec,t -> `](http://data.mihneadb.net/doc/std/index.html?search=vec%2C%20t%20-%3E))
- order of arguments does not matter
- `self` is took into account as well (e.g. search for `vec -> usize`)
- does not use "complex" annotations (e.g. you don't search for `&char -> char` but for `char -> char`)

My goal is to get a working, minimal "base" merged so that others can build upon it. How should I proceed? Do I open a PR (badly in need of code review since this is my first non "hello world"-ish rust code)?

---
2015-03-14 22:07:25 +00:00
Eduardo Bautista
7130c75e46 Concurrency is now in the "Concurrency" chapter 2015-03-14 14:05:59 -06:00
Eduardo Bautista
c8e4f61ad3 Fix indentation in the "Method Syntax" chapter 2015-03-14 13:27:44 -06:00
Mihnea Dobrescu-Balaur
7b7b938be1 Add support to search functions by type to rustdoc. 2015-03-14 20:45:27 +02:00
bors
3400c9ed9f Auto merge of #23357 - Manishearth:oops, r=Manishearth
Oops, merged #21468 by accident.
2015-03-14 16:59:06 +00:00
Barosl Lee
edbc0e509f check_match: Dereference ref x before comparing it and some other type
The arity of `ref x` is always 1, so it needs to be dereferenced before
being compared with some other type whose arity is not 1.

Fixes #23009.
2015-03-14 23:32:57 +09:00
Björn Steinbrink
9eed8ea644 Fix broken codegen for [expr; n] where "expr" diverges 2015-03-14 14:23:43 +01:00
Björn Steinbrink
3a8f989dbb Always evaluate the expression in [expr; n]
In case that there is a destination for the array, like in
"let x = [expr; n]", we currently don't evaluate the given expression if
n is zero. That's inconsistent with all other cases, including "[expr;
0]" without a destination.

Fixes #23354
2015-03-14 14:19:29 +01:00
Ricardo Martins
cb02f366dc Fix a typo in the documentation. 2015-03-14 12:42:12 +00:00
Björn Steinbrink
bb18a3cfe7 Drop support for LLVM < 3.5 and fix compile errors with 3.5
LLVM older that 3.6 has a bug that cause assertions when compiling certain
constructs. For 3.5 there's still a chance that the bug might get fixed
in 3.5.2, so let's keep allowing to compile with it for it for now.
2015-03-14 13:14:04 +01:00
Simonas Kazlauskas
b09e5daa89 Split rustdoc summary lines in a smarter way
Previously it would fail on a trivial case like

    /// Summary line
    /// <trailing space>
    /// Regular content

Compliant markdown preprocessor would render that as two separate paragraphs, but our summary line
extractor would interpret both lines as the same paragraph and include both into the short summary.
2015-03-14 13:00:19 +02:00
bors
766a4e1acc Auto merge of #23333 - oli-obk:slice_from_raw_parts, r=alexcrichton
at least that's what the docs say: http://doc.rust-lang.org/std/slice/fn.from_raw_parts.html

A few situations got prettier. In some situations the mutability of the resulting and source pointers differed (and was cast away by transmute), the mutability matches now.
2015-03-14 08:55:31 +00:00
Ryan Prichard
85b084f4bd Reject -L "", -L native=, and other empty search paths.
It wasn't clear to me that early_error was correct here, but it seems to
work. This code is reachable from `rustdoc`, which is problematic, because
early_error panics. rustc handles the panics gracefully (without ICEing or
crashing), but rustdoc does not. It's not the first such rustdoc problem,
though:

    $ rustdoc hello.rs --extern std=bad-std
    error: extern location for std does not exist: bad-std
    hello.rs:1:1: 1:1 error: can't find crate for `std`
    hello.rs:1
           ^
    error: aborting due to 2 previous errors
    thread '<unnamed>' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:151
    thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "rustc failed"', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/result.rs:744
    thread '<main>' panicked at 'child thread None panicked', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thread.rs:661
2015-03-13 23:49:44 -07:00
Manish Goregaokar
c908d1c1f9 Revert "Extend dead code lint to detect more unused enum variants"
This reverts commit b042ffc4a7.

Conflicts:
	src/librustc/middle/pat_util.rs
2015-03-14 12:14:32 +05:30
Manish Goregaokar
82bcc55232 Revert "Remove dead code flagged by lint"
This reverts commit bce7a6f4a9.
2015-03-14 12:14:03 +05:30
York Xiang
60aa751620 Improve camelcase suggestion 2015-03-14 13:40:33 +08:00
bors
f7453f940b Auto merge of #22948 - rprichard:simple-panic-opt, r=alexcrichton
Reduce code size overhead from core::panicking::panic

core::panicking::panic currently creates an Arguments structure using
format_args!("{}", expr), which formats the expr str using the Display::fmt.
Display::fmt pulls in Formatter::pad, which then also pulls in string-related
code for truncation and padding.

If core::panicking::panic instead creates an Arguments structure with a string
piece, it is possible that the Display::fmt function for str can be optimized
out of the program.

In my testing with a 32-bit x86 bare metal program, the change tended to save
between ~100 bytes and ~5500 bytes, depending on what other panic* functions
the program invokes and whether the panic_fmt lang item uses the Arguments
value.
2015-03-14 01:04:37 +00:00
Ryan Prichard
00211ecfda Avoid passing -L "" during cross-compilation.
LLVM_LIBDIR_<triple> is only defined for host triples, not target triples.

FWIW, the same is true for LLVM_STDCPP_RUSTFLAGS_<triple>, where we
explicitly define it as empty when --enable-llvm-static-stdcpp is not
specified, but it's still undefined for cross-compiled triples.
2015-03-13 16:46:45 -07:00