Commit Graph

76134 Commits

Author SHA1 Message Date
Scott McMurray
817efc2489 Suggest try if someone uses do catch 2018-08-19 16:53:42 -07:00
Scott McMurray
91967a8f16 Put try in the reserved list, not the in-use list 2018-08-19 16:53:41 -07:00
Scott McMurray
ef198867a7 Fix the unstable book
I ignored the code block as I didn't see a way to run the doctest in 2018 -- I noticed the edition guide is also not testing its 2018 code snippits.
2018-08-19 16:53:41 -07:00
Scott McMurray
9e64ce1799 Parse try blocks with the try keyword instead of do catch placeholder 2018-08-19 16:53:05 -07:00
Scott McMurray
1c906093f9 Add try to syntax_pos as an edition-2018-only keyword 2018-08-19 16:30:53 -07:00
Scott McMurray
f2445fb507 Rename Catch variants to TryBlock
(Not `Try` since `QuestionMark` is using that.)
2018-08-19 16:30:53 -07:00
bors
f28f648a96 Auto merge of #53316 - tristanburgess:52895_existential_type_ICE, r=oli-obk
52985: cause cycle err on inf trait normalization

Issue: #52985
 - If an existential type is defined, but no user code infers the
concrete type behind the existential type, normalization would
infinitely recurse on this existential type which is only defined in
terms of itself.
  - Instead of raising an inf recurse error, we cause a cycle error to
help highlight that the issue is that the type is only defined in terms
of itself.
  - Three known potential improvements:
    - If type folding itself was exposed as a query, used by
normalization and other mechanisms, cases that would cause infinite recursion would
automatically cause a cycle error.
    - The span for the cycle error should be improved to point to user
code that fails to allow inference of the concrete type of the existential type,
assuming that this error occurs because no user code can allow inference the
concrete type.
    - A mechanism to extend the cycle error with a helpful note would be nice. Currently,
the error is built and maintained by src/librustc/ty/query/plumbing,
with no known way to extend the information that the error gets built
with.

r? @oli-obk
2018-08-19 21:03:12 +00:00
bors
3ac79c7184 Auto merge of #53258 - nikomatsakis:issue-53189-optimize-reassignment-immutable-state, r=pnkfelix
optimize reassignment immutable state

This is the "simple fix" when it comes to checking for reassignment. We just shoot for compatibility with the AST-based checker. Makes no attempt to solve #21232.

I opted for this simpler fix because I didn't want to think about complications [like the ones described here](https://github.com/rust-lang/rust/issues/21232#issuecomment-412219247).

Let's do some profiling measurements.

Fixes #53189

r? @pnkfelix
2018-08-19 17:44:43 +00:00
bors
bfc3b20663 Auto merge of #53248 - nikomatsakis:nll-trivial-sized-predicate, r=eddyb
skip trivial `Sized` predicates

This came to about a 2% win for me in cargo. Small, but hey.

r? @eddyb
2018-08-19 15:22:18 +00:00
Niko Matsakis
58e4b54bd4 move tests to borrowck directory, remove feature(nll)
now compare-mode can show us the differences
2018-08-19 08:15:13 -07:00
Niko Matsakis
4e50c5b6e4 add tests for assigning fields without initializing var
We did not seem to have any!
2018-08-19 07:35:07 -07:00
Niko Matsakis
78e987ab8f just check whether a variable is initialized
Don't iterate over all things that are initialized.
2018-08-19 07:34:44 -07:00
Niko Matsakis
a8a982bb61 treat local variables specially 2018-08-19 07:34:43 -07:00
bors
b355906919 Auto merge of #51131 - qnighy:unsized-locals, r=eddyb
Implement Unsized Rvalues

This PR is the first step to implement RFC1909: unsized rvalues (#48055).

## Implemented

- `Sized` is removed for arguments and local bindings. (under `#![feature(unsized_locals)]`)
- Unsized locations are allowed in MIR
- Unsized places and operands are correctly translated at codegen

## Not implemented in this PR

- Additional `Sized` checks:
  - tuple struct constructor (accidentally compiles now)
  - closure arguments at closure generation (accidentally compiles now)
  - upvars (ICEs now)
- Generating vtable for `fn method(self)` (ICEs now)
- VLAs: `[e; n]` where `n` isn't const
- Reduce unnecessary allocations

## Current status

- [x] Fix `__rust_probestack` (rust-lang-nursery/compiler-builtins#244)
  - [x] Get the fix merged
- [x] `#![feature(unsized_locals)]`
  - [x] Give it a tracking issue number
- [x] Lift sized checks in typeck and MIR-borrowck
  - [ ] <del>Forbid `A(unsized-expr)`</del> will be another PR
- [x] Minimum working codegen
- [x] Add more examples and fill in unimplemented codegen paths
- [ ] <del>Loosen object-safety rules (will be another PR)</del>
- [ ] <del>Implement `Box<FnOnce>` (will be another PR)</del>
- [ ] <del>Reduce temporaries (will be another PR)</del>
2018-08-19 12:21:56 +00:00
bors
8928de7439 Auto merge of #52972 - RalfJung:from_raw_parts_align, r=alexcrichton
debug_assert to ensure that from_raw_parts is only used properly aligned

This does not help nearly as much as I would hope because everybody uses the distributed libstd which is compiled without debug assertions. For this reason, I am not sure if this is even worth it. OTOH, this would have caught the misalignment fixed by https://github.com/rust-lang/rust/issues/42789 *if* there had been any tests actually using ZSTs with alignment >1 (we have a CI runner which has debug assertions in libstd enabled), and it seems to currently [fail in the rg testsuite](https://ci.appveyor.com/project/rust-lang/rust/build/1.0.8403/job/v7dfdcgn8ay5j6sb). So maybe it is worth it, after all.

I have seen the attribute `#[rustc_inherit_overflow_checks]` in some places, does that make it so that the *caller's* debug status is relevant? Is there a similar attribute for `debug_assert!`? That could even subsume `rustc_inherit_overflow_checks`: Something like `rustc_inherit_debug_flag` could affect *all* places that change the generated code depending on whether we are in debug or release mode. In fact, given that we have to keep around the MIR for generic functions anyway, is there ever a reason *not* to handle the debug flag that way? I guess currently we apply debug flags like `cfg` so this is dropped early during the MIR pipeline?

EDIT: I learned from @eddyb that because of how `debug_assert!` works, this is not realistic. Well, we could still have it for the rustc CI runs and then maybe, eventually, when libstd gets compiled client-side and there is both a debug and a release build... then this will also benefit users.^^
2018-08-19 09:40:36 +00:00
Masaki Hara
c488d59add Integrate OperandValue::UnsizedRef into OperandValue::Ref. 2018-08-19 08:07:33 +09:00
Masaki Hara
6e15e7c126 Integrate PassMode::UnsizedIndirect into PassMode::Indirect. 2018-08-19 08:07:33 +09:00
Masaki Hara
a0c422a752 Remove a now-unnecessary paragraph.
The paragraph described a case where we can't optimize away repetitive
dynamic stack allocation. However, as arielb1 pointed out, it can
actually optimizable by dynamically delaying the stack unwinding.
2018-08-19 08:07:33 +09:00
Masaki Hara
438edc3d5e Update the unstable book regarding [e; dyn n]. 2018-08-19 08:07:33 +09:00
Masaki Hara
c72e87e30a Add an unstable-book article about unsized_locals. 2018-08-19 08:07:33 +09:00
Masaki Hara
800f2c13a3 Implement simple codegen for unsized rvalues. 2018-08-19 08:07:33 +09:00
Masaki Hara
e2b95cb70e Lift some Sized checks. 2018-08-19 08:07:33 +09:00
Masaki Hara
7f05304068 Add #![feature(unsized_locals)]. 2018-08-19 08:07:33 +09:00
Masaki Hara
cd0476a390 Add Builder::array_alloca. 2018-08-19 08:06:42 +09:00
Masaki Hara
9f0168a9f3 Add notes on unsized argument errors. 2018-08-19 08:06:42 +09:00
bors
a9fe312b98 Auto merge of #52592 - eddyb:or-default, r=Mark-Simulacrum
Use the new Entry::or_default method where possible.
2018-08-18 21:58:37 +00:00
bors
33b923fd44 Auto merge of #53324 - alexreg:self_in_typedefs, r=eddyb
`Self` in type definitions (self_in_typedefs)

This implements the [`self_in_typedefs` feature](https://github.com/rust-lang/rfcs/blob/master/text/2300-self-in-typedefs.md) ([tracking issue 49303](https://github.com/rust-lang/rust/issues/49303)).

r? @eddyb

CC @Centril
2018-08-18 19:34:24 +00:00
Alexander Regueiro
4e7d3f5a5e Added page for feature to unstable book. 2018-08-18 18:56:31 +01:00
Alexander Regueiro
7920a65c5f Added tests. 2018-08-18 18:56:31 +01:00
Alexander Regueiro
cbcabcaac8 Added feature gate. 2018-08-18 18:56:29 +01:00
Alexander Regueiro
79009ed728 Updated diagnostics. 2018-08-18 18:54:44 +01:00
Alexander Regueiro
856e84f9a3 Resolve Self within type definitions.
Currently type definitions include `struct`, `enum`, `union`, `existential type`.
2018-08-18 18:54:41 +01:00
Eduard-Mihai Burtescu
14aed81d9a Use the new Entry::or_default method where possible. 2018-08-18 20:19:45 +03:00
bors
f0341412ed Auto merge of #53436 - cuviper:trace_fn-stop, r=alexcrichton
std: stop backtracing when the frames are full

This is a defensive measure to mitigate the infinite unwind loop seen in #53372.  That case will still repeatedly unwind `__rust_try`, but now it will at least stop when `cx.frames` is full.

r? @alexcrichton
2018-08-18 17:15:31 +00:00
bors
a3ad012e2d Auto merge of #53286 - nagisa:cast-assumes, r=eddyb
Do not generate assumes for plain integer casts

I gave up on making anything more elegant for now.

r? @eddyb
2018-08-18 14:35:42 +00:00
bors
7de3dea2b7 Auto merge of #53175 - matthewjasper:more-return-stuff, r=nikomatsakis
[NLL] Returns are interesting for free regions

Based on #53088 - creating now to get feedback.

Closes #51175

* Make assigning to the return type interesting.
* Use "returning this value" instead of "return" in error messages.
* Prefer one of the explanations that we have a name for to a generic interesting cause in some cases.
* Treat causes that involve the destination of a call like assignments.
2018-08-18 11:57:46 +00:00
bors
d5b6b95aef Auto merge of #52553 - Pazzaz:vecdeque-append, r=SimonSapin
Non-naive implementation of `VecDeque.append`

Replaces the old, simple implementation with a more manual (and **unsafe** 😱) one. I've added 1 more test and verified that it covers all 6 code paths in the function.

This new implementation was about 60% faster than the old naive one when I tried benchmarking it.
2018-08-18 08:56:12 +00:00
bors
6b1ff19af3 Auto merge of #53437 - alexcrichton:fix-target-features, r=michaelwoerister
Set more llvm function attributes for __rust_try

This shim is generated elsewhere in the compiler so this commit adds support to
ensure it goes through similar paths as the rest of the compiler to set llvm
function attributes like target features.

cc #53372
2018-08-18 02:50:39 +00:00
bors
4d5ef325e0 Auto merge of #53369 - pnkfelix:partial-53351-make-some-ported-compile-fail-tests-more-robust-wrt-nll, r=davidtwco
Make some ported cfail tests robust w.r.t. NLL

Updated the most glaring instances of weak tests w.r.t. NLL that came from #53196.

See also the bulletpoint list on #53351.
2018-08-17 23:33:31 +00:00
bors
1fa944914c Auto merge of #53356 - michaelwoerister:itlto, r=alexcrichton
Preliminary work for incremental ThinLTO (CGU name edition)

Bring back the first half of #52266 but hopefully without the performance regression.
2018-08-17 21:24:22 +00:00
bors
c8c587fe4e Auto merge of #50911 - petrochenkov:macuse, r=alexcrichton
Stabilize `use_extern_macros`

Closes https://github.com/rust-lang/rust/issues/35896
2018-08-17 19:10:34 +00:00
bors
de21ea8ff5 Auto merge of #53449 - frewsxcv:rollup, r=frewsxcv
Rollup of 11 pull requests

Successful merges:

 - #52858 (Implement Iterator::size_hint for Elaborator.)
 - #53321 (Fix usage of `wasm_target_feature`)
 - #53326 ([nll] add regression test for issue #27868)
 - #53347 (rustc_resolve: don't allow paths starting with `::crate`.)
 - #53349 ([nll] add tests for #48697 and #30104)
 - #53357 (Pretty print btreemap for GDB)
 - #53358 (`{to,from}_{ne,le,be}_bytes` for unsigned integer types)
 - #53406 (Do not suggest conversion method that is already there)
 - #53407 (make more ported compile fail tests more robust w.r.t. NLL)
 - #53413 (Warn that `#![feature(rust_2018_preview)]` is implied when the edition is set to Rust 2018.)
 - #53434 (wasm: Remove --strip-debug argument to LLD)

Failed merges:

r? @ghost
2018-08-17 17:00:10 +00:00
Corey Farwell
f2146667af
Rollup merge of #53434 - alexcrichton:remove-strip-debug, r=yurydelendik
wasm: Remove --strip-debug argument to LLD

Originally added in #52887 this commit disables passing `--strip-debug` to LLD
when optimized. This bring back the original bug of emitting broken debuginfo
but currently it *also* strips the `name` section which makes it very difficult
to inspect the final binary. A real fix is happening at
https://reviews.llvm.org/D50729 and we can reevaluate once we've updated LLD to
have that commit.
2018-08-17 08:23:45 -07:00
Corey Farwell
5c7b837c4e
Rollup merge of #53413 - eddyb:featured-in-the-latest-edition, r=varkor
Warn that `#![feature(rust_2018_preview)]` is implied when the edition is set to Rust 2018.

cc @varkor @petrochenkov @joshtriplett
2018-08-17 08:23:44 -07:00
Corey Farwell
5ad7b914c0
Rollup merge of #53407 - pnkfelix:partial-53351-make-more-ported-compile-fail-tests-more-robust-wrt-nll, r=nikomatsakis
make more ported compile fail tests more robust w.r.t. NLL

This is similar to PR #53369, except it covers a disjoint (and much smaller) set of tests that I needed to look at more carefully before being 100% certain they were the same kind of issue.
2018-08-17 08:23:43 -07:00
Corey Farwell
4cdcb23581
Rollup merge of #53406 - estebank:to_string-to_string, r=michaelwoerister
Do not suggest conversion method that is already there

Fix #53348.
2018-08-17 08:23:42 -07:00
Corey Farwell
f0764433f7
Rollup merge of #53358 - SimonSapin:int-bytes, r=shepmaster
`{to,from}_{ne,le,be}_bytes` for unsigned integer types

Same as https://github.com/rust-lang/rust/pull/51919 did for signed integers.

Tracking issue: https://github.com/rust-lang/rust/issues/52963
2018-08-17 08:23:40 -07:00
Corey Farwell
18122e0db0
Rollup merge of #53357 - fukatani:pretty-print-btreemap, r=michaelwoerister
Pretty print btreemap for GDB

Merge #53112 first, please.
2018-08-17 08:23:39 -07:00
Corey Farwell
25aca443e6
Rollup merge of #53349 - memoryruins:nll-tests, r=nikomatsakis
[nll] add tests for #48697 and #30104

Adds tests for the following issues:
- #48697 ``[NLL] ICE: unexpected region for local data with reference to closure``
- #30104 ``Destructuring boxes into multiple mutable references seems broken``

r? @nikomatsakis
2018-08-17 08:23:38 -07:00
Corey Farwell
3de02d37ea
Rollup merge of #53347 - eddyb:no-crate-in-root, r=petrochenkov
rustc_resolve: don't allow paths starting with `::crate`.

cc @aturon @joshtriplett
r? @petrochenkov
2018-08-17 08:23:36 -07:00