Commit Graph

5932 Commits

Author SHA1 Message Date
Paul Daniel Faria
38c0887c76 Fix remaining Body -> (ReadOnly)BodyCache type errors in librustc_mir outside of librustc_mir/transform 2019-12-02 08:31:35 -05:00
Paul Daniel Faria
0a19371243 Add predecessors fn to ReadOnlyBodyCache, fix more Body -> (ReadOnly)BodyCache type errors 2019-12-02 08:31:35 -05:00
Paul Daniel Faria
26f1c01ff7 Add read_only fn to BodyCache<&mut...> impl, fix more Body -> (ReadOnly)BodyCache type errors 2019-12-02 08:31:35 -05:00
Paul Daniel Faria
ab98c595ea Fix a large number of Body -> (ReadOnly)BodyCache type errors, add predecessor_locations fn to ReadOnlyBodyCache 2019-12-02 08:31:35 -05:00
Paul Daniel Faria
649c73f96d Simplify Cache wrapper to single type, impl Deref on it, fix all compilation errors in librustc_codegen_ssa 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
9b335ce1a6 Move predecessors cache back to its own type
This ensures that the cache can be properly ignored during encoding and decoding.
Fix panics that arose due to lack of encoding
2019-12-02 08:30:30 -05:00
Paul Daniel Faria
52cc85f008 Address nits and remove unneeded pass 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
ad734680af Move predecessors cache invalidation back to basic_blocks_mut, add a couple more ensure_predecessors to prevent panics 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
8e8c97e5fd Ensure predecessors are recomputed at critical points, fixes panics 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
570e4182e8 Address linting errors caught by CI 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
2b31456068 Add pass to ensure predecessors cache is generated after optimization 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
f534d9f8c4 Stop invalidating predecessors cache when accessing unique basic block, invalidate cache when accessing unique terminator 2019-12-02 08:30:30 -05:00
Paul Daniel Faria
b5240596d2 Inline cache impl into Body, rename predecessor fns, change output of predecessors_for to slice 2019-12-02 08:30:29 -05:00
Paul Daniel Faria
c16ef6b21d Remove interior mutability in mir predecessors cache 2019-12-02 08:30:29 -05:00
Ralf Jung
313436807b
Rollup merge of #66827 - RalfJung:miri-missing-ret-place, r=oli-obk
handle diverging functions forwarding their return place

Fixes https://github.com/rust-lang/miri/issues/1075: the shim around diverging closures turned into function pointers actually "obtains" a return place inside a diverging function, but just uses it as the return place for a diverging callee. Handle this by using NULL places.

This is kind of a hack as it breaks our invariant that all places are dereferencable, but we'd eventually let raw pointers break that anyway I assume so that seems fine.

r? @oli-obk
2019-12-02 09:34:14 +01:00
Ralf Jung
f32f56969c
Rollup merge of #66654 - ecstatic-morse:check-consts-ref, r=eddyb,matthewjasper
Handle const-checks for `&mut` outside of `HasMutInterior`

Addresses [this comment](https://github.com/rust-lang/rust/pull/64470#discussion_r328200508).

Const-checking relied on `HasMutInterior` to forbid `&mut` in a const context. This was strange because all we needed to do was look for an `Rvalue::Ref` with a certain `BorrowKind`, whereas the `Qualif` traits are specifically meant to get the qualifs for a *value*. This PR removes that logic from `HasMutInterior` and moves it into `check_consts::Validator`.

As a result, we can now properly handle qualifications for `static`s, which had to be ignored previously since you can e.g. borrow a static `Cell` from another `static`. We also remove the `derived_from_illegal_borrow` logic, since it is no longer necessary; we give good errors for subsequent reborrows/borrows of illegal borrows.
2019-12-02 09:34:10 +01:00
Mazdak Farrokhzad
cd47551a0e
Rollup merge of #66926 - RalfJung:miri-stop, r=oli-obk
add reusable MachineStop variant to Miri engine error enum

Replace the Miri-tool-specific `Exit` error variant with something dynamically typed that all clients of the Miri engine can use.

r? @oli-obk
Cc https://github.com/rust-lang/rust/issues/66902
2019-12-02 04:09:07 +01:00
Mazdak Farrokhzad
fd09fad064
Rollup merge of #66789 - eddyb:mir-source-scope-local-data, r=oli-obk
rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.

By having one `ClearCrossCrate<SourceScopeLocalData>` for each scope, as opposed to a single `ClearCrossCrate` for all the `SourceScopeLocalData`s, we can represent the fact that some scopes have `SourceScopeLocalData` associated with them, and some don't.

This is useful when doing MIR inlining across crates, because the `ClearCrossCrate` will be `Clear` for the cross-crate MIR scopes and `Set` for the local ones.

Also see https://github.com/rust-lang/rust/pull/66203#issuecomment-555589574 for some context around this approach.

Fixes #51314.
2019-12-02 04:09:00 +01:00
Dylan MacKenzie
ccb4eed352 Incorporate fixes from review 2019-12-01 11:43:24 -08:00
Ralf Jung
4b81dd43e0 add reusable MachineStop variant to Miri engine error enum 2019-12-01 11:49:40 +01:00
Mazdak Farrokhzad
d91e63b7a2
Rollup merge of #66832 - RalfJung:const-prop-no-alloc, r=oli-obk
const_prop: detect and avoid catching Miri errors that require allocation

r? @wesleywiser @oli-obk
2019-12-01 04:49:27 +01:00
Mazdak Farrokhzad
75fd413e7b
Rollup merge of #66790 - christianpoveda:check-set-discriminant, r=oli-obk
Do `min_const_fn` checks for `SetDiscriminant`s target

Fixes https://github.com/rust-lang/rust/issues/66556

r? @oli-obk @ecstatic-morse
2019-12-01 04:49:26 +01:00
Mazdak Farrokhzad
60f4212ee5
Rollup merge of #66726 - CAD97:miri-recursion-limit, r=RalfJung
Use recursion_limit for const eval stack limit

cc https://github.com/rust-lang/miri/issues/643 @orium @RalfJung

I'm really not certain how exactly to handle this change, but it looks like it's that simple.

Reuse `recursion_limit` ("The maximum recursion limit for potentially infinitely recursive operations such as auto-dereference and monomorphization") which is configurable by the user for the const evaluation stack frame limit.

The other option is to make `const_eval_stack_frame_limit` configurable in the same way as `recursion_limit` (but I'm not sure how to do that and it'd be a bigger change).

Fixes https://github.com/rust-lang/miri/issues/643.
2019-12-01 04:49:24 +01:00
Mazdak Farrokhzad
99f9fa3695
Rollup merge of #66679 - mark-i-m:fix-anon-lifetime-errors, r=matthewjasper
Improve lifetime errors with implicit trait object lifetimes

r? @matthewjasper

cc @estebank

I still think the ideal solution would be to construct a `BrAnon`, but that seems like a more invasive change, and can be done later. This at least gets rid of the hack in `OutliveSuggestion` and is slightly more principled.
2019-12-01 04:49:23 +01:00
Christian Poveda
2ced9d96e7 Merge match branches 2019-11-30 12:25:45 -05:00
Mazdak Farrokhzad
b772b5b19d
Rollup merge of #66895 - Centril:rustc_feature, r=oli-obk
Feature gating *declarations* => new crate `rustc_feature`

This PR moves the data-oriented parts of feature gating into its own crate, `rustc_feature`.
The parts consist of some data types as well as `accepted`, `active`, `removed`, and `builtin_attrs`.

Feature gate checking itself remains in `syntax::feature_gate::check`. The parts which define how to emit feature gate errors could probably be moved to `rustc_errors` or to the new `rustc_session` crate introduced in #66878. The visitor itself could probably be moved as a pass in `rustc_passes` depending on how the dependency edges work out.

The PR also contains some drive-by cleanup of feature gate checking. As such, the PR probably best read commit-by-commit.

r? @oli-obk
cc @petrochenkov
cc @Mark-Simulacrum
2019-11-30 16:56:58 +01:00
Mazdak Farrokhzad
472bee260e
Rollup merge of #66870 - tmiasko:simplify-ty, r=oli-obk
SimplifyArmIdentity only for locals with the same type

Fixes #66856
Fixes #66851
2019-11-30 16:56:52 +01:00
Mazdak Farrokhzad
3af14f994d
Rollup merge of #66612 - Nadrieril:or-patterns-initial, r=varkor
Initial implementation of or-pattern usefulness checking

The title says it all.
I'd like to request a perf run on that, hopefully this doesn't kill performance too much.

cc https://github.com/rust-lang/rust/issues/54883
2019-11-30 16:56:45 +01:00
Nadrieril Feneanar
0f4c5fb20c
Apply suggestions from code review
Co-Authored-By: varkor <github@varkor.com>
2019-11-30 13:35:46 +00:00
Mazdak Farrokhzad
79077f13ff move GateIssue to rustc_feature & simplify emit_feature_err 2019-11-30 07:40:28 +01:00
cad97
52426ab42d
Use recursion_limit for const eval stack limit 2019-11-29 22:49:39 -05:00
Eduard-Mihai Burtescu
a9976d89ed rustc: move mir::SourceScopeLocalData to a field of SourceScopeData. 2019-11-30 01:37:42 +02:00
Eduard-Mihai Burtescu
78d85fcf52 rustc_mir: fix inliner to also copy over source_scope_local_data. 2019-11-30 01:36:51 +02:00
Eduard-Mihai Burtescu
30a9978c6c rustc: move MIR source_scope_local_data's ClearCrossCrate to be around elements. 2019-11-30 01:36:51 +02:00
Ralf Jung
0f6745d6e2
Rollup merge of #66844 - RalfJung:caller-location-leak, r=oli-obk
Miri: do not consider memory allocated by caller_location leaked

Fixes https://github.com/rust-lang/miri/issues/1071

r? @oli-obk

I am not sure if this is the best approach, but it certainly is the easiest.
2019-11-29 22:57:42 +01:00
Ralf Jung
37c1f52b43
Rollup merge of #66793 - matthewjasper:record-static-refs, r=cramertj
Record temporary static references in generator witnesses

Closes #66695

* Record the pointer to static's type in MIR.
* Normalize the static's type (so that constants can be compared correctly).
2019-11-29 22:57:36 +01:00
Tomasz Miąsko
45c4e11e43 SimplifyArmIdentity only for locals with the same type
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-29 20:13:54 +01:00
bors
25d8a9494c Auto merge of #66321 - ninjasource:async-fn-resume-after-completion, r=oli-obk
Async fn resume after completion

#65419 -- Attempting to run an async fn after completion mentions generators
Not yet ready for review - work in progress
Just need to run the tests on a proper build server
2019-11-29 18:11:33 +00:00
Mark Mansi
2a86b6cb33 minor fix 2019-11-29 11:07:06 -06:00
Mark Mansi
05db660d39 remove get_named_span 2019-11-29 11:07:06 -06:00
Mark Mansi
59a768ce14 rename to AnonRegionFromAsyncFn 2019-11-29 11:07:06 -06:00
Mark Mansi
1f853d25b8 improve lifetime errors with implicit trait object lifetimes 2019-11-29 11:07:06 -06:00
bors
861e96f2e9 Auto merge of #66567 - estebank:suggest-copy, r=Centril
Use structured suggestion when requiring `Copy` constraint in type param
2019-11-29 00:23:23 +00:00
Esteban Küber
0f530ecb68 review comments 2019-11-28 12:22:07 -08:00
Esteban Küber
9fb446d472 Deduplicate type param constraint suggestion code 2019-11-28 12:20:28 -08:00
Esteban Küber
02bc412d19 Use structured suggestion when requiring Copy constraint in type param 2019-11-28 12:20:28 -08:00
Ralf Jung
3048d7e5b5 do not consider memory allocated by caller_location leaked 2019-11-28 19:15:32 +01:00
bors
bbb664a99c Auto merge of #66642 - ecstatic-morse:promotion-in-const, r=eddyb
Create promoted MIR fragments for `const` and `static`s

Resolves #65732.

The previous strategy of removing `Drop` and `StorageDead` for promoted locals only worked for rvalue lifetime extension and only if no `loop`s were present. This PR applies the approach currently used for `fn` and `const fn`s to `const` and `statics`.

This may have some performance impacts.

r? @eddyb
2019-11-28 17:30:24 +00:00
bors
f453d1127d Auto merge of #66603 - Nadrieril:fix-65413, r=varkor
Fix #65413

#65413 was due to an oversight in `pat_constructor` that didn't check if a particular const value was maybe a slice/array const.
2019-11-28 14:22:47 +00:00
David Haig
6531ba882e Moved tests and fixed merge conflict 2019-11-28 08:24:19 +00:00