]> git.lizzy.rs Git - rust.git/log
rust.git
7 years agoRollup merge of #40702 - mrhota:global_asm, r=nagisa
Corey Farwell [Fri, 14 Apr 2017 21:41:03 +0000 (17:41 -0400)]
Rollup merge of #40702 - mrhota:global_asm, r=nagisa

Implement global_asm!() (RFC 1548)

This is a first attempt. ~~One (potential) problem I haven't solved is how to handle multiple usages of `global_asm!` in a module/crate. It looks like `LLVMSetModuleInlineAsm` overwrites module asm, and `LLVMAppendModuleInlineAsm` is not provided in LLVM C headers ðŸ˜¦~~

I can provide more detail as needed, but honestly, there's not a lot going on here.

r? @eddyb

CC @Amanieu @jackpot51

Tracking issue: #35119

7 years agoAuto merge of #41153 - petrochenkov:umove, r=pnkfelix
bors [Fri, 14 Apr 2017 16:28:14 +0000 (16:28 +0000)]
Auto merge of #41153 - petrochenkov:umove, r=pnkfelix

Fix move checking for nested union fields

Fixes https://github.com/rust-lang/rust/issues/41126
r? @arielb1

7 years agoAuto merge of #41122 - palango:mod-desc-floats, r=frewsxcv
bors [Fri, 14 Apr 2017 13:24:27 +0000 (13:24 +0000)]
Auto merge of #41122 - palango:mod-desc-floats, r=frewsxcv

Improve module description for std::f32 and std::f64

Fixes #29353, see discussion there.

7 years agoComply with windows symbol name conventions
A.J. Gardner [Fri, 14 Apr 2017 04:41:03 +0000 (23:41 -0500)]
Comply with windows symbol name conventions

7 years agoAuto merge of #41294 - frewsxcv:rollup, r=frewsxcv
bors [Fri, 14 Apr 2017 02:02:13 +0000 (02:02 +0000)]
Auto merge of #41294 - frewsxcv:rollup, r=frewsxcv

Rollup of 4 pull requests

- Successful merges: #41279, #41281, #41287, #41292
- Failed merges:

7 years agoRollup merge of #41292 - est31:master, r=BurntSushi
Corey Farwell [Fri, 14 Apr 2017 02:01:28 +0000 (22:01 -0400)]
Rollup merge of #41292 - est31:master, r=BurntSushi

Avoid to use floating point match

Its going to be forbidden, see issue #41255.

7 years agoRollup merge of #41287 - nikomatsakis:incr-comp-refactor-trans, r=eddyb
Corey Farwell [Fri, 14 Apr 2017 02:01:27 +0000 (22:01 -0400)]
Rollup merge of #41287 - nikomatsakis:incr-comp-refactor-trans, r=eddyb

Miscellneous refactorings of trans

This doesn't achieve any particular goal yet, but it's a collection of refactorings with the common goal of turning `SharedCrateContext` etc into stuff that we can use with on-demand and actually expect to hash in a stable fashion for incremental. Not there yet, clearly.

r? @eddyb
cc @michaelwoerister

7 years agoRollup merge of #41281 - steveklabnik:update-submodules2, r=guillaumegomez
Corey Farwell [Fri, 14 Apr 2017 02:01:26 +0000 (22:01 -0400)]
Rollup merge of #41281 - steveklabnik:update-submodules2, r=guillaumegomez

bump book repos

Not ready to merge yet; I'd like to see what tidy says.

7 years agoRollup merge of #41279 - arielb1:adjustment-composition, r=nikomatsakis
Corey Farwell [Fri, 14 Apr 2017 02:01:25 +0000 (22:01 -0400)]
Rollup merge of #41279 - arielb1:adjustment-composition, r=nikomatsakis

rustc_typeck: consolidate adjustment composition

Instead of having `write_adjustment` overwrite the previous adjustment, have `apply_adjustment` compose a new adjustment on top of the previous one. This is important because `NeverToAny` adjustments can be present on expressions during coercion.

Fixes #41213.

r? @nikomatsakis

7 years agoAvoid to use floating point match
est31 [Fri, 14 Apr 2017 00:58:54 +0000 (02:58 +0200)]
Avoid to use floating point match

Its going to be forbidden, see issue 41255.

7 years agomake `write_metadata` take `tcx` intead of `SharedCrateContext`
Niko Matsakis [Thu, 13 Apr 2017 22:21:51 +0000 (18:21 -0400)]
make `write_metadata` take `tcx` intead of `SharedCrateContext`

7 years agorefactor `metadata_symbol_name`
Niko Matsakis [Thu, 13 Apr 2017 22:08:36 +0000 (18:08 -0400)]
refactor `metadata_symbol_name`

7 years agopull stats out of `SharedCrateContext`
Niko Matsakis [Thu, 13 Apr 2017 21:11:54 +0000 (17:11 -0400)]
pull stats out of `SharedCrateContext`

shared mutable state is bad

7 years agoremove `LinkMeta` from `SharedCrateContext`
Niko Matsakis [Thu, 13 Apr 2017 19:55:48 +0000 (15:55 -0400)]
remove `LinkMeta` from `SharedCrateContext`

A number of things were using `crate_hash` that really ought to be using
`crate_disambiguator` (e.g., to create the plugin symbol names). They
have been updated.

It is important to remove `LinkMeta` from `SharedCrateContext` since it
contains a hash of the entire crate, and hence it will change
whenever **anything** changes (which would then require
rebuilding **everything**).

7 years agouse `tcx.crate_name(LOCAL_CRATE)` rather than `LinkMeta::crate_name`
Niko Matsakis [Thu, 13 Apr 2017 18:58:20 +0000 (14:58 -0400)]
use `tcx.crate_name(LOCAL_CRATE)` rather than `LinkMeta::crate_name`

7 years agokill `CrateContextList` as a thing
Niko Matsakis [Thu, 13 Apr 2017 17:57:45 +0000 (13:57 -0400)]
kill `CrateContextList` as a thing

7 years agorewrite post-processing routines not to require a `CrateContext`
Niko Matsakis [Thu, 13 Apr 2017 17:14:37 +0000 (13:14 -0400)]
rewrite post-processing routines not to require a `CrateContext`

These do some low-level munging on the LLVM data structures. Unclear
that they need to operate as a "second pass" but leave it for now.

7 years agocreate `ModuleTranslation` all in one big loop
Niko Matsakis [Thu, 13 Apr 2017 16:46:37 +0000 (12:46 -0400)]
create `ModuleTranslation` all in one big loop

7 years agomove `assert_module_sources` call down below
Niko Matsakis [Thu, 13 Apr 2017 16:38:27 +0000 (12:38 -0400)]
move `assert_module_sources` call down below

7 years agomerge the "predeclare" and "declare" phases so we run them per-CGU
Niko Matsakis [Thu, 13 Apr 2017 16:38:03 +0000 (12:38 -0400)]
merge the "predeclare" and "declare" phases so we run them per-CGU

7 years agoredirect `exported_symbols` through `shared`
Niko Matsakis [Thu, 13 Apr 2017 16:07:56 +0000 (12:07 -0400)]
redirect `exported_symbols` through `shared`

7 years agoremove unused `link_meta`
Niko Matsakis [Thu, 13 Apr 2017 16:07:45 +0000 (12:07 -0400)]
remove unused `link_meta`

7 years agorewrite to pass a ref, not slice + index
Niko Matsakis [Thu, 13 Apr 2017 16:07:25 +0000 (12:07 -0400)]
rewrite to pass a ref, not slice + index

7 years agoremove `metadata_*` from `SharedCrateContext`
Niko Matsakis [Thu, 13 Apr 2017 15:48:19 +0000 (11:48 -0400)]
remove `metadata_*` from `SharedCrateContext`

No good reason for them to be in there.

7 years agoUpdate various bookshelf repositories.
steveklabnik [Thu, 13 Apr 2017 18:34:32 +0000 (14:34 -0400)]
Update various bookshelf repositories.

The book and the reference have both had changes lately; this integrates
them upstream.

7 years agoAuto merge of #41227 - alexcrichton:compiletest, r=aturon
bors [Thu, 13 Apr 2017 20:21:12 +0000 (20:21 +0000)]
Auto merge of #41227 - alexcrichton:compiletest, r=aturon

rustbuild: Fix recompilation of stage0 tools dir

This commit knocks out a longstanding FIXME in rustbuild which should correctly
recompile stage0 compiletest and such whenever libstd itself changes. The
solution implemented here was to implement a notion of "order only" dependencies
and then add a new dependency stage for clearing out the tools dir, using
order-only deps to ensure that it happens correctly.

The dependency drawing for tools is a bit wonky now but I think this'll get the
job done.

Closes #39396

7 years agorustc_typeck: consolidate adjustment composition
Ariel Ben-Yehuda [Thu, 13 Apr 2017 18:27:35 +0000 (21:27 +0300)]
rustc_typeck: consolidate adjustment composition

Fixes #41213.

7 years agoAuto merge of #41277 - frewsxcv:rollup, r=frewsxcv
bors [Thu, 13 Apr 2017 17:32:22 +0000 (17:32 +0000)]
Auto merge of #41277 - frewsxcv:rollup, r=frewsxcv

Rollup of 3 pull requests

- Successful merges: #41240, #41250, #41266
- Failed merges:

7 years agoRollup merge of #41266 - projektir:weak_docs_rc, r=alexcrichton
Corey Farwell [Thu, 13 Apr 2017 17:04:16 +0000 (13:04 -0400)]
Rollup merge of #41266 - projektir:weak_docs_rc, r=alexcrichton

Updating docs for std::rc::Rc

The same changes as PR [#41240 ](https://github.com/rust-lang/rust/pull/41240), but for [`std::rc::Weak`](https://doc.rust-lang.org/std/rc/struct.Weak.html). At least, as far as I am aware, the Weak pointer is the same for both, and they're basically the same, just one is thread-safe and the other is not.

r? @alexcrichton

7 years agoRollup merge of #41250 - kennytm:fix-41228, r=nikomatsakis
Corey Farwell [Thu, 13 Apr 2017 17:04:15 +0000 (13:04 -0400)]
Rollup merge of #41250 - kennytm:fix-41228, r=nikomatsakis

Fix invalid 128-bit division on 32-bit target (#41228)

The bug of #41228 is a typo, this line: https://github.com/rust-lang/rust/blob/1dca19ae3fd195fa517e326a39bfee729da7cadb/src/libcompiler_builtins/lib.rs#L183

```rust
            // 1 <= sr <= u64::bits() - 1
            q = n.wrapping_shl(64u32.wrapping_sub(sr));
```

The **64** should be **128**.

(Compare with https://github.com/rust-lang-nursery/compiler-builtins/blob/280d19f1127aa80739f4179152b11a5f7d36d79f/src/int/udiv.rs#L213-L214:

```rust
            // 1 <= sr <= <hty!($ty)>::bits() - 1
            q = n << (<$ty>::bits() - sr);
```

Or compare with the C implementation https://github.com/llvm-mirror/compiler-rt/blob/master/lib/builtins/udivmodti4.c#L113-L116

```c
        /* 1 <= sr <= n_udword_bits - 1 */
        /* q.all = n.all << (n_utword_bits - sr); */
        q.s.low = 0;
        q.s.high = n.s.low << (n_udword_bits - sr);
```
)

Added a bunch of randomly generated division test cases to try to cover every described branch of `udivmodti4`.

7 years agoRollup merge of #41240 - projektir:weak_docs, r=alexcrichton
Corey Farwell [Thu, 13 Apr 2017 17:04:14 +0000 (13:04 -0400)]
Rollup merge of #41240 - projektir:weak_docs, r=alexcrichton

Updating docs for std::sync::Weak #29377

I will duplicate these changes for [`std::rc::Weak`] if they are approved.

[`std::rc::Weak`]: https://doc.rust-lang.org/std/rc/struct.Weak.html

r? @jonathandturner

7 years agorustbuild: Fix recompilation of stage0 tools dir
Alex Crichton [Tue, 11 Apr 2017 18:58:25 +0000 (11:58 -0700)]
rustbuild: Fix recompilation of stage0 tools dir

This commit knocks out a longstanding FIXME in rustbuild which should correctly
recompile stage0 compiletest and such whenever libstd itself changes. The
solution implemented here was to implement a notion of "order only" dependencies
and then add a new dependency stage for clearing out the tools dir, using
order-only deps to ensure that it happens correctly.

The dependency drawing for tools is a bit wonky now but I think this'll get the
job done.

Closes #39396

7 years agoAuto merge of #40367 - eddyb:naked-cruft, r=nagisa
bors [Thu, 13 Apr 2017 11:47:33 +0000 (11:47 +0000)]
Auto merge of #40367 - eddyb:naked-cruft, r=nagisa

Improve the LLVM IR we generate for trivial functions, especially #[naked] ones.

These two small changes fix edef1c/libfringe#68:
* Don't emit ZST allocas, such as when returning `()`
* Don't emit a branch from LLVM's entry block to MIR's `START_BLOCK` unless needed
  * That is, if a loop branches back to it, although I'm not sure that's even valid MIR

7 years agoAuto merge of #41267 - alexcrichton:fix-analysis-dist, r=alexcrichton
bors [Thu, 13 Apr 2017 09:16:11 +0000 (09:16 +0000)]
Auto merge of #41267 - alexcrichton:fix-analysis-dist, r=alexcrichton

travis: Enable rust-analysis package for more targets

This commit enables the `rust-analysis` package to be produced for all targets
that are part of the `dist-*` suite of docker images on Travis. Currently
these packages are showing up with `available = false` in the
`channel-rust-nightly.toml` manifest where we'd prefer to have them show up for
all targets.

Unfortunately rustup isn't handling the `available = false` section well right
now, so this should also inadvertently fix the nightly regression.

7 years agoAuto merge of #41009 - scottmcm:toowned-clone-into, r=alexcrichton
bors [Thu, 13 Apr 2017 06:46:29 +0000 (06:46 +0000)]
Auto merge of #41009 - scottmcm:toowned-clone-into, r=alexcrichton

Add a resource-reusing method to `ToOwned`

`ToOwned::to_owned` generalizes `Clone::clone`, but `ToOwned` doesn't have an equivalent to `Clone::clone_from`.  This PR adds such a method as `clone_into` under a new unstable feature `toowned_clone_into`.

Analogous to `clone_from`, this has the obvious default implementation in terms of `to_owned`.  I've updated the `libcollections` impls: for `T:Clone` it uses `clone_from`, for `[T]` I moved the code from `Vec::clone_from` and implemented that in terms of this, and for `str` it's a predictable implementation in terms of `[u8]`.

Used it in `Cow::clone_from` to reuse resources when both are `Cow::Owned`, and added a test that `Cow<str>` thus keeps capacity in `clone_from` in that situation.

The obvious question: is this the right place for the method?
- It's here so it lives next to `to_owned`, making the default implementation reasonable, and avoiding another trait.  But allowing method syntax forces a name like `clone_into`, rather than something more consistent like `owned_from`.
- Another trait would allow `owned_from` and could support multiple owning types per borrow type.  But it'd be another single-method trait that generalizes `Clone`, and I don't know how to give it a default impl in terms of `ToOwned::to_owned`, since a blanket would mean overlapping impls problems.

I did it this way as it's simpler and many of the `Borrow`s/`AsRef`s don't make sense with `owned_from` anyway (`[T;1]:Borrow<[T]>`, `Arc<T>:Borrow<T>`, `String:AsRef<OsStr>`...).  I'd be happy to re-do it the other way, though, if someone has a good solution for the default handling.

(I can also update with `CStr`, `OsStr`, and `Path` once a direction is decided.)

7 years agoMake simple_global_asm even simpler
A.J. Gardner [Fri, 7 Apr 2017 14:46:34 +0000 (09:46 -0500)]
Make simple_global_asm even simpler

Windows builder croaked. This change tries to fix that by actually
calling the global_asm-defined function so the symbol doesn't get
optimized away, if that is in fact what was happening.

Additionally, we provide an empty main() for non-x86 arches.

7 years agotravis: Enable rust-analysis package for more targets
Alex Crichton [Thu, 13 Apr 2017 03:48:18 +0000 (20:48 -0700)]
travis: Enable rust-analysis package for more targets

This commit enables the `rust-analysis` package to be produced for all targets
that are part of the `dist-*` suite of docker images on Travis. Currently
these packages are showing up with `available = false` in the
`channel-rust-nightly.toml` manifest where we'd prefer to have them show up for
all targets.

Unfortunately rustup isn't handling the `available = false` section well right
now, so this should also inadvertently fix the nightly regression.

7 years agoUpdating docs for std::rc::Rc
projektir [Thu, 13 Apr 2017 01:33:49 +0000 (21:33 -0400)]
Updating docs for std::rc::Rc

7 years agoAuto merge of #40570 - nikomatsakis:inference-subtype-through-obligation, r=arielb1
bors [Thu, 13 Apr 2017 00:28:11 +0000 (00:28 +0000)]
Auto merge of #40570 - nikomatsakis:inference-subtype-through-obligation, r=arielb1

Handle subtyping in inference through obligations

We currently store subtyping relations in the `TypeVariables` structure as a kind of special case. This branch uses normal obligations to propagate subtyping, thus converting our inference variables into normal fallback. It also does a few other things:

- Removes the (unstable, outdated) support for custom type inference fallback.
    - It's not clear how we want this to work, but we know that we don't want it to work the way it currently does.
    - The existing support was also just getting in my way.
- Fixes #30225, which was caused by the trait caching code pretending type variables were normal unification variables, when indeed they were not (but now are).

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 or what.

I have started a crater run to test the impact of these changes.

7 years agoAdd ToOwned::clone_into (unstable as toowned_clone_into)
Scott McMurray [Sun, 2 Apr 2017 02:33:45 +0000 (19:33 -0700)]
Add ToOwned::clone_into (unstable as toowned_clone_into)

to_owned generalizes clone; this generalizes clone_from.  Use to_owned to
give it a default impl.  Customize the impl for [T], str, and T:Clone.

Use it in Cow::clone_from to reuse resources when cloning Owned into Owned.

7 years agoReplace ExpnId with SyntaxContext
A.J. Gardner [Thu, 6 Apr 2017 03:12:02 +0000 (22:12 -0500)]
Replace ExpnId with SyntaxContext

7 years agoAdd global_asm tests
A.J. Gardner [Wed, 22 Mar 2017 04:47:25 +0000 (23:47 -0500)]
Add global_asm tests

7 years agoUpdate unstable book with global_asm feature
A.J. Gardner [Tue, 21 Mar 2017 15:02:14 +0000 (10:02 -0500)]
Update unstable book with global_asm feature

7 years agoExpose LLVM appendModuleInlineAsm
A.J. Gardner [Wed, 22 Mar 2017 00:50:23 +0000 (19:50 -0500)]
Expose LLVM appendModuleInlineAsm

7 years agoEnsure walk_item visits GlobalAsm NodeId
A.J. Gardner [Thu, 30 Mar 2017 04:32:20 +0000 (23:32 -0500)]
Ensure walk_item visits GlobalAsm NodeId

Travis failures indicated the OuterVisitor#visit_item method caused a
panic. The Visitor's inner visitor actually relies on the visitor
visiting every item's NodeId. I forgot to perform that call in the
ItemGlobalAsm match arm, leading to build breakage. The fix is
simple: call visit_id(...) for ItemGlobalAsm

7 years agoAdd new TransItem for global_asm trans
A.J. Gardner [Tue, 21 Mar 2017 15:03:52 +0000 (10:03 -0500)]
Add new TransItem for global_asm trans

7 years agoExpand _ into explicit variants in match
A.J. Gardner [Fri, 17 Mar 2017 03:16:40 +0000 (22:16 -0500)]
Expand _ into explicit variants in match

7 years agoFirst attempt at global_asm! macro
A.J. Gardner [Thu, 16 Mar 2017 02:27:40 +0000 (21:27 -0500)]
First attempt at global_asm! macro

7 years agoAuto merge of #41008 - sagebind:thread_id, r=alexcrichton
bors [Wed, 12 Apr 2017 19:58:10 +0000 (19:58 +0000)]
Auto merge of #41008 - sagebind:thread_id, r=alexcrichton

Derive Hash for ThreadId + better example

Derive `Hash` for `ThreadId` (see comments in #21507). Useful for making maps based on thread, e.g. `HashMap<ThreadId, ?>`. Also update example code for thread IDs to be more useful.

7 years agorustc_trans: avoid a separate entry BB if START_BLOCK has no backedges.
Eduard-Mihai Burtescu [Wed, 8 Mar 2017 18:08:09 +0000 (20:08 +0200)]
rustc_trans: avoid a separate entry BB if START_BLOCK has no backedges.

7 years agorustc_trans: don't emit ZST allocas that are only assigned to.
Eduard-Mihai Burtescu [Wed, 8 Mar 2017 18:03:04 +0000 (20:03 +0200)]
rustc_trans: don't emit ZST allocas that are only assigned to.

7 years agosimplify code to remove now unused "stack" and fix comments
Niko Matsakis [Wed, 12 Apr 2017 16:51:19 +0000 (12:51 -0400)]
simplify code to remove now unused "stack" and fix comments

7 years agodo not consult union-find during `fudge_regions_if_ok`
Niko Matsakis [Wed, 12 Apr 2017 16:36:43 +0000 (12:36 -0400)]
do not consult union-find during `fudge_regions_if_ok`

7 years agoFixed invalid 128-bit division on 32-bit target. Fixed issue #41228.
kennytm [Wed, 12 Apr 2017 14:51:32 +0000 (22:51 +0800)]
Fixed invalid 128-bit division on 32-bit target. Fixed issue #41228.

Added test cases to cover all special-cased branches of udivmodti4.

7 years agoAuto merge of #41246 - TimNN:rollup, r=TimNN
bors [Wed, 12 Apr 2017 13:22:16 +0000 (13:22 +0000)]
Auto merge of #41246 - TimNN:rollup, r=TimNN

Rollup of 9 pull requests

- Successful merges: #41063, #41087, #41141, #41166, #41183, #41205, #41206, #41232, #41243
- Failed merges:

7 years agoRollup merge of #41243 - projektir:prim_str_docs, r=GuillaumeGomez
Tim Neumann [Wed, 12 Apr 2017 12:45:48 +0000 (14:45 +0200)]
Rollup merge of #41243 - projektir:prim_str_docs, r=GuillaumeGomez

Minor nits in primitive str

Some minor updates to linking, added some links, doc format, etc.

r? @GuillaumeGomez

7 years agoRollup merge of #41232 - arielb1:mir-rvalues, r=eddyb
Tim Neumann [Wed, 12 Apr 2017 12:45:47 +0000 (14:45 +0200)]
Rollup merge of #41232 - arielb1:mir-rvalues, r=eddyb

move rvalue checking to MIR

7 years agoRollup merge of #41206 - eddyb:avoid-illegal-vectors, r=nagisa
Tim Neumann [Wed, 12 Apr 2017 12:45:46 +0000 (14:45 +0200)]
Rollup merge of #41206 - eddyb:avoid-illegal-vectors, r=nagisa

Fix pairs of doubles using an illegal <8 x i8> vector.

Accidentally introduced in #40658 and discovered in some Objective-C bindings (returning `NSPoint`).
Turns out LLVM will widen element types of illegal vectors instead of increasing element count, i.e. it will zero-extend `<8 x i8>` to `<8 x i16>`, interleaving the bytes, instead of using the first 8 of `<16 x i8>`.

7 years agoRollup merge of #41205 - estebank:shorter-mismatched-types-2, r=nikomatsakis
Tim Neumann [Wed, 12 Apr 2017 12:45:45 +0000 (14:45 +0200)]
Rollup merge of #41205 - estebank:shorter-mismatched-types-2, r=nikomatsakis

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`
```

Fix #21025. Re: #40186. Follow up to #39906.

I'm looking to change how this output is accomplished so that it doesn't create list of strings to pass around, but rather add an elided `Ty` placeholder, and use the same string formatting for normal types. I'll be doing that soonish.

r? @nikomatsakis

7 years agoRollup merge of #41183 - nodakai:remove-hoedown-license, r=TimNN
Tim Neumann [Wed, 12 Apr 2017 12:45:44 +0000 (14:45 +0200)]
Rollup merge of #41183 - nodakai:remove-hoedown-license, r=TimNN

COPYRIGHT: remove hoedown license

Hoedown was removed in b96fef8411f

Also cleanup src/tools/tidy/src/main.rs

7 years agoRollup merge of #41166 - alexcrichton:update-cargo, r=brson
Tim Neumann [Wed, 12 Apr 2017 12:45:43 +0000 (14:45 +0200)]
Rollup merge of #41166 - alexcrichton:update-cargo, r=brson

Update cargo submodules

Brings in a fix for #40955 through rust-lang/cargo#3898.

Closes #40955

7 years agoRollup merge of #41141 - michaelwoerister:direct-metadata-ich-final, r=nikomatsakis
Tim Neumann [Wed, 12 Apr 2017 12:45:42 +0000 (14:45 +0200)]
Rollup merge of #41141 - michaelwoerister:direct-metadata-ich-final, r=nikomatsakis

ICH: Replace old, transitive metadata hashing with direct hashing approach.

This PR replaces the old crate metadata hashing strategy with a new one that directly (but stably) hashes all values we encode into the metadata. Previously we would track what data got accessed during metadata encoding and then hash the input nodes (HIR and upstream metadata) that were transitively reachable from the accessed data. While this strategy was sound, it had two major downsides:

1. It was susceptible to generating false positives, i.e. some input node might have changed without actually affecting the content of the metadata. That metadata entry would still show up as changed.
2. It was susceptible to quadratic blow-up when many metadata nodes shared the same input nodes, which would then get hashed over and over again.

The new method does not have these disadvantages and it's also a first step towards caching more intermediate results in the compiler.

Metadata hashing/cross-crate incremental compilation is still kept behind the `-Zincremental-cc` flag even after this PR. Once the new method has proven itself with more tests, we can remove the flag and enable cross-crate support by default again.

r? @nikomatsakis
cc @rust-lang/compiler

7 years agoRollup merge of #41087 - estebank:tuple-float-index, r=arielb1
Tim Neumann [Wed, 12 Apr 2017 12:45:41 +0000 (14:45 +0200)]
Rollup merge of #41087 - estebank:tuple-float-index, r=arielb1

Use proper span for tuple index parsed as float

Fix diagnostic suggestion from:

```rust
help: try parenthesizing the first index
  |     (1, (2, 3)).((1, (2, 3)).1).1;
```

to the correct:

```rust
help: try parenthesizing the first index
  |     ((1, (2, 3)).1).1;
```

Fix #41081.

7 years agoRollup merge of #41063 - nikomatsakis:issue-40746-always-exec-loops, r=eddyb
Tim Neumann [Wed, 12 Apr 2017 12:45:40 +0000 (14:45 +0200)]
Rollup merge of #41063 - nikomatsakis:issue-40746-always-exec-loops, r=eddyb

remove unnecessary tasks

Remove various unnecessary tasks. All of these are "always execute" tasks that don't do any writes to tracked state (or else an assert would trigger, anyhow). In some cases, they issue lints or errors, but we''ll deal with that -- and anyway side-effects outside of a task don't cause problems for anything that I can see.

The one non-trivial refactoring here is the borrowck conversion, which adds the requirement to go from a `DefId` to a `BodyId`. I tried to make a useful helper here.

r? @eddyb

cc #40746
cc @cramertj @michaelwoerister

7 years agoICH: Replace old, transitive metadata hashing with direct hashing approach.
Michael Woerister [Wed, 5 Apr 2017 21:39:02 +0000 (23:39 +0200)]
ICH: Replace old, transitive metadata hashing with direct hashing approach.

Instead of collecting all potential inputs to some metadata entry and
hashing those, we directly hash the values we are storing in metadata.
This is more accurate and doesn't suffer from quadratic blow-up when
many entries have the same dependencies.

7 years agoICH: Hash everything that gets encoded into crate metadata.
Michael Woerister [Wed, 5 Apr 2017 11:00:17 +0000 (13:00 +0200)]
ICH: Hash everything that gets encoded into crate metadata.

7 years agoMake compiletest write test output to different files for different revisions.
Michael Woerister [Thu, 6 Apr 2017 14:56:09 +0000 (16:56 +0200)]
Make compiletest write test output to different files for different revisions.

7 years agofix nit
Niko Matsakis [Wed, 12 Apr 2017 09:42:02 +0000 (05:42 -0400)]
fix nit

7 years agoAuto merge of #40765 - pirate:patch-3, r=aturon
bors [Wed, 12 Apr 2017 09:16:14 +0000 (09:16 +0000)]
Auto merge of #40765 - pirate:patch-3, r=aturon

Add contribution instructions to stdlib docs

Generally programming language docs have instructions on how to contribute changes.

I couldn't find any in the rust docs, so I figured I'd add an instructions section, let me know if this belongs somewhere else!

7 years agoAuto merge of #40584 - nrc:rls-submod, r=alexcrichton
bors [Wed, 12 Apr 2017 05:26:10 +0000 (05:26 +0000)]
Auto merge of #40584 - nrc:rls-submod, r=alexcrichton

Add the RLS as a submodule and build a package out of it

r? @brson (and cc @alexcrichton) Please review closely, I am not at all convinced I've done the right things here. I did run `x.py dist` and it makes an rls package which looks right to my eyes, but I haven't tested on non-linux platforms nor am I really sure what it should look like.

This does not attempt to run tests for the RLS yet.

7 years agoCOPYRIGHT: remove hoedown license
NODA, Kai [Mon, 10 Apr 2017 12:53:20 +0000 (20:53 +0800)]
COPYRIGHT: remove hoedown license

Hoedown was removed in b96fef8411f

Also cleanup src/tools/tidy/src/main.rs

Signed-off-by: NODA, Kai <nodakai@gmail.com>
7 years agoUpdating docs for std::sync::Weak #29377
projektir [Wed, 12 Apr 2017 02:29:42 +0000 (22:29 -0400)]
Updating docs for std::sync::Weak #29377

7 years agoMinor nits in primitive str
projektir [Wed, 12 Apr 2017 04:10:36 +0000 (00:10 -0400)]
Minor nits in primitive str

7 years agoAuto merge of #41237 - frewsxcv:rollup, r=frewsxcv
bors [Wed, 12 Apr 2017 00:45:49 +0000 (00:45 +0000)]
Auto merge of #41237 - frewsxcv:rollup, r=frewsxcv

Rollup of 8 pull requests

- Successful merges: #40377, #40559, #41173, #41202, #41204, #41209, #41216, #41231
- Failed merges:

7 years agofix long line
Niko Matsakis [Tue, 11 Apr 2017 21:12:00 +0000 (17:12 -0400)]
fix long line

7 years agoadd some debug! to coercion
Niko Matsakis [Tue, 11 Apr 2017 21:11:41 +0000 (17:11 -0400)]
add some debug! to coercion

7 years agoadd some comments and `debug!` calls to "obligation forest"
Niko Matsakis [Tue, 11 Apr 2017 21:11:22 +0000 (17:11 -0400)]
add some comments and `debug!` calls to "obligation forest"

7 years agojust panic in rustdoc if we encounter a subtype predicate
Niko Matsakis [Tue, 11 Apr 2017 21:11:05 +0000 (17:11 -0400)]
just panic in rustdoc if we encounter a subtype predicate

These are not user expressible anyhow.

7 years agoupdate various test cases that generate slightly different output
Niko Matsakis [Tue, 11 Apr 2017 21:10:26 +0000 (17:10 -0400)]
update various test cases that generate slightly different output

For the most part, it seems to be better, but one side-effect is that I
cannot seem to reproduce E0102 anymore.

7 years agogeneralize type variables too
Niko Matsakis [Tue, 11 Apr 2017 21:17:58 +0000 (17:17 -0400)]
generalize type variables too

When we are generalizing a super/sub-type, we have to replace type
variables with a fresh variable (and not just region variables).  So if
we know that `Box<?T> <: ?U`, for example, we instantiate `?U` with
`Box<?V>` and then relate `Box<?T>` to `Box<?V>` (and hence require that
`?T <: ?V`).

This change has some complex interactions, however:

First, the occurs check must be updated to detect constraints like `?T
<: ?U` and `?U <: Box<?T>`. If we're not careful, we'll create a
never-ending sequence of new variables. To address this, we add a second
unification set into `type_variables` that tracks type variables related
through **either** equality **or** subtyping, and use that during the
occurs-check.

Second, the "fudge regions if ok" code was expecting no new type
variables to be created. It must be updated to create new type variables
outside of the probe. This is relatively straight-forward under the new
scheme, since type variables are now independent from one another, and
any relations are moderated by pending subtype obliations and so forth.
This part would be tricky to backport though.

cc #18653
cc #40951

7 years agoavoid unneeded subtype obligations in lub/glb
Niko Matsakis [Tue, 11 Apr 2017 21:16:57 +0000 (17:16 -0400)]
avoid unneeded subtype obligations in lub/glb

In some specific cases, the new scheme was failing to learn as much from
a LUB/GLB operaiton as the old code, which caused coercion to go awry. A
slight ordering hack fixes this.

7 years agofix a bug in compiletest JSON parsing for duplicate errors
Niko Matsakis [Tue, 11 Apr 2017 20:58:04 +0000 (16:58 -0400)]
fix a bug in compiletest JSON parsing for duplicate errors

In some cases, we give multiple primary spans, in which case we would
report one `//~` annotation per primary span. That was very confusing
because these things are reported to the user as a single error.

UI tests would be better here.

7 years agoadd FIXME for bivariant lub/glb
Niko Matsakis [Mon, 3 Apr 2017 20:14:05 +0000 (16:14 -0400)]
add FIXME for bivariant lub/glb

7 years agoadd FIXME to #18653
Niko Matsakis [Mon, 3 Apr 2017 19:59:34 +0000 (15:59 -0400)]
add FIXME to #18653

7 years agoadd regression test for #30225
Niko Matsakis [Thu, 16 Mar 2017 13:58:21 +0000 (09:58 -0400)]
add regression test for #30225

Fixes #30225

7 years agoremove the subtyping relations from TypeVariable
Niko Matsakis [Thu, 16 Mar 2017 13:05:39 +0000 (09:05 -0400)]
remove the subtyping relations from TypeVariable

7 years agouse obligations to propagate sub-typing instead of the TV code
Niko Matsakis [Fri, 10 Mar 2017 10:21:27 +0000 (05:21 -0500)]
use obligations to propagate sub-typing instead of the TV code

7 years agopropagate sub-obligations better
Niko Matsakis [Fri, 10 Mar 2017 10:19:49 +0000 (05:19 -0500)]
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.

7 years agoadd Subtype predicate
Niko Matsakis [Fri, 10 Mar 2017 02:47:09 +0000 (21:47 -0500)]
add Subtype predicate

7 years agoremove bivariance
Niko Matsakis [Fri, 10 Mar 2017 18:30:09 +0000 (13:30 -0500)]
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.

7 years agoremove type variable defaults code
Niko Matsakis [Fri, 10 Mar 2017 02:29:22 +0000 (21:29 -0500)]
remove type variable defaults code

This just limits ourselves to the "old school" defaults: diverging
variables and integer variables.

7 years agoHighlight and simplify mismatched types
Esteban Küber [Fri, 17 Feb 2017 22:31:59 +0000 (14:31 -0800)]
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`
```

7 years agoRollup merge of #41231 - TimNN:fix-centos, r=frewsxcv
Corey Farwell [Tue, 11 Apr 2017 22:36:17 +0000 (18:36 -0400)]
Rollup merge of #41231 - TimNN:fix-centos, r=frewsxcv

Use correct vault URL in CentOS images

r? @frewsxcv

7 years agoRollup merge of #41216 - shahn:iter_pos, r=steveklabnik
Corey Farwell [Tue, 11 Apr 2017 22:36:16 +0000 (18:36 -0400)]
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

7 years agoRollup merge of #41209 - aidanhs:aphs-quiet-sccache, r=alexcrichton
Corey Farwell [Tue, 11 Apr 2017 22:36:16 +0000 (18:36 -0400)]
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](https://github.com/mozilla/sccache/blob/ec10cdb2ddeb3dde9891bea1fa095e504a60a28a/src/main.rs#L124-L128)).

r? @frewsxcv

7 years agoRollup merge of #41204 - remexre:master, r=steveklabnik
Corey Farwell [Tue, 11 Apr 2017 22:36:15 +0000 (18:36 -0400)]
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

7 years agoRollup merge of #41202 - brson:btree, r=nikomatsakis
Corey Farwell [Tue, 11 Apr 2017 22:36:14 +0000 (18:36 -0400)]
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.

7 years agoRollup merge of #41173 - GuillaumeGomez:fix-rustdoc-code-block-parsing, r=steveklabnik
Corey Farwell [Tue, 11 Apr 2017 22:36:13 +0000 (18:36 -0400)]
Rollup merge of #41173 - GuillaumeGomez:fix-rustdoc-code-block-parsing, r=steveklabnik

Fix block code headers parsing

Fixes #41167.

r? @rust-lang/docs

7 years agoRollup merge of #40559 - nagisa:manually-drop, r=alexcrichton
Corey Farwell [Tue, 11 Apr 2017 22:36:12 +0000 (18:36 -0400)]
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.

7 years agoRollup merge of #40377 - camlorn:optimization_fuel, r=eddyb
Corey Farwell [Tue, 11 Apr 2017 22:36:12 +0000 (18:36 -0400)]
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.