Commit Graph

63227 Commits

Author SHA1 Message Date
Niko Matsakis
bc79f01a58 create ModuleTranslation all in one big loop 2017-04-13 18:33:09 -04:00
Niko Matsakis
6cb516ad7b move assert_module_sources call down below 2017-04-13 18:33:09 -04:00
Niko Matsakis
fe78b546ed merge the "predeclare" and "declare" phases so we run them per-CGU 2017-04-13 18:33:09 -04:00
Niko Matsakis
33875055f0 redirect exported_symbols through shared 2017-04-13 18:33:09 -04:00
Niko Matsakis
7b429242a5 remove unused link_meta 2017-04-13 18:33:09 -04:00
Niko Matsakis
b078ecefcd rewrite to pass a ref, not slice + index 2017-04-13 18:33:09 -04:00
Niko Matsakis
15507bcb64 remove metadata_* from SharedCrateContext
No good reason for them to be in there.
2017-04-13 18:33:09 -04:00
steveklabnik
537eb45b9d Update various bookshelf repositories.
The book and the reference have both had changes lately; this integrates
them upstream.
2017-04-13 18:15:40 -04:00
lukaramu
89ac8654e1 Various consistency and phrasing fixes in std::collections' docs
* Changed btree_map's and hash_map's Entry (etc.) docs to be consistent
* Changed VecDeque's type and module summary sentences to be consistent
  with each other as well as with other summary sentences in the module
* Changed HashMap's and HashSet's summary sentences to be less redundantly
  phrased and also more consistant with the other summary sentences in the
  module
* Also, added an example to Bound
2017-04-13 22:51:05 +02:00
lukaramu
d688c4d806 Various fixes throughout std::collections' docs
* Added links where possible (limited because of facading)
* Changed references to methods from `foo()` to `foo` in module docs
* Changed references to methods from `HashMap::foo` to just `foo` in
  top-level docs for `HashMap` and the `default` doc for `DefaultHasher`
* Various small other fixes
2017-04-13 22:51:05 +02:00
lukaramu
d64de94efa Update std::collections' docs to use iterator (etc.) boilerplate
This greatly improves consistency.
2017-04-13 22:51:05 +02:00
bors
28a7429977 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
2017-04-13 20:21:12 +00:00
Ariel Ben-Yehuda
03b0d99556 rustc_typeck: consolidate adjustment composition
Fixes #41213.
2017-04-13 21:27:35 +03:00
bors
ea376822a1 Auto merge of #41277 - frewsxcv:rollup, r=frewsxcv
Rollup of 3 pull requests

- Successful merges: #41240, #41250, #41266
- Failed merges:
2017-04-13 17:32:22 +00:00
Corey Farwell
6afb2c48d9 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
2017-04-13 13:04:16 -04:00
Corey Farwell
6dfd8f6e12 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: 1dca19ae3f/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 280d19f112/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`.
2017-04-13 13:04:15 -04:00
Corey Farwell
9eb3468e2f 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
2017-04-13 13:04:14 -04:00
Alex Crichton
2a33559207 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
2017-04-13 09:47:00 -07:00
bors
43ef63d5b4 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
2017-04-13 11:47:33 +00:00
bors
1f59c7ebb1 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.
2017-04-13 09:16:11 +00:00
bors
6c03efd8f3 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.)
2017-04-13 06:46:29 +00:00
A.J. Gardner
63a074791e 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.
2017-04-13 00:49:13 -05:00
Alex Crichton
cdedecb7ba 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.
2017-04-12 20:48:18 -07:00
projektir
f84cc0c0d0 Updating docs for std::rc::Rc 2017-04-12 22:57:49 -04:00
bors
d2e2ad559e 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.
2017-04-13 00:28:11 +00:00
Scott McMurray
7ec27ae63d 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.
2017-04-12 17:21:15 -07:00
A.J. Gardner
24a89a015e Replace ExpnId with SyntaxContext 2017-04-12 19:12:50 -05:00
A.J. Gardner
da0742c070 Add global_asm tests 2017-04-12 19:12:50 -05:00
A.J. Gardner
4b9de4cc63 Update unstable book with global_asm feature 2017-04-12 19:12:49 -05:00
A.J. Gardner
9240054b3e Expose LLVM appendModuleInlineAsm 2017-04-12 19:12:49 -05:00
A.J. Gardner
7be5043fd9 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
2017-04-12 19:12:49 -05:00
A.J. Gardner
70fcff6318 Add new TransItem for global_asm trans 2017-04-12 19:12:49 -05:00
A.J. Gardner
6bcd5b0980 Expand _ into explicit variants in match 2017-04-12 19:12:49 -05:00
A.J. Gardner
768e902941 First attempt at global_asm! macro 2017-04-12 19:12:49 -05:00
bors
14481f7210 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.
2017-04-12 19:58:10 +00:00
Eduard-Mihai Burtescu
9b5c577dbd rustc_trans: avoid a separate entry BB if START_BLOCK has no backedges. 2017-04-12 20:20:53 +03:00
Eduard-Mihai Burtescu
cb3c4d022a rustc_trans: don't emit ZST allocas that are only assigned to. 2017-04-12 20:20:53 +03:00
Niko Matsakis
1cc7621dec simplify code to remove now unused "stack" and fix comments 2017-04-12 13:03:47 -04:00
Niko Matsakis
fa437f49af do not consult union-find during fudge_regions_if_ok 2017-04-12 12:36:43 -04:00
kennytm
71a9e10669
Fixed invalid 128-bit division on 32-bit target. Fixed issue #41228.
Added test cases to cover all special-cased branches of udivmodti4.
2017-04-13 00:15:04 +08:00
Guillaume Gomez
dd7dfe56a9 Fix invalid associated type rendering in rustdoc 2017-04-12 18:14:54 +02:00
bors
910c4816fd 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:
2017-04-12 13:22:16 +00:00
Tim Neumann
d4d35cfecc 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
2017-04-12 14:45:48 +02:00
Tim Neumann
1dd9801fa5 Rollup merge of #41232 - arielb1:mir-rvalues, r=eddyb
move rvalue checking to MIR
2017-04-12 14:45:47 +02:00
Tim Neumann
092f19ac99 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>`.
2017-04-12 14:45:46 +02:00
Tim Neumann
afb300d831 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
2017-04-12 14:45:45 +02:00
Tim Neumann
5c23e7089d Rollup merge of #41183 - nodakai:remove-hoedown-license, r=TimNN
COPYRIGHT: remove hoedown license

Hoedown was removed in b96fef8411

Also cleanup src/tools/tidy/src/main.rs
2017-04-12 14:45:44 +02:00
Tim Neumann
9275c9c2f0 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
2017-04-12 14:45:43 +02:00
Tim Neumann
1b006b78a6 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
2017-04-12 14:45:42 +02:00
Tim Neumann
918e35a9bd 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.
2017-04-12 14:45:41 +02:00