4486 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
1ce0288e2f
Rollup merge of #61092 - spastorino:sanitize-place-iterative, r=oli-obk
Make sanitize_place iterate instead of recurse

r? @oli-obk
2019-05-25 04:57:32 +02:00
Santiago Pastorino
03dc30d3d5 Make sanitize_place iterate instead of recurse 2019-05-24 18:31:11 +02:00
bors
46805805ab Auto merge of #60984 - matthewjasper:borrowck-error-reporting-cleanup, r=pnkfelix
Borrowck error reporting cleanup

* Don't show variables created by desugarings in borrowck errors
* Move "conflict error" reporting to it's own module, so that `error_reporting` contains only common error reporting methods.
* Remove unused `ScopeTree` parameter.

r? @pnkfelix
2019-05-24 03:07:07 +00:00
bors
85334c5092 Auto merge of #60174 - matthewjasper:add-match-arm-scopes, r=pnkfelix
Add match arm scopes and other scope fixes

* Add drop and lint scopes for match arms.
* Lint attributes are now respected on match arms.
* Make sure we emit a StorageDead if we diverge when initializing a temporary.
* Adjust MIR pretty printing of scopes for locals.
* Don't generate duplicate lint scopes for `let statements`.
* Add some previously missing fake borrows for matches.

closes #46525

cc @rust-lang/compiler
2019-05-23 04:48:21 +00:00
bors
15ccaf7791 Auto merge of #60740 - petrochenkov:kw, r=nnethercote
Simplify use of keyword symbols

They mirror non-keyword symbols now (see https://github.com/rust-lang/rust/pull/60630).

`keywords::MyKeyword.name()` -> `kw::MyKeyword`
`keywords::MyKeyword.ident()` -> `Ident::with_empty_ctxt(kw::MyKeyword)` (not common)
`keywords::Invalid.ident()` -> `Ident::invalid()` (more common)

Keywords are simply `Symbol` constants now, the `Keyword` struct is eliminated.
This means `kw::MyKeyword` can now be used in `match` in particular.
2019-05-23 01:50:55 +00:00
Vadim Petrochenkov
59a382122f Simplify use of keyword symbols 2019-05-22 19:48:56 +03:00
Mazdak Farrokhzad
fba5ed355a
Rollup merge of #61023 - spastorino:use-iterate-qualify-consts, r=oli-obk
Migrate from recursion to iterate on qualify consts visitor impl

r? @oli-obk
2019-05-22 18:08:19 +02:00
Mazdak Farrokhzad
621231053c
Rollup merge of #60809 - jethrogb:jb/nll-faq, r=pnkfelix
Add FAQ for NLL migration

r? @pnkfelix

cc @oli-obk @davidtwco @Centril Since you've provided feedback on the warning wording before.
2019-05-22 18:08:17 +02:00
bors
37ff5d388f Auto merge of #59445 - alexreg:ban-multi-trait-objects-via-aliases, r=oli-obk
Ban multi-trait objects via trait aliases

Obviously, multi-trait objects are not normally supported, so they should not be supported via trait aliases.

This has been factored out from the previous PR https://github.com/rust-lang/rust/pull/55994 (see point 1).

r? @Centril

CC @nikomatsakis

------------------

### RELNOTES:

We now allow `dyn Send + fmt::Debug` with equivalent semantics to `dyn fmt::Debug + Send`.
That is, the order of the mentioned traits does not matter wrt. principal/not-principal traits.
This is a small change that might deserve a mention in the blog post because it is a language change but most likely not.

See ce2ee305f9/src/test/ui/traits/wf-trait-object-reverse-order.rs.

// @Centril
2019-05-22 08:22:17 +00:00
bors
1cc822c261 Auto merge of #60840 - tmandry:preserve-scope-in-generator-mir, r=cramertj
Preserve local scopes in generator MIR

Part of #52924, depended upon by the generator layout optimization #60187.

This PR adds `StorageDead` statements in more places in generators, so we can see when non-`Drop` locals have gone out of scope and recover their storage.

The reason this is only done for generators is compiler performance. See https://github.com/rust-lang/rust/pull/60187#issuecomment-485637811 for what happens when we do this for all functions.

For `Drop` locals, we modify the `MaybeStorageLive` analysis to use `drop` to indicate that storage is no longer live for the local. Once `drop` returns or unwinds to our function, we implicitly assume that the local is `StorageDead`.

Instead of using `drop`, it is possible to emit more `StorageDead` statements in the MIR for `Drop` locals so we can handle all locals the same. I am fine with doing it that way, but this was the simplest approach for my purposes. It is also likely to be more performant.

r? @Zoxc (feel free to reassign)
cc @cramertj @eddyb @RalfJung @rust-lang/wg-async-await
2019-05-22 04:42:20 +00:00
Santiago Pastorino
f47b87279c Migrate from recursion to iterate on qualify consts visitor impl 2019-05-22 06:00:04 +02:00
Mazdak Farrokhzad
44cb86bdc8
Rollup merge of #61003 - nnethercote:rm-InternedString-PartialEq-impls, r=petrochenkov
Remove impls for `InternedString`/string equality.

`Symbol` received the same treatment in #60630.

Also, we can derive `PartialEq` for `InternedString`.

r? @petrochenkov
2019-05-22 03:47:41 +02:00
Mazdak Farrokhzad
98172092cf
Rollup merge of #60998 - RalfJung:static_assert, r=Centril
static_assert: make use of anonymous constants
2019-05-22 03:47:40 +02:00
Matthew Jasper
8dc945c169 Remove unused parameter in borrowck error reporting 2019-05-21 20:38:17 +01:00
Matthew Jasper
df5d072172 Move conflict error reporting to its own module 2019-05-21 20:38:17 +01:00
Matthew Jasper
ebd6c7164e Dont show variables from desugarings in borrowck errors 2019-05-21 20:38:17 +01:00
Mazdak Farrokhzad
015a45156f Comment style fixes
Co-Authored-By: matthewjasper <mjjasper1@gmail.com>
2019-05-21 19:37:39 +01:00
Matthew Jasper
abab9efbdb Schedule storage-dead of temporaries sooner
This ensures that we will correctly generate a storage-dead if the
initializing expression diverges.
2019-05-21 19:37:38 +01:00
Matthew Jasper
b5643f1a49 Emit fake borrows for all tests
I was incorrectly under the impression that this would only lead to
duplicates. See `mir-opt/match-arm-scope.rs` (upcomming commit) for a
case where we didn't emit a fake borrow of `items.1`.
2019-05-21 19:37:38 +01:00
Matthew Jasper
0f507246e7 Remove MIR borrowck hack for old match scopes 2019-05-21 19:37:38 +01:00
Matthew Jasper
f506aea1fa Give match arms a drop/region scope
Also give arms the correct lint scope in MIR.
2019-05-21 19:37:38 +01:00
Matthew Jasper
af6a9a2c62 Handle the visibility/lint scope distinction better
* Don't generate an extra lint scope for each `let` statement.
* Place match guards inside the visiblility scope of the bindings for
  their arm.
2019-05-21 19:37:38 +01:00
Matthew Jasper
615c23f6ec Remove unused parameter from in(_opt)?_scope 2019-05-21 19:37:38 +01:00
Jethro Beekman
33fb1c501c Add FAQ for NLL migration 2019-05-21 09:52:05 -07:00
Nicholas Nethercote
b557567c35 Remove impls for InternedString/string equality.
`Symbol` received the same treatment in #60630.

Also, we can derive `PartialEq` for `InternedString`.
2019-05-21 20:08:33 +10:00
Ralf Jung
5ea5fe3072 static_assert: make use of anonymous constants 2019-05-21 09:10:24 +02:00
Santiago Pastorino
419ca9d640
LocalDecl push returns Local len 2019-05-20 20:13:58 -03:00
Alexander Regueiro
16ef295770 Accumulation of various drive-by cosmetic changes. 2019-05-20 16:12:48 +01:00
bors
caef1e833f Auto merge of #60815 - nnethercote:use-Symbol-more-2, r=petrochenkov
Use `Symbol` even more

These patches simplify the code a bit (fewer conversions) and also speed things up a bit (fewer `with_interner` calls).

r? @petrochenkov
2019-05-20 03:36:43 +00:00
Nicholas Nethercote
257eaf523f Introduce InternedString::intern.
`InternedString::intern(x)` is preferable to
`Symbol::intern(x).as_interned_str()`, because the former involves one
call to `with_interner` while the latter involves two.

The case within InternedString::decode() is particularly hot, and this
change reduces the number of `with_interner` calls by up to 13%.
2019-05-20 09:17:00 +10:00
Nicholas Nethercote
b96be5b188 Avoid as_str() in ParamTy::is_self.
It's a hot function, and a direct `Symbol` comparison is faster.

The patch also converts some `&InternedString`s to `InternedString`.
2019-05-20 09:16:26 +10:00
Wesley Wiser
ec853ba026 [const-prop] Don't const-prop into terminators unless mir-opt-level >= 2 2019-05-19 16:47:03 -04:00
Wesley Wiser
2baab0eaaa [const-prop] Remove catch all match and add FIXME 2019-05-19 16:47:03 -04:00
Wesley Wiser
3f5c743b53 [const-prop] Support propagating into SwitchInt's discr Operand 2019-05-19 16:46:51 -04:00
Wesley Wiser
8e99c76089 [const-prop] Support propagating into Assert's cond Operand 2019-05-19 16:13:08 -04:00
bors
ce41e48362 Auto merge of #60937 - RalfJung:miri, r=oli-obk
update Miri

r? @oli-obk
2019-05-19 08:56:24 +00:00
Ralf Jung
a226b53b58 expand comment in StorageLive 2019-05-18 14:40:53 +02:00
Fabian Drinck
b18de52080 Declare DefIndex with the newtype_index macro 2019-05-18 13:19:33 +02:00
Manish Goregaokar
e7f27947cf
Rollup merge of #60597 - wesleywiser:const_prop, r=oli-obk
Do some simple constant propagation in the ConstProp pass

r? @oli-obk

I added a few test cases. Let me know if you think there should be more.
2019-05-16 12:31:46 -07:00
Wesley Wiser
45214edf9e Run const propagation at O2 2019-05-15 06:07:06 -04:00
Wesley Wiser
317daf77de Do some simple constant propagation in the ConstProp pass 2019-05-15 06:07:06 -04:00
Tyler Mandry
26c37d7b16 Revert "Remove separation between generator_drop and unwind paths"
This reverts commit 26a7228f0fd5929f2134ac36180eb1e8ff5e16e3.
2019-05-14 18:33:13 -07:00
Tyler Mandry
e2cde9119b Remove separation between generator_drop and unwind paths 2019-05-14 18:33:13 -07:00
Tyler Mandry
dd2eabc49d Make MaybeStorageLive drop-aware 2019-05-14 18:33:13 -07:00
Tyler Mandry
b789017403 Emit StorageDead for all locals in generators 2019-05-14 18:04:57 -07:00
Mazdak Farrokhzad
2821329c34
Rollup merge of #60176 - matthewjasper:yield-ref-to-local, r=pnkfelix
Explain error when yielding a reference to a local variable

Closes #56508
2019-05-13 21:36:49 +02:00
Nicholas Nethercote
fb084a48e2 Pass a Symbol to check_name, emit_feature_err, and related functions. 2019-05-13 09:29:22 +10:00
Yusuke Matsushita
a145b14b3e
Remove redundant "let mut" in write_graph_label
Removed the redundant "let mut" in the write_graph_label function (it caused "let mut let mut" for non-user-defined local variables).
2019-05-12 01:47:20 +09:00
bors
acc7e652f8 Auto merge of #59288 - Centril:hir-if-to-match, r=oli-obk
[let_chains, 1/6] Remove hir::ExprKind::If

Per https://github.com/rust-lang/rust/issues/53667#issuecomment-471583239.

r? @oli-obk
2019-05-10 22:58:52 +00:00
Mazdak Farrokhzad
5cccda1770 Remove hir::ExprKind::If and replace it with lowering to hir::ExprKind::Match. 2019-05-10 19:41:10 +02:00