Commit Graph

43193 Commits

Author SHA1 Message Date
bors
06c6b3caaf Auto merge of #25743 - michaelsproul:match-diagnostics, r=nrc
Part of #24407.

Currently the diagnostics for range patterns are a bit wrong:

```rust
fn main() {
    match 5u32 {
        0 ... 10 => (),
        'a' ... 10 => (),
        10 ... 'z' => (),
        "what" ... 10 => (),
        "what" ... "well" => (),
        10 ... "what" => ()
    }
}
```

```
range.rs:4:9: 4:19 error: mismatched types in range:
 expected integral variable,
    found char [E0211]
range.rs:4         'a' ... 10 => (),
                   ^~~~~~~~~~
range.rs:4:9: 4:16 error: only char and numeric types are allowed in range [E0029]
range.rs:4         'a' ... 10 => (),
                   ^~~~~~~
range.rs:4:9: 4:19 error: mismatched types:
 expected `u32`,
    found `char`
(expected u32,
    found char) [E0308]
range.rs:4         'a' ... 10 => (),
                   ^~~~~~~~~~
range.rs:5:9: 5:19 error: mismatched types in range:
 expected char,
    found integral variable [E0211]
range.rs:5         10 ... 'z' => (),
                   ^~~~~~~~~~
range.rs:5:9: 5:15 error: only char and numeric types are allowed in range [E0029]
range.rs:5         10 ... 'z' => (),
                   ^~~~~~
range.rs:6:9: 6:22 error: mismatched types in range:
 expected integral variable,
    found &-ptr [E0211]
range.rs:6         "what" ... 10 => (),
                   ^~~~~~~~~~~~~
range.rs:6:9: 6:19 error: only char and numeric types are allowed in range [E0029]
range.rs:6         "what" ... 10 => (),
                   ^~~~~~~~~~
range.rs:6:9: 6:22 error: mismatched types:
 expected `u32`,
    found `&'static str`
(expected u32,
    found &-ptr) [E0308]
range.rs:6         "what" ... 10 => (),
                   ^~~~~~~~~~~~~
range.rs:7:9: 7:19 error: only char and numeric types are allowed in range [E0029]
range.rs:7         "what" ... "well" => (),
                   ^~~~~~~~~~
range.rs:7:9: 7:26 error: mismatched types:
 expected `u32`,
    found `&'static str`
(expected u32,
    found &-ptr) [E0308]
range.rs:7         "what" ... "well" => (),
                   ^~~~~~~~~~~~~~~~~
range.rs:8:9: 8:22 error: mismatched types in range:
 expected &-ptr,
    found integral variable [E0211]
range.rs:8         10 ... "what" => ()
                   ^~~~~~~~~~~~~
range.rs:8:9: 8:15 error: only char and numeric types are allowed in range [E0029]
range.rs:8         10 ... "what" => ()
                   ^~~~~~
error: aborting due to 12 previous errors
```

The problems here are:

1. The type of the end of the range is used to predict the type of the start (only mildly counter intuitive).
2. E0029 is erroneously generated for `char ... num` and `num ... char`.
2. `u32` is mentioned.
3. Errors which are essentially the same are reported multiple times.

I've attempted to fix this by checking the requirements in a different order. The output I've achieved for the above example is:

```
/home/michael/Temp/range.rs:4:17: 4:22 error: mismatched types in range:
 expected char,
    found integral variable [E0211]
/home/michael/Temp/range.rs:4         'a' ... 10 => (),
                                              ^~~~~
/home/michael/Temp/range.rs:5:16: 5:22 error: mismatched types in range:
 expected integral variable,
    found char [E0211]
/home/michael/Temp/range.rs:5         10 ... 'z' => (),
                                             ^~~~~~
/home/michael/Temp/range.rs:6:9: 6:19 error: only char and numeric types are allowed in range [E0029]
/home/michael/Temp/range.rs:6         "what" ... 10 => (),
                                      ^~~~~~~~~~
/home/michael/Temp/range.rs:6:9: 6:19 help: run `rustc --explain E0029` to see a detailed explanation
/home/michael/Temp/range.rs:6:9: 6:19 note: Start type: &'static str
End type: _
/home/michael/Temp/range.rs:6         "what" ... 10 => (),
                                      ^~~~~~~~~~
/home/michael/Temp/range.rs:7:9: 7:26 error: only char and numeric types are allowed in range [E0029]
/home/michael/Temp/range.rs:7         "what" ... "well" => (),
                                      ^~~~~~~~~~~~~~~~~
/home/michael/Temp/range.rs:7:9: 7:26 help: run `rustc --explain E0029` to see a detailed explanation
/home/michael/Temp/range.rs:7:9: 7:26 note: Start type: &'static str
End type: &'static str
/home/michael/Temp/range.rs:7         "what" ... "well" => (),
                                      ^~~~~~~~~~~~~~~~~
/home/michael/Temp/range.rs:8:16: 8:25 error: only char and numeric types are allowed in range [E0029]
/home/michael/Temp/range.rs:8         10 ... "what" => ()
                                             ^~~~~~~~~
/home/michael/Temp/range.rs:8:16: 8:25 help: run `rustc --explain E0029` to see a detailed explanation
/home/michael/Temp/range.rs:8:16: 8:25 note: Start type: _
End type: &'static str
/home/michael/Temp/range.rs:8         10 ... "what" => ()
                                             ^~~~~~~~~
error: aborting due to 5 previous errors
```

I think this is already tonnes better, but the `Start type/End type` stuff could be neater. I don't think there's really any need to start a `note:` block but I wanted to get some feedback on this. I'd also appreciate advice on how to print the integer types as something other than `_`.
2015-06-04 01:02:41 +00:00
bors
fe107b360e Auto merge of #25959 - pnkfelix:fsk-hack-move-val-init, r=nikomatsakis
Hack the move_val_init intrinsic to trans directly into the destination address.

This is to remove an intermediate (and unnecessary) alloca on the stack that one otherwise suffers when using this intrinsic.

This is part of the `box` protocol work; in particular, this is meant to address the `ptr::write` codegen issues alluded to at this comment: 

  https://github.com/rust-lang/rust/pull/22086#issuecomment-96168675

cc #22181
2015-06-03 21:46:21 +00:00
bors
b70f49b86f Auto merge of #24910 - steveklabnik:remove_static_assert, r=alexcrichton
This was always a weird feature, and isn't being used in the compiler.
Static assertions should be done better than this.

Fixes #13951
Fixes #23008
Fixes #6676

This is behind a feature gate, but that's still a

[breaking-change]

(It's not entirely clear to me that this should or shouldn't have an RFC, but if it does, I'm fine blocking on such a thing.)
2015-06-03 18:21:09 +00:00
bors
9a2f68e159 Auto merge of #25966 - pelmers:save-api, r=nrc
Move EnumData into the API, and change a few spots where we use &String[..] when it is equivalent to &String.

r? @nrc
2015-06-03 14:40:37 +00:00
Steve Klabnik
5235065d74 Remove #[static_assert]
This was always a weird feature, and isn't being used in the compiler.
Static assertions should be done better than this.

This implements RFC #1096.

Fixes #13951
Fixes #23008
Fixes #6676

This is behind a feature gate, but that's still a

[breaking-change]
2015-06-03 09:38:13 -04:00
bors
5b56d73dc0 Auto merge of #25984 - Manishearth:rollup, r=Manishearth
- Successful merges: #25939, #25963, #25970, #25971, #25974
- Failed merges:
2015-06-03 09:44:26 +00:00
Manish Goregaokar
e490c17eb5 Rollup merge of #25974 - richo:stack-msg, r=alexcrichton
These are implemented in asm, they're just not inlined.

Open questions are:
* Should I just inline them? They're.. big, but it seems as though this needs violates the #[inline(always)] gaurantees the others make.
* Does something (llvm?) provide these as intrinsics? The structure of this code suggests that we could be hoisting off something else, instead of flagrantly ignoring it like we do for power and mips.
2015-06-03 14:46:41 +05:30
Manish Goregaokar
27dd5e9ce9 Rollup merge of #25971 - richo:configurable-python, r=alexcrichton
r? @alexcrichton
2015-06-03 14:46:41 +05:30
Manish Goregaokar
a190394ae8 Rollup merge of #25970 - gkoz:make_compiler_docs, r=brson 2015-06-03 14:46:41 +05:30
Manish Goregaokar
f90aecff76 Rollup merge of #25963 - steveklabnik:link_to_cell, r=alexcrichton 2015-06-03 14:46:40 +05:30
Manish Goregaokar
3fd41d61ab Rollup merge of #25939 - wca:fix-freebsd-configure, r=alexcrichton
Bug fixes for configure on FreeBSD:
- Don't ban using gcc; newer versions can be installed and other checks should enforce its suitability.
- Don't force Rust to link itself with /usr/local/lib{,gcc4[46]}, which causes builds to fail if Rust is already installed.  I've not been able to find an use case where this is actually necessary.
2015-06-03 14:46:40 +05:30
Michael Sproul
25d0ef347a Improve diagnostic messages for range patterns. 2015-06-03 16:15:15 +10:00
bors
a5979be9fe Auto merge of #25938 - wca:fix-clang-check-compatibility, r=alexcrichton
Not all /bin/sh have [[ available, so for compatibility using case..esac
for pattern matching is better.
2015-06-03 06:07:44 +00:00
bors
2c8d75d655 Auto merge of #25935 - wesleywiser:fix_libcollection_build_warnings, r=alexcrichton
Fixes a bunch of warnings that are generated during the stage0 build of libcollections.
2015-06-03 02:47:45 +00:00
Richo Healey
506d5a8d19 std: clarify comments about sp* implementations 2015-06-02 16:55:50 -07:00
bors
e8af4752ce Auto merge of #25867 - petrochenkov:ucellv, r=alexcrichton
Now when const functions are implemented and used, the `value` field of `UnsafeCell` can be made deprecated (and then private as intended).
2015-06-02 23:23:32 +00:00
Richo Healey
de4a1dca2b configure: Allow specifying your python with --python 2015-06-02 15:16:30 -07:00
Gleb Kozyrev
b936b1bd7c mk: fix the CFG_ENABLE_COMPILER_DOCS spelling 2015-06-03 00:49:47 +03:00
bors
dc1e79b3c2 Auto merge of #25926 - Ms2ger:enum_variant_ids, r=alexcrichton 2015-06-02 20:05:49 +00:00
Peter Elmers
1ef0ad8adc Change &String[..] to just &String, since it coerces to &str automatically. 2015-06-02 12:21:49 -07:00
Peter Elmers
6812ca1cc8 Move EnumData to the API. 2015-06-02 12:21:20 -07:00
bors
cc85db4ce6 Auto merge of #25868 - alexcrichton:issue-25505, r=brson
The compiler already has special support for fixing up verbatim paths with disks
on Windows to something that can be correctly passed down to gcc, and this
commit adds support for verbatim UNC paths as well.

Closes #25505
2015-06-02 16:37:21 +00:00
Steve Klabnik
e1a33aa987 Link to cell in TRPL: mutability 2015-06-02 09:37:54 -04:00
bors
c800b22e95 Auto merge of #25905 - michaelwoerister:lldb-pp-strings, r=brson
GDB and LLDB pretty printers have some common functionality and also access some common information, such as the layout of standard library types. So far, this information has been duplicated in the two pretty printing python modules. This PR introduces a common module used by both debuggers.

This PR also implements proper rendering of `String` and `&str` values in LLDB.
2015-06-02 13:07:41 +00:00
Felix S. Klock II
0b748002ec added test to ensure move_val_init still handles cleanups properly. 2015-06-02 10:37:56 +02:00
Felix S. Klock II
528ab1fe9b Hack the move_val_init intrinsic to trans directly into the destination address.
remove dead code further down for intrinsic.
2015-06-02 10:37:45 +02:00
bors
48e9ef6404 Auto merge of #25958 - Manishearth:rollup, r=Manishearth
- Successful merges: #25751, #25821, #25920, #25932, #25933, #25936, #25941, #25949, #25951
- Failed merges:
2015-06-02 08:28:20 +00:00
Manish Goregaokar
6e97b16d02 Rollup merge of #25951 - mbrubeck:nan, r=alexcrichton
This is based on the documented behavior of cmath::{fmin,fmax}.  It is also tested by existing unit tests in this module.
2015-06-02 11:14:09 +05:30
Manish Goregaokar
ce3bc8d884 Rollup merge of #25949 - mbrubeck:ndebug, r=alexcrichton
As of rust-lang/rust#22980 only `cfg(debug_assertions)` is used in the
standard library and rustc code.
2015-06-02 11:14:09 +05:30
Manish Goregaokar
98612dad9b Rollup merge of #25941 - puzza007:trpl-infinite-iterator-chain-take, r=steveklabnik 2015-06-02 11:14:08 +05:30
Manish Goregaokar
a85150b58a Rollup merge of #25936 - tshepang:patch-2, r=alexcrichton 2015-06-02 11:14:08 +05:30
Manish Goregaokar
46ebed55a6 Rollup merge of #25933 - bluss:rustdoc-fn-css, r=alexcrichton
rustdoc: Tweak css of function where clauses

Method where clauses are put indented on a new line, do the same tweak
to free functions, which makes it cleaner and easier to read.
2015-06-02 11:14:08 +05:30
Manish Goregaokar
04abc05094 Rollup merge of #25932 - bluss:doc-book-1, r=alexcrichton
trpl: Fix typo in Raw Pointers chapter
2015-06-02 11:14:08 +05:30
Manish Goregaokar
9c77784668 Rollup merge of #25920 - tshepang:option-map-example, r=Gankro 2015-06-02 11:14:08 +05:30
Manish Goregaokar
4f5a7440db Rollup merge of #25821 - jooert:remove_build_date, r=brson
Closes #25812.
2015-06-02 11:14:07 +05:30
Manish Goregaokar
7da2228861 Rollup merge of #25751 - steveklabnik:translations, r=brson
/cc @kgv, @rust-kr, @KaiserY, @mkpankov
2015-06-02 11:14:07 +05:30
bors
f14190199c Auto merge of #25848 - alexcrichton:fix-msvc, r=brson
Now that MSVC support has landed in the most recent nightlies we can now have
MSVC bootstrap itself without going through a GNU compiler first. Unfortunately,
however, the bootstrap currently fails due to the compiler not being able to
find the llvm-ar.exe tool during the stage0 libcore compile. The compiler cannot
find this tool because it's looking inside a directory that does not exist:

    $SYSROOT/rustlib/x86_64-pc-windows-gnu/bin

The `gnu` on this triple is because the bootstrap compiler's host architecture
is GNU. The build system, however, only arranges for the llvm-ar.exe tool to be
available in this location:

    $SYSROOT/rustlib/x86_64-pc-windows-msvc/bin

To resolve this discrepancy, the build system has been modified to understand
triples that are bootstrapped from another triple, and in this case copy the
native tools to the right location.
2015-06-02 05:12:51 +00:00
bors
f813f97797 Auto merge of #25654 - petrochenkov:encenv, r=alexcrichton
Fixes https://github.com/rust-lang/rust/issues/25268 and a couple of similar test errors

r? @alexcrichton
2015-06-02 02:08:17 +00:00
Wesley Wiser
99df38347b [libcollections] Fix unused import warnings during stage0 build 2015-06-01 19:43:18 -04:00
bors
613e57b448 Auto merge of #25246 - mzabaluev:io-invalid-data, r=alexcrichton
This takes the cases from `InvalidInput` where a data format error
was encountered. This is different from the documented semantics
of `InvalidInput`, which more likely indicate a programming error.

Fixes rust-lang/rfcs#906
2015-06-01 23:12:52 +00:00
Matt Brubeck
f44d287a76 Document behavior of {f32,f64}::{min,max} on NaN
This is based on the documented behavior of cmath::{fmin,fmax}.  It is also
tested by existing unit tests in this module.
2015-06-01 15:02:11 -07:00
Matt Brubeck
7d95c22244 Stop passing the old ndebug/debug cfg directives
As of rust-lang/rust#22980 only `cfg(debug_assertions)` is used in the
standard library and rustc code.
2015-06-01 14:01:13 -07:00
Steve Klabnik
321c2f4f8c Add community translations. 2015-06-01 15:57:44 -04:00
bors
a49ae5bd43 Auto merge of #25858 - alexcrichton:disable-os-tls, r=brson
This commit adds a ./configure option called `--disable-elf-tls` which disables
ELF based TLS (that which is communicated to LLVM) on platforms which already
support it. OSX 10.6 does not support this form of TLS, and some users of Rust
need to target 10.6 and are unable to do so due to the usage of TLS. The
standard library will continue to use ELF based TLS on OSX by default (as the
officially supported platform is 10.7+), but this adds an option to compile the
standard library in a way that is compatible with 10.6.

Closes #25342
2015-06-01 19:51:57 +00:00
Tshepang Lekhonkhobe
8221715b95 doc: improve Option::map example 2015-06-01 20:49:33 +02:00
petrochenkov
a40bca29a8 Fix platform detection 2015-06-01 20:50:35 +03:00
bors
3e561f05c0 Auto merge of #25825 - GuillaumeGomez:check_co, r=Manishearth
Part of #24407.
2015-06-01 10:59:37 +00:00
Paul Oliver
5fefae684a trpl: Use infinite iterator in chain example with take 2015-06-01 12:44:50 +02:00
Guillaume Gomez
dbfc8c5a07 Update diagnostics.rs 2015-06-01 12:33:41 +02:00
Guillaume Gomez
42c5c982c4 Remove full path 2015-06-01 10:46:28 +02:00