Commit Graph

74520 Commits

Author SHA1 Message Date
John Kåre Alsaker
77bc26f4f3 Require yield types to be sized 2018-01-29 10:02:04 +01:00
John Kåre Alsaker
7a6f68c872 Make error reporting work on generator upvars. Fixes #47793, #47805 2018-01-29 10:02:03 +01:00
John Kåre Alsaker
dd3fa07a52 Make yield_in_scope_for_expr work with patterns. Fixes #47758 2018-01-29 10:02:03 +01:00
John Kåre Alsaker
ad058cfafe Make pattern visiting consistent 2018-01-29 10:02:03 +01:00
Manish Goregaokar
540f95d9fa Add internal-only rustc_serialize_exclude_null attribute for making the field only exist in the json if the flag is passed 2018-01-29 11:41:03 +05:30
Manish Goregaokar
a53bdc6212 Add -Zapproximate-suggestions 2018-01-29 11:41:02 +05:30
Manish Goregaokar
937bc2e04a Add approximate suggestions for rustfix
This adds `span_approximate_suggestion()` that lets you emit a
suggestion marked as "approximate" in the JSON output. UI
users see no difference. This is for when rustc and clippy wish to
 emit suggestions which will make sense to the reader (e.g. they may
have placeholders like `<type>`) but are not source-applicable, so that
rustfix/etc can ignore these.

fixes #39254
2018-01-29 11:40:50 +05:30
bors
679f30e1aa Auto merge of #47730 - alexcrichton:multitrans, r=Mark-Simulacrum
rustc: Split Emscripten to a separate codegen backend

This commit introduces a separately compiled backend for Emscripten, avoiding
compiling the `JSBackend` target in the main LLVM codegen backend. This builds
on the foundation provided by #47671 to create a new codegen backend dedicated
solely to Emscripten, removing the `JSBackend` of the main codegen backend in
the process.

A new field was added to each target for this commit which specifies the backend
to use for translation, the default being `llvm` which is the main backend that
we use. The Emscripten targets specify an `emscripten` backend instead of the
main `llvm` one.

There's a whole bunch of consequences of this change, but I'll try to enumerate
them here:

* A *second* LLVM submodule was added in this commit. The main LLVM submodule
  will soon start to drift from the Emscripten submodule, but currently they're
  both at the same revision.
* Logic was added to rustbuild to *not* build the Emscripten backend by default.
  This is gated behind a `--enable-emscripten` flag to the configure script. By
  default users should neither check out the emscripten submodule nor compile
  it.
* The `init_repo.sh` script was updated to fetch the Emscripten submodule from
  GitHub the same way we do the main LLVM submodule (a tarball fetch).
* The Emscripten backend, turned off by default, is still turned on for a number
  of targets on CI. We'll only be shipping an Emscripten backend with Tier 1
  platforms, though. All cross-compiled platforms will not be receiving an
  Emscripten backend yet.

This commit means that when you download the `rustc` package in Rustup for Tier
1 platforms you'll be receiving two trans backends, one for Emscripten and one
that's the general LLVM backend. If you never compile for Emscripten you'll
never use the Emscripten backend, so we may update this one day to only download
the Emscripten backend when you add the Emscripten target. For now though it's
just an extra 10MB gzip'd.

Closes #46819
2018-01-29 04:55:47 +00:00
penpalperson
81e49597bf Added inline to fmt for debug implementations of primitives. 2018-01-28 21:55:05 -07:00
Corey Farwell
7b4cbbd12d Document that Index ops can panic on HashMap & BTreeMap.
Fixes https://github.com/rust-lang/rust/issues/47011.
2018-01-28 21:51:33 -05:00
Alex Crichton
c6daea7c9a rustc: Split Emscripten to a separate codegen backend
This commit introduces a separately compiled backend for Emscripten, avoiding
compiling the `JSBackend` target in the main LLVM codegen backend. This builds
on the foundation provided by #47671 to create a new codegen backend dedicated
solely to Emscripten, removing the `JSBackend` of the main codegen backend in
the process.

A new field was added to each target for this commit which specifies the backend
to use for translation, the default being `llvm` which is the main backend that
we use. The Emscripten targets specify an `emscripten` backend instead of the
main `llvm` one.

There's a whole bunch of consequences of this change, but I'll try to enumerate
them here:

* A *second* LLVM submodule was added in this commit. The main LLVM submodule
  will soon start to drift from the Emscripten submodule, but currently they're
  both at the same revision.
* Logic was added to rustbuild to *not* build the Emscripten backend by default.
  This is gated behind a `--enable-emscripten` flag to the configure script. By
  default users should neither check out the emscripten submodule nor compile
  it.
* The `init_repo.sh` script was updated to fetch the Emscripten submodule from
  GitHub the same way we do the main LLVM submodule (a tarball fetch).
* The Emscripten backend, turned off by default, is still turned on for a number
  of targets on CI. We'll only be shipping an Emscripten backend with Tier 1
  platforms, though. All cross-compiled platforms will not be receiving an
  Emscripten backend yet.

This commit means that when you download the `rustc` package in Rustup for Tier
1 platforms you'll be receiving two trans backends, one for Emscripten and one
that's the general LLVM backend. If you never compile for Emscripten you'll
never use the Emscripten backend, so we may update this one day to only download
the Emscripten backend when you add the Emscripten target. For now though it's
just an extra 10MB gzip'd.

Closes #46819
2018-01-28 18:32:45 -08:00
Andy Russell
043d4615f2
use correct casing for rename suggestions
If the original name is uppercase, use camel case. Otherwise, use snake
case.
2018-01-28 20:48:54 -05:00
Esteban Küber
871856e831 Highlight code on diagnostics when underlined 2018-01-28 17:15:15 -08:00
Esteban Küber
67696be160 Point only at method signatures and point at trait
- On mismatch between impl and trait method, point at the trait
   signature.
 - Point only at the method signature instead of the whole body on
   trait/impl mismatch errors.
2018-01-28 17:06:30 -08:00
Eduard-Mihai Burtescu
46a9bdda78 rustc: replace "lvalue" terminology with "place" in the code. 2018-01-29 01:49:29 +02:00
bors
385ef1514c Auto merge of #47663 - malbarbo:mips-crt-static, r=alexcrichton
Do not assume dynamic linking for musl/mips[el] targets

All musl targets except mips[el] assume static linking by default. This can be [confusing](https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084).

When the musl/mips[el] targets was [added](https://github.com/rust-lang/rust/pull/31298), dynamic linking was chosen because of binary size concerns, and probably also because libunwind [didn't](https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084/8) supported mips.

Now that we have `crt-static` target-feature (the user can choose dynamic link for musl targets), and libunwind [6.0](https://github.com/llvm-mirror/libunwind/commits/release_60) add support to mips, we do not need to assume dynamic linking.
2018-01-28 23:30:15 +00:00
Eduard-Mihai Burtescu
06a0e4f7ae rustc: move expr_is_lval to rustc_typeck and rename to is_place_expr. 2018-01-29 01:24:25 +02:00
Eduard-Mihai Burtescu
3f4a489f8f rustc_typeck: rename LvalueOp to PlaceOp. 2018-01-29 01:20:18 +02:00
Mark Simulacrum
caa42e11bb Remove VecCell 2018-01-28 16:01:32 -07:00
Mark Simulacrum
505ef7bc06 Remove unused blake2b implementation 2018-01-28 16:01:32 -07:00
Eduard-Mihai Burtescu
2c4a75bf09 rustc_typeck: rename LvaluePreference::PreferMutLvalue to Needs::MutPlace. 2018-01-29 00:59:25 +02:00
Eduard-Mihai Burtescu
800166cf96 rustc: remove LvaluePreference argument from Ty::builtin_deref. 2018-01-29 00:42:51 +02:00
Esteban Küber
6c026997bf For named lifetimes point only at method signature
When refering to named lifetime conflict, point only at the method's
signature span instead of the entire method.

When the expected and found sup and sub traces are the same, avoid
redundant text.
2018-01-28 12:07:03 -08:00
Esteban Küber
b7437c56f8 Suggest removing value from break when invalid 2018-01-28 11:14:09 -08:00
bors
21882aad72 Auto merge of #47204 - varkor:unsafecell-into_inner-safe, r=alexcrichton
Make UnsafeCell::into_inner safe

This fixes #35067. It will require a Crater run as discussed in that
issue.
2018-01-28 19:01:51 +00:00
gnzlbg
b32dbbc67e
Whitelist v7 feature for ARM and AARCH64.
Needed for `v7` features in `coresimd`. 

See b2f7be24d5/coresimd/src/arm/v7.rs (L40) which used to work but doesn't anymore.

r? alexcrichton
2018-01-28 18:50:03 +01:00
bors
771873c841 Auto merge of #47800 - Pulkit07:issue47755, r=sfackler
don't mention tasks in stability warnings of #[thread_local] #47755

This is a fix for issue #47755.
2018-01-28 16:17:18 +00:00
bors
5e7fd65419 Auto merge of #47794 - etaoins:fix-ice-on-const-eval-of-union-field, r=eddyb
Fix ICE on const eval of union field

MIR's `Const::get_field()` attempts to retrieve the value for a given field in a constant. In the case of a union constant it was falling through to a generic `const_get_elt` based on the field index. As union fields don't have an index this caused an ICE in `llvm_field_index`.

Fix by simply returning the current value when accessing any field in a union. This works because all union fields start at byte offset 0.

The added test uses `const_fn` it ensure the field is extracted using MIR's const evaluation. The crash is reproducible without it, however.

Fixes #47788

r? @eddyb
2018-01-28 13:24:47 +00:00
gnzlbg
2497d10ff3
Whitelist aes x86 feature flag
Required to fix https://github.com/rust-lang-nursery/stdsimd/issues/295 in stdsimd.

r? @alexcrichton
2018-01-28 13:47:06 +01:00
bors
0119b44270 Auto merge of #47772 - arthurprs:iter-position-bounds-check, r=dtolnay
Use the slice length to hint the optimizer about iter.position result

Using the len of the iterator doesn't give the same result.
That's also why we can't generalize it to all TrustedLen iterators.

Problem demo: https://godbolt.org/g/MXg2ae
Fix demo: https://godbolt.org/g/P8q5aZ

Second attempt of #47333
Third attempt of #45501
Fixes #45964
2018-01-28 10:41:34 +00:00
bors
7046a40623 Auto merge of #47767 - estebank:as-suggestion, r=petrochenkov
Correctly format `extern crate` conflict resolution help

Closes #45799. Follow up to @Cldfire's #45820.

If the `extern` statement that will have a suggestion ends on a `;`, synthesize a new span that doesn't include it.
2018-01-28 07:44:14 +00:00
bors
87990a119a Auto merge of #47671 - alexcrichton:trans-c-api-only, r=Mark-Simulacrum
rustc: Load the `rustc_trans` crate at runtime

Building on the work of #45684 this commit updates the compiler to
unconditionally load the `rustc_trans` crate at runtime instead of linking to it
at compile time. The end goal of this work is to implement #46819 where rustc
will have multiple backends available to it to load.

This commit starts off by removing the `extern crate rustc_trans` from the
driver. This involved moving some miscellaneous functionality into the
`TransCrate` trait and also required an implementation of how to locate and load
the trans backend. This ended up being a little tricky because the sysroot isn't
always the right location (for example `--sysroot` arguments) so some extra code
was added as well to probe a directory relative to the current dll (the
rustc_driver dll).

Rustbuild has been updated accordingly as well to have a separate compilation
invocation for the `rustc_trans` crate and assembly it accordingly into the
sysroot. Finally, the distribution logic for the `rustc` package was also
updated to slurp up the trans backends folder.

A number of assorted fallout changes were included here as well to ensure tests
pass and such, and they should all be commented inline.
2018-01-28 03:40:26 +00:00
Alex Crichton
884715c654 rustc: Load the rustc_trans crate at runtime
Building on the work of # 45684 this commit updates the compiler to
unconditionally load the `rustc_trans` crate at runtime instead of linking to it
at compile time. The end goal of this work is to implement # 46819 where rustc
will have multiple backends available to it to load.

This commit starts off by removing the `extern crate rustc_trans` from the
driver. This involved moving some miscellaneous functionality into the
`TransCrate` trait and also required an implementation of how to locate and load
the trans backend. This ended up being a little tricky because the sysroot isn't
always the right location (for example `--sysroot` arguments) so some extra code
was added as well to probe a directory relative to the current dll (the
rustc_driver dll).

Rustbuild has been updated accordingly as well to have a separate compilation
invocation for the `rustc_trans` crate and assembly it accordingly into the
sysroot. Finally, the distribution logic for the `rustc` package was also
updated to slurp up the trans backends folder.

A number of assorted fallout changes were included here as well to ensure tests
pass and such, and they should all be commented inline.
2018-01-27 19:16:21 -08:00
bors
6beb06ee5e Auto merge of #47746 - varkor:never-type-ice, r=nikomatsakis
Fix never-type rvalue ICE

This fixes #43061.
r? @nikomatsakis

A small post-mortem as a follow-up to our investigations in https://github.com/rust-lang/rust/pull/47291:
The problem as I understand it is that when `NeverToAny` coercions are made, the expression/statement that is coerced may be enclosed in a block. In our case, the statement `x;` was being transformed to something like: `NeverToAny( {x;} )`. Then, `NeverToAny` is transformed into an expression:
000fbbc9b8/src/librustc_mir/build/expr/into.rs (L52-L59)
Which ends up calling `ast_block_stmts` on the block `{x;}`, which triggers this condition:
000fbbc9b8/src/librustc_mir/build/block.rs (L141-L147)
In our case, there is no return expression, so `push_assign_unit` is called. But the block has already been recorded as _diverging_, meaning the result of the block will be assigned to a location of type `!`, rather than `()`. This causes the MIR error.
I'm assuming the `NeverToAny` coercion code is doing what it's supposed to (there don't seem to be any other problems), so fixing the issue simply consists of checking that the destination for the return value actually _is_ supposed to be a unit. (If no return value is given, the only other possible type for the return value is `!`, which can just be ignored, as it will be unreachable anyway.)

I checked the other cases of `push_assign_unit`, and it didn't look like they could be affected by the divergence issue (blocks are kind of special-cased in this regard as far as I can tell), so this should be sufficient to fix the issue.
2018-01-28 00:40:10 +00:00
Marco A L Barbosa
2875f825fd Remove musl/libunwind patch for i686
The i686 problem was fixed upstream:
aa805e415f
2018-01-27 20:57:10 -02:00
leonardo.yvens
b813718f6d Refactor away fn must_be_known_in_context 2018-01-27 18:17:44 -02:00
leonardo.yvens
f8c140465f Only closure analysis should run after fallback.
Move `check_casts` and `resolve_generator_interiors` to before fallback.

Rename `apply_fallback_if_possible` to `fallback_if_possible`.

Refactor `select_all_obligations_or_error`.
2018-01-27 18:02:12 -02:00
bors
7d6e5b9da0 Auto merge of #47420 - davidtwco:issue-46885, r=estebank
Fix off-by-one spans in MIR borrowck errors

Fixes #46885.

r? @nikomatsakis
2018-01-27 19:41:40 +00:00
Vadim Petrochenkov
f57ea7cb3d Make + in impl/dyn Trait non-associative 2018-01-27 22:38:28 +03:00
Vadim Petrochenkov
d79f7cde06 Add tests 2018-01-27 22:37:30 +03:00
Vadim Petrochenkov
95d27c3b79 syntax: Permit + in return types of function declarations
`+` is still disallowed in function types and function-like traits
2018-01-27 22:37:30 +03:00
Vadim Petrochenkov
873b77531c syntax: Lower priority of + in impl Trait/dyn Trait 2018-01-27 22:37:30 +03:00
leonardo.yvens
cd4de4cece Suppress unknown cast errors in the presence of other errors. 2018-01-27 15:42:55 -02:00
leonardo.yvens
4c0ff95e6e Be more explicit about how and why we need fallback in targets of casts 2018-01-27 15:42:54 -02:00
leonardo.yvens
02084f3304 No fallback in structurally_resolve_types. Further refactoring.
Put all fallback in `apply_fallback_if_possible`.
2018-01-27 15:42:54 -02:00
leonardo.yvens
f3cd4a7f64 Refactor away fn default_type_parameters
It had only one caller.
2018-01-27 15:42:54 -02:00
leonardo.yvens
3d83fc914a Lazy numeric fallback.
This refactoring tries to make numeric fallback easier to reason about.
Instead of applying all fallbacks at an arbitrary point in the middle
of inference, we apply the fallback only when necessary and only for
the variable that requires it, which for numeric fallback turns out to
be just casts.

The only visible consequence seems to be some error messages where
instead of getting `i32` we get `{integer}` because we are less eager
about fallback.

The bigger goal is to make it easier to integrate user fallbacks into
inference, if we ever figure that out.
2018-01-27 15:42:54 -02:00
leonardo.yvens
c01bfbd02b refactor structurally_resolve_type
the `or_else` part was dead code.
2018-01-27 15:42:53 -02:00
Peter Hrvola
80b8c808ba Optimized error reporting for recursive requirements #47720 2018-01-27 18:19:39 +01:00
David Wood
970fb1a77f
Added logging for error suppression. 2018-01-27 17:16:13 +00:00