Commit Graph

63365 Commits

Author SHA1 Message Date
Niko Matsakis
77d9e38e94 add FIXME for bivariant lub/glb 2017-04-11 20:32:47 -04:00
Niko Matsakis
d1033d06ba add FIXME to #18653 2017-04-11 20:32:47 -04:00
Niko Matsakis
e4b762b532 add regression test for #30225
Fixes #30225
2017-04-11 20:32:47 -04:00
Niko Matsakis
e58e2b423d remove the subtyping relations from TypeVariable 2017-04-11 20:32:46 -04:00
Niko Matsakis
105ec7e3bb use obligations to propagate sub-typing instead of the TV code 2017-04-11 20:32:46 -04:00
Niko Matsakis
4e4bdea0ae propagate sub-obligations better
The most interesting place is the hinting mechanism; once we start
having subtyping obligations, it's important to see those through.
2017-04-11 20:32:46 -04:00
Niko Matsakis
58609ef879 add Subtype predicate 2017-04-11 20:32:46 -04:00
Niko Matsakis
18ea55fe16 remove bivariance
There is one fishy part of these changes: when computing the LUB/GLB of
a "bivariant" type parameter, I currently return the `a`
value. Bivariant type parameters are only allowed in a very particular
situation, where the type parameter is only used as an associated type
output, like this:

```rust
pub struct Foo<A, B>
    where A: Fn() -> B
    {
        data: A
        }
        ```

In principle, if one had `T=Foo<A, &'a u32>` and `U=Foo<A, &'b u32>`
and (e.g.) `A: for<'a> Fn() -> &'a u32`, then I think that computing the
LUB of `T` and `U` might do the wrong thing. Probably the right behavior
is just to create a fresh type variable. However, that particular
example would not compile (because the where-clause is illegal; `'a`
does not appear in any input type). I was not able to make an example
that *would* compile and demonstrate this shortcoming, and handling the
LUB/GLB was mildly inconvenient, so I left it as is. I am considering
whether to revisit this.
2017-04-11 20:19:23 -04:00
Niko Matsakis
4a0a0e949a remove type variable defaults code
This just limits ourselves to the "old school" defaults: diverging
variables and integer variables.
2017-04-11 20:19:23 -04:00
Esteban Küber
2389830dea Highlight and simplify mismatched types
Shorten mismatched types errors by replacing subtypes that are not
different with `_`, and highlighting only the subtypes that are
different.

Given a file

```rust
struct X<T1, T2> {
    x: T1,
    y: T2,
}

fn foo() -> X<X<String, String>, String> {
    X { x: X {x: "".to_string(), y: 2}, y: "".to_string()}
}

fn bar() -> Option<String> {
    "".to_string()
}
```

provide the following output

```rust
error[E0308]: mismatched types
  --> file.rs:6:5
   |
 6 |     X { x: X {x: "".to_string(), y: 2}, y: "".to_string()}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::string::String`, found {integer}
   |
   = note: expected type `X<X<_, std::string::String>, _>`
                                 ^^^^^^^^^^^^^^^^^^^   // < highlighted
              found type `X<X<_, {integer}>, _>`
                                 ^^^^^^^^^             // < highlighted

error[E0308]: mismatched types
  --> file.rs:6:5
   |
10 |     "".to_string()
   |     ^^^^^^^^^^^^^^ expected struct `std::option::Option`, found `std::string::String`
   |
   = note: expected type `Option<std::string::String>`
                          ^^^^^^^                   ^  // < highlighted
              found type `std::string::String`
```
2017-04-11 15:45:00 -07:00
Corey Farwell
72538dee4d Rollup merge of #41231 - TimNN:fix-centos, r=frewsxcv
Use correct vault URL in CentOS images

r? @frewsxcv
2017-04-11 18:36:17 -04:00
Corey Farwell
3ebeaf6d5c Rollup merge of #41216 - shahn:iter_pos, r=steveklabnik
Clarify Iterator::position doc

Extend the example a little bit to show behaviour better.

r? @steveklabnik
2017-04-11 18:36:16 -04:00
Corey Farwell
828ed96377 Rollup merge of #41209 - aidanhs:aphs-quiet-sccache, r=alexcrichton
Make sccache a bit quieter

...and remove the single mention of `SCCACHE_LOG_LEVEL` that would only take effect on Docker (i.e. Linux) builds since it had no effect anyway (because [`RUST_LOG` takes priority](ec10cdb2dd/src/main.rs (L124-L128))).

r? @frewsxcv
2017-04-11 18:36:16 -04:00
Corey Farwell
704cbad248 Rollup merge of #41204 - remexre:master, r=steveklabnik
Fixes incorrect formatting in array's documentation.

Changes

 - [`Clone`][clone] (only if `T: [Copy][copy]`)

to

 - [`Clone`][clone] (only if `T: `[`Copy`](copy))

r? @steveklabnik
2017-04-11 18:36:15 -04:00
Corey Farwell
c03061d347 Rollup merge of #41202 - brson:btree, r=nikomatsakis
Convert HashMap to BTree in build-manifest

This is just for my peace of mind since it's important the output of this program be deterministic.
2017-04-11 18:36:14 -04:00
Corey Farwell
b72c30a8df Rollup merge of #41173 - GuillaumeGomez:fix-rustdoc-code-block-parsing, r=steveklabnik
Fix block code headers parsing

Fixes #41167.

r? @rust-lang/docs
2017-04-11 18:36:13 -04:00
Corey Farwell
acb43ce573 Rollup merge of #40559 - nagisa:manually-drop, r=alexcrichton
Implement Manually Drop

As the RFC has been from approx a week in FCP without any major comments, I’m taking the opportunity to submit the PR early.
2017-04-11 18:36:12 -04:00
Corey Farwell
4f6f4eb7c3 Rollup merge of #40377 - camlorn:optimization_fuel, r=eddyb
Implement optimization fuel and re-enable struct field reordering

See [this discussion](https://internals.rust-lang.org/t/rolling-out-or-unrolling-struct-field-reorderings/4485) for background.

This pull request adds two new compilation options: `-Z print-fuel=crate` prints the optimization fuel used by a crate and `-Z fuel=crate=n` sets the optimization fuel for a crate.

It also turns field reordering back on.  There is no way to test this feature without something consuming fuel.  We can roll this back if we want, but then the optimization fuel bits will be dead code.

The one notable absence from this PR is a test case.  I'm not sure how to do one that's worth having.  The only thing I can think of to test is `-Z fuel=foo=0`.  The problem with other tests is that either (1) they're so big that future optimizations will apply, thus breaking them or (2) we don't know which order the optimizations will be applied in, so we can't guess the message that will be printed.  If someone has a useful proposal for a good test, I certainly want to add one.
2017-04-11 18:36:12 -04:00
Ariel Ben-Yehuda
540a069761 address review comments 2017-04-12 00:45:54 +03:00
bors
f8107c0d7c Auto merge of #41231 - TimNN:fix-centos, r=frewsxcv
Use correct vault URL in CentOS images

r? @frewsxcv
2017-04-11 20:56:00 +00:00
Ariel Ben-Yehuda
0144613078 Move rvalue checking to MIR
Fixes #41139.
2017-04-11 23:53:20 +03:00
Tim Neumann
56503dd4ad use correct vault url 2017-04-11 22:53:16 +02:00
Ariel Ben-Yehuda
384ec80d2b store Spans for all MIR locals 2017-04-11 23:52:51 +03:00
Paul Lange
4b4b1e1b25 Improve module description for std::f32 and std::f64.
Fixes #29353
2017-04-11 21:57:54 +02:00
Alex Crichton
13d008d1e8 Touch up rls integration
* Use the right version when building combined installer
* Update dependencies of rls as it depends on rustc and plugins
* Fix build-manifest and the versions it uses for the rls
2017-04-11 10:47:53 -07:00
Sebastian Hahn
316af6082c Clarify Iterator::position doc
Extend the example a little bit to show behaviour better.
2017-04-11 19:39:58 +02:00
Guillaume Gomez
143f7be8b6 Remove strings fulfilled with whitespaces in code block headers 2017-04-11 17:36:52 +02:00
Simonas Kazlauskas
e18c59fd48 Fix some nits 2017-04-11 16:06:30 +03:00
Simonas Kazlauskas
a384f131cb Fix handling of closure arguments
Those did not take tuple reordering into account, causing majority of the compiler test suite to
fail.
2017-04-11 15:21:07 +03:00
bors
c58c928e65 Auto merge of #41096 - clarcharr:as_bytes_mut, r=alexcrichton
Reduce str transmutes, add mut versions of methods.

When I was working on the various parts involved in #40380 one of the comments I got was the excess of transmutes necessary to make the changes work. This is part of a set of multiple changes I'd like to offer to fix this problem.

I think that having these methods is reasonable because they're already possible via transmutes, and it makes the code that uses them safer. I can also add `pub(crate)` to these methods for now if the libs team would rather not expose them to the public without an RFC.
2017-04-11 12:13:49 +00:00
Austin Hicks
d821e98fd7 Make a comment better. 2017-04-11 14:36:08 +03:00
Austin Hicks
0931e2006a Initial attempt at implementing optimization fuel and re-enabling struct field reordering. 2017-04-11 14:36:08 +03:00
Austin Hicks
98eb121b7a We have to use u16 to test field reordering because u64's alignment changes based on 32-bit or 64-bit architecture. 2017-04-11 14:36:08 +03:00
Austin Hicks
8b00837691 UI test for -Z print-fuel=foo 2017-04-11 14:36:08 +03:00
Austin Hicks
912599944e Tests for -Z fuel=foo=n 2017-04-11 14:36:08 +03:00
Austin Hicks
4db9c7a2a2 Make a comment better. 2017-04-11 14:36:07 +03:00
Austin Hicks
63ebf08be5 Initial attempt at implementing optimization fuel and re-enabling struct field reordering. 2017-04-11 14:36:05 +03:00
bors
6edc596853 Auto merge of #41168 - Shizmob:jemalloc-musl, r=alexcrichton
Fix jemalloc support for musl

Just like DragonFlyBSD, using the same symbols as the system allocator will result in a segmentation fault at runtime due to allocator mismatches. As such, it's better to prefix the jemalloc symbols instead, avoiding crashes.

We encountered this problem on a dynamically-linked musl target (with patches to Rust to make that possible, see #40113). It may not show up immediately obviously on the current statically-linked CRT targets.
2017-04-11 08:57:39 +00:00
Eduard-Mihai Burtescu
0303a3364b Fix pairs of doubles using an illegal <8 x i8> vector. 2017-04-11 11:33:30 +03:00
bors
8d85504410 Auto merge of #41174 - estebank:issue-41155, r=nikomatsakis
Point at only one char on `Span::next_point`

Avoid pointing at two chars so the diagnostic output doesn't display a
multiline span when starting beyond a line end.

Fix #41155.

Instead of

```rust
error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
 --> <anon>:3:1
  |
1 |   impl S {	pub
  |  _____________- starting here...
2 | |
  | |  ...ending here: expected one of 7 possible tokens here
3 |   }
  |   ^ unexpected token
```

show

```rust
error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
  --> <anon>:13:1
   |
12 |     pub
   |        - expected one of 7 possible tokens here
13 | }
   | ^ unexpected token
```
2017-04-11 05:44:06 +00:00
Aidan Hobson Sayers
f297767b2c Make sccache a bit quieter 2017-04-11 00:22:26 +01:00
bors
730e5ad04e Auto merge of #40565 - estebank:binops-help, r=arielb1
Explicit help message for binop type mismatch

When trying to do `1 + Some(2)`, or some other binary operation on two
types different types without an appropriate trait implementation, provide
an explicit help message:

```rust
help: `{integer} + std::option::Option<{integer}>` has no implementation
```

Re: #39579, #38564, #37626, #39942, #34698.
2017-04-10 21:56:13 +00:00
Esteban Küber
be8787dfe5 Explicit help message for binop type missmatch
When trying to do a binary operation with missing implementation, for
example `1 + Some(2)`, provide an explicit help message:

```
note: no implementation for `{integer} + std::option::Option<{integer}>`
```

Use `rustc_on_unimplemented` for the suggestions. Move cfail test to ui.
2017-04-10 14:28:38 -07:00
Nathaniel Ringo
b9d662a000 Fixes incorrect formatting in array's documentation. 2017-04-10 16:12:39 -05:00
Esteban Küber
4c80170782 Point at only one char on Span::next_point
Avoid pointing at two chars so the diagnostic output doesn't display a
multiline span when starting beyond a line end.
2017-04-10 14:03:17 -07:00
Brian Anderson
1c3f34dba6 Convert HashMap to BTree in build-manifest 2017-04-10 20:50:57 +00:00
bors
3b5754e5ce Auto merge of #40018 - japaric:ld, r=alexcrichton
-Z linker-flavor

(Please read the commit message first)

This PR is an alternative to rust-lang/rust#36120 (internal lld linker). The
main goal of this PR is to make it *possible* to use LLD as a linker to allow
out of tree experimentation. Now that LLD is going to be shipped with LLVM 4.0,
it should become easier to get a hold of LLD (hopefully, it will be packaged by
Linux distros soon).

Since LLD is a multiarch linker, it has the potential to make cross compilation
easier (less tools need to be installed). Supposedly, LLD is also faster than
the gold linker so LLD may improve build times where link times are significant
(e.g. 100% incremental compilation reuse).

The place where LLD shines is at linking Rust programs that don't depend on
system libraries. For example, here's how you would link a bare metal ARM
Cortex-M program:

```
$ xargo rustc --target thumbv7m-none-eabi -- -Z linker-flavor=ld -C linker=ld.lld -Z print-link-args
"ld.lld" \
  "-L" \
  "$XARGO_HOME/lib/rustlib/thumbv7m-none-eabi/lib" \
  "$PWD/target/thumbv7m-none-eabi/debug/deps/app-de1f86df314ad68c.0.o" \
  "-o" \
  "$PWD/target/thumbv7m-none-eabi/debug/deps/app-de1f86df314ad68c" \
  "--gc-sections" \
  "-L" \
  "$PWD/target/thumbv7m-none-eabi/debug/deps" \
  "-L" \
  "$PWD/target/debug/deps" \
  "-L" \
  "$XARGO_HOME/lib/rustlib/thumbv7m-none-eabi/lib" \
  "-Bstatic" \
  "-Bdynamic" \
  "$XARGO_HOME/lib/rustlib/thumbv7m-none-eabi/lib/libcore-11670d2bd4951fa7.rlib"

$ file target/thumbv7m-none-eabi/debug/app
app: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped, with debug_info
```

This doesn't require installing the `arm-none-eabi-gcc` toolchain.

Even cooler (but I'm biased) is that you can link Rust programs that use
[`steed`] (`steed` is a `std` re-implementation free of C dependencies for Linux
systems) instead of `std` for a bunch of different architectures without having
to install a single cross toolchain.

[`steed`]: https://github.com/japaric/steed

```
$ xargo rustc --target aarch64-unknown-linux-steed --example hello --release -- -Z print-link-args
"ld.lld" \
  "-L" \
  "$XARGO_HOME/lib/rustlib/aarch64-unknown-linux-steed/lib" \
  "$PWD/target/aarch64-unknown-linux-steed/release/examples/hello-80c130ad884c0f8f.0.o" \
  "-o" \
  "$PWD/target/aarch64-unknown-linux-steed/release/examples/hello-80c130ad884c0f8f" \
  "--gc-sections" \
  "-L" \
  "$PWD/target/aarch64-unknown-linux-steed/release/deps" \
  "-L" \
  "$PWD/target/release/deps" \
  "-L" \
  "$XARGO_HOME/lib/rustlib/aarch64-unknown-linux-steed/lib" \
  "-Bstatic" \
  "-Bdynamic" \
  "/tmp/rustc.lAybk9Ltx93Q/libcompiler_builtins-589aede02de78434.rlib"

$ file target/aarch64-unknown-linux-steed/release/examples/hello
hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped, with debug_info
```

All these targets (architectures) worked with LLD:

- [aarch64-unknown-linux-steed](https://github.com/japaric/steed/blob/lld/docker/aarch64-unknown-linux-steed.json)
- [arm-unknown-linux-steedeabi](https://github.com/japaric/steed/blob/lld/docker/arm-unknown-linux-steedeabi.json)
- [arm-unknown-linux-steedeabihf](https://github.com/japaric/steed/blob/lld/docker/arm-unknown-linux-steedeabihf.json)
- [armv7-unknown-linux-steedeabihf](https://github.com/japaric/steed/blob/lld/docker/armv7-unknown-linux-steedeabihf.json)
- [i686-unknown-linux-steed](https://github.com/japaric/steed/blob/lld/docker/i686-unknown-linux-steed.json)
- [mips-unknown-linux-steed](https://github.com/japaric/steed/blob/lld/docker/mips-unknown-linux-steed.json)
- [mipsel-unknown-linux-steed](https://github.com/japaric/steed/blob/lld/docker/mipsel-unknown-linux-steed.json)
- [powerpc-unknown-linux-steed](https://github.com/japaric/steed/blob/lld/docker/powerpc-unknown-linux-steed.json)
- [powerpc64-unknown-linux-steed](https://github.com/japaric/steed/blob/lld/docker/powerpc64-unknown-linux-steed.json)
- [x86_64-unknown-linux-steed](https://github.com/japaric/steed/blob/lld/docker/x86_64-unknown-linux-steed.json)

---

The case where lld is unergonomic is linking binaries that depend on system
libraries. Like "Hello, world" for `x86_64-unknown-linux-gnu`. Because you have
to pass as linker arguments: the path to the startup objects, the path to the
dynamic linker and the library search paths. And all those are system specific
so they can't be encoded in the target itself.

```
$ cargo \
  rustc \
  --release \
  -- \
  -C \
  linker=ld.lld \
  -Z \
  linker-flavor=ld \
  -C \
  link-args='-dynamic-linker /lib64/ld-linux-x86-64.so.2 -L/usr/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1 /usr/lib/Scrt1.o /usr/lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtbeginS.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtendS.o /usr/lib/crtn.o'
```

---

Another case where `-Z linker-flavor` may come in handy is directly calling
Solaris' linker which is also a multiarch linker (or so I have heard). cc
@binarycrusader

cc @alexcrichton
Heads up: [breaking-change] due to changes in the target specification format.
2017-04-10 18:00:23 +00:00
lukaramu
12d7c3d9d8 Fixed indent, grammar, and link in std::hash docs 2017-04-10 17:50:54 +02:00
Jorge Aparicio
e192fb3d89 explain why we have a fake cfail test 2017-04-10 09:55:52 -05:00
Jorge Aparicio
251d9be429 --subsystem needs -Wl when using non-ld linkers 2017-04-10 09:53:24 -05:00