Commit Graph

69603 Commits

Author SHA1 Message Date
Michael Hewson 31d3783050 fixed all the compile-fail error messages
now that we've fixed the bug where constraint origins were getting overwritten, the good error messages are back (with some tweaks)
2017-11-09 09:16:55 -05:00
Michael Hewson dcbb27aa60 fix the bug in region_inference where constraint origins were being overwritten 2017-11-09 08:42:33 -05:00
Konrad Borowski 6a92c0fdbd Allow a trailing comma in assert_eq/ne macro 2017-11-09 14:14:49 +01:00
Mikhail Modin 0e5c95ebcb change separator from `.` to `-` 2017-11-09 12:37:16 +03:00
Mikhail Modin 7a6832de99 change MIR dump filenames from `nodeN` to `DefPath` 2017-11-09 12:00:17 +03:00
Mikhail Modin 3ccb567b90 Add `TerminatorKind::DropAndReplace` handling 2017-11-09 11:55:23 +03:00
Alex Crichton 348930eb4e std: Move the `cmath` module into the `sys` module
This commit moves the `f32::cmath` and `f64::cmath` modules into the
`sys` module. Note that these are not publicly exported modules, simply
implementation details. These modules are already platform-specific with
shims on MSVC and this is mostly just a reflection of that reality. This
should also help cut down on `#[cfg]` traffic if platforms are brought on
which don't directly support these functions.
2017-11-08 20:42:23 -08:00
Alex Crichton 1ccb50eaa6 std: Change how EBADF is handled in `sys`
This commit removes the reexport of `EBADF_ERR` as a constant from
libstd's portability facade, instead opting for a platform-specific
function that specifically queries an `io::Error`. Not all platforms may
have a constant for this, so it makes the intent a little more clear
that a code need not be supplied, just an answer to a query.
2017-11-08 20:41:17 -08:00
Alex Crichton 6bc8f164b0 std: Remove `rand` crate and module
This commit removes the `rand` crate from the standard library facade as
well as the `__rand` module in the standard library. Neither of these
were used in any meaningful way in the standard library itself. The only
need for randomness in libstd is to initialize the thread-local keys of
a `HashMap`, and that unconditionally used `OsRng` defined in the
standard library anyway.

The cruft of the `rand` crate and the extra `rand` support in the
standard library makes libstd slightly more difficult to port to new
platforms, namely WebAssembly which doesn't have any randomness at all
(without interfacing with JS). The purpose of this commit is to clarify
and streamline randomness in libstd, focusing on how it's only required
in one location, hashmap seeds.

Note that the `rand` crate out of tree has almost always been a drop-in
replacement for the `rand` crate in-tree, so any usage (accidental or
purposeful) of the crate in-tree should switch to the `rand` crate on
crates.io. This then also has the further benefit of avoiding
duplication (mostly) between the two crates!
2017-11-08 20:41:17 -08:00
bors fd9ecfdfd0 Auto merge of #45736 - oli-obk:rvalue_promotable_map, r=nikomatsakis
Use a `Set<T>` instead of a `Map<T, bool>`

r? @nikomatsakis

introduced in #44501
2017-11-09 04:14:28 +00:00
bors fc77b623d3 Auto merge of #45688 - Gankro:layout-tests, r=alexcrichton
Add reftest that checks the layout of repr(int) on non-c-like enums

This verifies the first layout specified in https://github.com/rust-lang/rfcs/pull/2195

The second (`repr(C)`) layout isn't included here because it doesn't actually exist today. However if/when that's implemented a second test could be fairly easily derived from this one.

CC @eddyb
2017-11-09 00:50:56 +00:00
Eduard-Mihai Burtescu fbcc6733d4 proc_macro: use the proc_macro API at runtime to construct quasi-quoted TokenStream's. 2017-11-09 01:40:04 +02:00
Eduard-Mihai Burtescu a51c69e2d5 proc_macro: process proc_macro tokens instead of libsyntax ones in the quasi-quoter. 2017-11-09 01:40:04 +02:00
Jorge Aparicio 47ed4738d9 fix core for targets with max-atomic-width = 0
closes #45802
2017-11-09 00:20:55 +01:00
bors da3fbe750f Auto merge of #45867 - michaelwoerister:check-ich-stability, r=nikomatsakis
incr.comp.: Verify stability of incr. comp. hashes and clean up various other things.

The main contribution of this PR is that it adds the `-Z incremental-verify-ich` functionality. Normally, when the red-green tracking system determines that a certain query result has not changed, it does not re-compute the incr. comp. hash (ICH) for that query result because that hash is already known. `-Z incremental-verify-ich` tells the compiler to re-hash the query result and compare the new hash against the cached hash. This is a rather thorough way of
- testing hashing implementation stability,
- finding missing `[input]` annotations on `DepNodes`, and
- finding missing read-edges,

since both a missed read and a missing `[input]` annotation can lead to something being marked as green instead of red and thus will have a different hash than it should have.

Case in point, implementing this verification logic and activating it for all `src/test/incremental` tests has revealed several such oversights, all of which are fixed in this PR.

r? @nikomatsakis
2017-11-08 22:27:06 +00:00
John Ford cd32aff3fc
get() example should use get() not get_mut()
I'm really new to Rust, this is the first thing I've ever actually pushed to github in a rust project, so please double check that it's correct.  I noticed that the in-doc example for the string's get() function was referring to get_mut().  Looks like a copy/paste issue.

```rust
fn main() {
    let v = String::from("🗻🌏");

    assert_eq!(Some("🗻"), v.get(0..4));

    // indices not on UTF-8 sequence boundaries
    assert!(v.get(1..).is_none());
    assert!(v.get(..8).is_none());

    // out of bounds
    assert!(v.get(..42).is_none());
}
```
results in:
```
jhford-work:~/rust/redish $ cat get-example.rs
fn main() {
    let v = String::from("🗻🌏");

    assert_eq!(Some("🗻"), v.get(0..4));

    // indices not on UTF-8 sequence boundaries
    assert!(v.get(1..).is_none());
    assert!(v.get(..8).is_none());

    // out of bounds
    assert!(v.get(..42).is_none());
}
jhford-work:~/rust/redish $ rustc get-example.rs
jhford-work:~/rust/redish $ ./get-example ; echo $?
0
```

I did not build an entire rust toolchain as I'm not totally sure how to do that.
2017-11-08 22:40:35 +01:00
Michael Hewson 7f8b003fbb update ui test to new error message 2017-11-08 16:12:34 -05:00
Michael Hewson aa00f17409 fix error message in arbitrary-self-types-not-object-safe test
put the error message on one line so the test suite does not think it is two errors
use a substring of the error message so it fits in 100 chars for tidy
2017-11-08 16:12:12 -05:00
Michael Hewson 0954e5489c shorten line length for tidy 2017-11-08 16:09:58 -05:00
Michael Hewson 0a3a46d3b6 tidy things up a bit 2017-11-08 15:03:37 -05:00
bors 02004ef783 Auto merge of #45452 - estebank:colon-typo, r=nikomatsakis
Detect `=` -> `:` typo in let bindings

When encountering a let binding type error, attempt to parse as
initializer instead. If successful, it is likely just a typo:

```rust
fn main() {
    let x: Vec::with_capacity(10);
}
```

```
error: expected type, found `10`
 --> file.rs:3:31
  |
3 |     let x: Vec::with_capacity(10, 20);
  |         --                    ^^
  |         ||
  |         |help: did you mean assign here?: `=`
  |         while parsing the type for `x`
```

Fix #43703.
2017-11-08 20:00:41 +00:00
Mikhail Modin e48691a578 restore move out dataflow, add report of move out errors 2017-11-08 22:04:56 +03:00
Esteban Küber d0339c7e44 Fix help for duplicated names: `extern crate (...) as (...)`
On the case of duplicated names caused by an `extern crate` statement
with a rename, don't include the inline suggestion, instead using a span
label with only the text to avoid incorrect rust code output.
2017-11-08 10:36:14 -08:00
Alexis Beingessner e156f89e11 Add reftest that checks the layout of repr(int) on non-c-like enums
This verifies the layout specified in rfc #2195
2017-11-08 12:47:39 -05:00
bors 7ca430df71 Auto merge of #45205 - rkruppe:saturating-casts, r=eddyb
Saturating casts between integers and floats

Introduces a new flag, `-Z saturating-float-casts`, which makes code generation for int->float and float->int casts safe (`undef`-free), implementing [the saturating semantics laid out by](https://github.com/rust-lang/rust/issues/10184#issuecomment-299229143) @jorendorff for float->int casts and overflowing to infinity for `u128::MAX` -> `f32`.
Constant evaluation in trans was changed to behave like HIR const eval already did, i.e., saturate for u128->f32 and report an error for problematic float->int casts.

Many thanks to @eddyb, whose APFloat port simplified many parts of this patch, and made HIR constant evaluation recognize dangerous float casts as mentioned above.
Also thanks to @ActuallyaDeviloper whose branchless implementation served as inspiration for this implementation.

cc #10184 #41799
fixes #45134
2017-11-08 17:27:56 +00:00
bors 6e2977499b Auto merge of #45866 - JohnColanduoni:issue-45731, r=alexcrichton
Disable `mmap`  in `libbacktrace` on Apple platforms

Fixes #45731

libbacktrace uses mmap if available to map ranges of the files containing debug information. On macOS `mmap` will succeed even if the mapped range does not exist, and a SIGBUS (with an unusual EXC_BAD_ACCESS code 10) will occur when the program attempts to page in the memory. To combat this we force `libbacktrace` to be built with the simple `read` based fallback on Apple platforms.
2017-11-08 14:54:03 +00:00
Robin Kruppe ef0b99930e Disable u128 <-> float tests on emscripten 2017-11-08 14:54:03 +01:00
Michael Woerister d01b89b948 incr.comp.: Provide session to some more decoding contexts. 2017-11-08 14:52:00 +01:00
Michael Hewson e06cd316a4 Remove the error check that I think is redundant, and change the test error messages that I don't understand why they changed, so the tests pass 2017-11-08 08:31:08 -05:00
Michael Hewson 02ce3ac1f8 add a NOTE comment to the object safety test so that it passes 2017-11-08 08:29:47 -05:00
Michael Hewson bbe755c7a6 Switch from using At::eq to InferCtxt::can_eq and demand_eqtype_with_origin
I doubt this changes anything, I was just trying to fix an issue with
error messages and ended up doing this along with other things.
Committing it separately so I can undo it easily.
2017-11-08 08:28:36 -05:00
Michael Hewson 236974619f normalize associated types in both self_ty and self_arg_ty
I was only doing it for self_arg_ty, and ended up causing
run-pass/associated-types-projection-from-known-type-in-impl.rs to fail.
2017-11-08 08:24:33 -05:00
Guillaume Gomez 3d480b4138 Add missing example for Debug trait 2017-11-08 14:11:27 +01:00
bors 4bb96f6519 Auto merge of #45575 - michaelwoerister:tweak-inline-trans-items, r=nikomatsakis
Only instantiate inline- and const-fns if they are referenced (again).

It seems that we have regressed on not translating `#[inline]` functions unless they are actually used. This should bring back this optimization. I also added a regression test this time so it doesn't happen again accidentally.

Fixes #40392.

r? @alexcrichton

UPDATE & PSA
---------------------
This patch **makes translation very lazy** -- in general this is a good thing (we don't want the compiler to do unnecessary work) but it has two consequences:
1. Some error messages are only generated when an item is actually translated. Consequently, this patch will lead to more cases where the compiler will only start emitting errors when the erroneous function is actually used. This has always been true to some extend (e.g. when passing generic values to an intrinsic) but since this is something user-facing it's worth mentioning.
2. When writing tests, one has to make sure that the functions in question are actually generated. In other words, it must not be dead code. This can usually  be achieved by either
    1. making sure the function is exported from the resulting binary or
    2. by making sure the function is called from something that is exported (or `main()`).

Note that it depends on the crate type what functions are exported:
   1. For rlibs and dylibs everything that is reachable from the outside is exported.
   2. For executables, cdylibs, and staticlibs, items are only exported if they are additionally `#[no_mangle]` or have an `#[export_name]`.

The commits in this PR contain many examples of how tests can be updated to comply to the new requirements.
2017-11-08 12:23:34 +00:00
Michael Woerister d948af1d37 incr.comp.: Remove unused DepKind::WorkProduct. 2017-11-08 11:44:55 +01:00
Michael Woerister 702ce8f0a6 incr.comp.: Remove outdated comment about TraitSelect dep-node. 2017-11-08 11:34:09 +01:00
Michael Woerister 13bc7ad476 incr.comp.: Always verify incr. comp. hashes when running incremental tests. 2017-11-08 11:33:06 +01:00
Michael Woerister 95b0849715 incr.comp.: Adapt nested_items test to new HIR hashing rules. 2017-11-08 11:32:16 +01:00
Michael Woerister fde0ca5456 incr.comp.: Add some missing reads in HIR map. 2017-11-08 11:31:15 +01:00
Michael Woerister 616b45542b incr.comp.: Make DefSpan an input dep-node so it is not affected by the existing Span/HIR hashing hack. 2017-11-08 11:30:14 +01:00
Niko Matsakis 629efae761 look for the note on the guarantor, not the root cmt
This was causing upvar inference to fail for all cases where the move
was from a projection, not the root variable.
2017-11-08 05:29:03 -05:00
John Colanduoni 8581b59fb3 Disable `mmap` in `libbacktrace` on Apple platforms
Fixes #45731

libbacktrace uses mmap if available to map ranges of the files containing debug information. On macOS `mmap` will succeed even if the mapped range does not exist, and a SIGBUS (with an unusual EXC_BAD_ACCESS code 10) will occur when the program attempts to page in the memory. To combat this we force `libbacktrace` to be built with the simple `read` based fallback on Apple platforms.
2017-11-08 02:28:17 -08:00
Michael Hewson 3902643c27 move ExplicitSelf to rustc::ty::util, and use it to implement object safety checks 2017-11-08 05:27:39 -05:00
Michael Woerister 081ef8ed75 Update fastcall-inreg codegen test so that functions actually get instantiated. 2017-11-08 11:09:48 +01:00
bors f733f484f8 Auto merge of #45862 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 4 pull requests

- Successful merges: #45582, #45766, #45830, #45849
- Failed merges:
2017-11-08 09:43:27 +00:00
Niko Matsakis dc6af49258 use the derived Debug rather than our custom written ones
That encoding that the custom Debugs was using is rather inscrutable,
and incomplete.
2017-11-08 04:43:13 -05:00
Michael Hewson 0b27dcc665 modify ExplicitSelf::determine to take an `is_self_type` predicate closure, instead of infcx 2017-11-08 04:31:48 -05:00
Lukas Kalbertodt e65214441d Add `Option::filter()` according to RFC 2124 2017-11-08 10:23:12 +01:00
Guillaume Gomez 661c507a2e Rollup merge of #45849 - GuillaumeGomez:more-shortcut, r=QuietMisdreavus
Add "-" shortcut

Fixes #45847.

r? @Havvy
2017-11-08 10:09:18 +01:00
Guillaume Gomez 6392a164f0 Rollup merge of #45830 - pornel:dosglobs, r=dtolnay
Warn about lack of args glob expansion in Windows shell

Because all shells on Linux/macOS expand globs, and even MinGW on Windows emulates this behavior, it's easy to forget that Windows by itself doesn't support glob expansion. This PR documents this cross-platform difference.
2017-11-08 10:09:17 +01:00