364 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
0cb9e36090 rustc -> rustc_middle part 2 2020-03-30 07:16:56 +02:00
bors
0afdf43dc1 Auto merge of #70449 - ecstatic-morse:visit-body, r=oli-obk
Make `Visitor::visit_body` take a plain `&Body`

`ReadOnlyBodyAndCache` has replaced `&Body` in many parts of the code base that don't care about basic block predecessors. This includes the MIR `Visitor` trait, which I suspect resulted in many unnecessary changes in #64736. This reverts part of that PR to reduce the number of places where we need to pass a `ReadOnlyBodyAndCache`.

In the long term, we should either give `ReadOnlyBodyAndCache` more ergonomic name and replace all uses of `&mir::Body` with it at the cost of carrying an extra pointer everywhere, or use it only in places that actually need access to the predecessor cache. Perhaps there is an even nicer alternative.

r? @Nashenas88
2020-03-30 02:04:00 +00:00
Dylan MacKenzie
538cdef64b Use & to do deref coercion for ReadOnlyBodyAndCache 2020-03-29 13:30:26 -07:00
Dylan MacKenzie
b641e9e358 Make Visitor::visit_body take a simple Body 2020-03-29 11:56:36 -07:00
Ana-Maria Mihalache
50d2c3abd5 Rename TyLayout to TyAndLayout. 2020-03-27 17:14:53 +00:00
Mazdak Farrokhzad
20771ae5b9
Rollup merge of #70385 - RalfJung:miri-nits, r=eddyb
Miri nits: comment and var name improvement

r? @eddyb
2020-03-26 13:32:15 +01:00
Ana-Maria Mihalache
0f7840b89b Rename LayoutDetails to just Layout. 2020-03-25 15:06:48 +00:00
Ralf Jung
b5343d6baa rename def_id -> static_def_id 2020-03-25 08:47:59 +01:00
Ralf Jung
4920a3371f better explain GLOBAL_KIND choice 2020-03-25 08:46:58 +01:00
Mazdak Farrokhzad
b8093bad58
Rollup merge of #70241 - RalfJung:global-mem, r=oli-obk
Miri: move ModifiedStatic to ConstEval errors

Also generally adjust terminology from "static" to "global" where appropriate (to avoid confusion with specifically `static` items).
2020-03-24 21:32:29 +01:00
Ralf Jung
1939b4c940 actually we can reject all reads from mutable allocs in const-prop 2020-03-24 14:31:55 +01:00
Ralf Jung
7a73b879cb fix const_prop ICE 2020-03-24 08:34:28 +01:00
Ralf Jung
69cf211d06 get back the more precise error message 2020-03-24 08:27:46 +01:00
Ralf Jung
9d9649adea move ModifiedStatic error to ConstEval errors, and generally adjust terminology from "static" to "global" where appropriate 2020-03-24 08:27:45 +01:00
Mazdak Farrokhzad
0d5b83df26
Rollup merge of #70259 - wesleywiser:use_reveal_all, r=eddyb
Use Reveal::All in MIR optimizations

Resolves some code review feedback in #67662.

Fixes #68855

r? @eddyb
2020-03-24 07:13:38 +01:00
Mazdak Farrokhzad
31845068cc
Rollup merge of #70267 - RalfJung:const-prop-unsup, r=oli-obk,wesleywiser
get rid of ConstPropUnsupported; use ZST marker structs instead

This gets rid of yet another machine-specific error variant.

r? @oli-obk
2020-03-24 00:49:46 +01:00
Ralf Jung
410385dfd0 add macro to reduce boilerplate and keep readable messages 2020-03-23 11:02:18 +01:00
Ralf Jung
2ee2157e29 miri engine: turn error sanity checks into assertions 2020-03-22 22:47:35 +01:00
Dylan DPC
8fe8bad96b
Rollup merge of #70254 - matthiaskrgr:cl4ppy, r=Centril
couple more clippy fixes (let_and_return, if_same_then_else)

* summarize if-else-code with identical blocks (clippy::if_same_then_else)
* don't create variable bindings just to return the bound value immediately (clippy::let_and_return)
2020-03-22 15:48:41 +01:00
Ralf Jung
82f4a1a9b9 get rid of ConstPropUnsupported; use ZST marker structs instead 2020-03-22 12:16:24 +01:00
Wesley Wiser
4f405119e8 Resolve worsened debug build codegen 2020-03-21 22:37:51 -04:00
Matthias Krüger
74d68ea7eb don't create variable bindings just to return the bound value immediately (clippy::let_and_return) 2020-03-22 00:35:25 +01:00
Matthias Krüger
e45fdcfa9a remove unused unit values (clippy::unused_unit) 2020-03-21 20:45:19 +01:00
Mazdak Farrokhzad
16f607f65a
Rollup merge of #70138 - RalfJung:throw-not-return, r=oli-obk
do not 'return' in 'throw_' macros

In https://github.com/rust-lang/rust/pull/69839 we turned a closure into a `try` block, but it turns out that does not work with our `throw_` macros, which `return` so they skip the `try`.

Here we fix that. For some reason that means we also have to remove some `;`.

r? @oli-obk
2020-03-21 08:51:21 +01:00
Matthias Krüger
ad00e91887 remove redundant returns (clippy::needless_return) 2020-03-20 20:23:03 +01:00
Ralf Jung
a39875b4dd do not 'return' in 'throw_' macros 2020-03-19 09:07:43 +01:00
Mazdak Farrokhzad
4392a8b73c use direct imports for rustc::{lint, session}. 2020-03-16 02:52:06 +01:00
Camille GILLOT
1fcdc52f70 Make downstream crates compile. 2020-03-14 14:17:43 +01:00
Mazdak Farrokhzad
3853da75cb
Rollup merge of #69850 - RalfJung:panic-bounds-check, r=eddyb
panic_bounds_check: use caller_location, like PanicFnLangItem

The `PanicFnLangItem` got switched to using `#[caller_location]` at some point, but `PanicBoundsCheckFnLangItem` was kept in the old style. For consistency, switch that one over to use `#[caller_location]` as well.

This is also helpful for Miri as it means the `assert_panic` machine hook never needs to know the current `Span`.
2020-03-11 14:03:49 +01:00
Ralf Jung
f34e0664a1 remove no-longer needed span from Miri Machine hook 2020-03-09 19:58:58 +01:00
Ralf Jung
4971d03ccf fix some cases of unexpected exceptions leaving validation 2020-03-08 22:04:54 +01:00
Ralf Jung
0468929ce3 move error allocation test to error.rs 2020-03-08 22:04:54 +01:00
Matthias Krüger
136ad015b6 fix various typos 2020-03-06 15:19:31 +01:00
bors
4d71c164a8 Auto merge of #69550 - RalfJung:scalar, r=oli-obk
interpret engine: Scalar cleanup

* Remove `to_ptr`
* Make `to_bits` private

r? @oli-obk
2020-03-04 04:10:58 +00:00
bors
1cf090e8d1 Auto merge of #69408 - RalfJung:canonical-alloc-id, r=oli-obk
Miri: let machine canonicalize AllocIDs

This implements the rustc side of the plan I laid out [here](https://github.com/rust-lang/miri/pull/1147#issuecomment-581868901).

Miri PR: https://github.com/rust-lang/miri/pull/1190
2020-03-01 20:53:04 +00:00
Vadim Petrochenkov
e08c279eac Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
Ralf Jung
63c77f1bd0 remove ScalarMaybeUndef::to_bits and make Scalar::to_bits private 2020-02-28 16:07:12 +01:00
Ralf Jung
5da393970d miri/machine: add canonical_alloc_id hook to replace find_foreign_static 2020-02-23 17:45:44 +01:00
Mazdak Farrokhzad
d237e0fc6c
Rollup merge of #69185 - RalfJung:const-prop-lints, r=oli-obk
Unify and improve const-prop lints

Add a single helper method for all lints emitted by const-prop, and make that lint different from the CTFE `const_err` lint. Also consistently check overflow on *arithmetic*, not on the assertion, to make behavior the same for debug and release builds.

See [this summary comment](https://github.com/rust-lang/rust/pull/69185#issuecomment-587924754) for details and the latest status.

In terms of lint formatting, I went for what seems to be the better style: have a general message above the code, and then a specific message at the span:
```
error: this arithmetic operation will overflow
  --> $DIR/const-err2.rs:21:18
   |
LL |     let a_i128 = -std::i128::MIN;
   |                  ^^^^^^^^^^^^^^^ attempt to negate with overflow
```
We could also just have the specific message above and no text at the span if that is preferred.

I also converted some of the existing tests to use compiletest revisions, so that the same test can check a bunch of different compile flags.

Fixes https://github.com/rust-lang/rust/issues/69020.
Helps with https://github.com/rust-lang/rust/issues/69021: debug/release are now consistent, but the assoc-const test in that issue still fails (there is a FIXME in the PR for this). The reason seems to be that const-prop notices the assoc const in `T::N << 42` and does not even bother calling `const_prop` on that operation.
Has no effect on https://github.com/rust-lang/rust/issues/61821; the duplication there has entirely different reasons.
2020-02-20 20:18:50 +01:00
Ralf Jung
5e19350a4c better lint names 2020-02-18 22:49:47 +01:00
Camille GILLOT
1637aab15e Make librustc_mir compile. 2020-02-16 11:57:49 +01:00
Ralf Jung
0c8c800f21
Tighter type bounds for messages
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2020-02-15 15:42:13 +01:00
Ralf Jung
2107e73d2f fix exceeding_bitshift lint and test 2020-02-15 11:43:54 +01:00
Ralf Jung
ad4b3f3e17 const-prop: use one helper method for all lints; consistently lint overflow on BinOps and not on Assert 2020-02-14 22:49:01 +01:00
Ralf Jung
33ba83c3a0
fix typo 2020-02-13 11:26:09 +01:00
Ralf Jung
ed2f22c5a9 rename PanicInfo -> AssertKind 2020-02-13 11:04:49 +01:00
Ralf Jung
7e7d1c39ed improve comments:
- comment for special handling of Shl/Shr
- reference a PR
2020-02-13 11:04:26 +01:00
Ralf Jung
6457b29104 move PanicInfo to mir module 2020-02-13 11:04:26 +01:00
Ralf Jung
c5709ff6b7 const-prop: handle overflow_check consistently for all operators 2020-02-13 10:56:38 +01:00
Ralf Jung
0633a0e380 remove Panic variant from InterpError 2020-02-13 10:54:37 +01:00