Commit Graph

63141 Commits

Author SHA1 Message Date
Guillaume Gomez bee0291320 Add hoedown COPYRIGHT back 2017-04-17 18:10:03 +02:00
Guillaume Gomez 695354af9c Remove hoedown from tidy check 2017-04-17 18:10:03 +02:00
Guillaume Gomez cbf8342efe Hoedown big comeback! 2017-04-17 18:10:03 +02: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
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
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
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
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
Tim Neumann 49082ae9f2 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
2017-04-12 14:45:40 +02:00
Michael Woerister ca2dce9b48 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.
2017-04-12 11:47:26 +02:00
Michael Woerister bc7af816f3 ICH: Hash everything that gets encoded into crate metadata. 2017-04-12 11:42:15 +02:00
Michael Woerister c008cd70f5 Make compiletest write test output to different files for different revisions. 2017-04-12 11:42:15 +02:00
Niko Matsakis 2e327a668e fix nit 2017-04-12 05:42:02 -04:00
bors 1dca19ae3f 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!
2017-04-12 09:16:14 +00:00
bors 8c6e2ff452 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.
2017-04-12 05:26:10 +00:00
NODA, Kai f39145169f
COPYRIGHT: remove hoedown license
Hoedown was removed in b96fef8411

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

Signed-off-by: NODA, Kai <nodakai@gmail.com>
2017-04-12 12:54:27 +08:00
projektir ed7b6c3724 Minor nits in primitive str 2017-04-12 00:10:36 -04:00
bors da32752d92 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:
2017-04-12 00:45:49 +00:00
Niko Matsakis 7832db8031 fix long line 2017-04-11 20:32:48 -04:00
Niko Matsakis 0fae3324a2 add some debug! to coercion 2017-04-11 20:32:48 -04:00
Niko Matsakis 59babd80bd add some comments and `debug!` calls to "obligation forest" 2017-04-11 20:32:48 -04:00
Niko Matsakis 761808ef40 just panic in rustdoc if we encounter a subtype predicate
These are not user expressible anyhow.
2017-04-11 20:32:48 -04:00
Niko Matsakis 1c138ed1c7 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.
2017-04-11 20:32:48 -04:00
Niko Matsakis bca56e82a1 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
2017-04-11 20:32:47 -04:00
Niko Matsakis 3a5bbf89b2 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.
2017-04-11 20:32:47 -04:00
Niko Matsakis 14f1e3459f 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.
2017-04-11 20:32:47 -04:00
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