243 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
75e4783f63 Normalize syntax::source_map imports. 2020-01-02 13:57:04 +01:00
Oliver Scherer
07df1479e5 Rebase fallout 2019-12-26 12:11:12 +01:00
Oliver Scherer
d5f1d75dd2 Rename query module 2019-12-26 12:11:12 +01:00
Oliver Scherer
e21d2c8f9b Move all functions used by the queries to query.rs 2019-12-26 12:11:12 +01:00
Oliver Scherer
eea51e3427 Make some functions crate local 2019-12-26 12:11:11 +01:00
Oliver Scherer
eda3fa9eb5 Move eval_body_using_ecx to the only module it is used in 2019-12-26 12:11:11 +01:00
Oliver Scherer
2d67edd32c Move const eval query components into their own module 2019-12-26 12:11:11 +01:00
Oliver Scherer
3e7fa3c6f2 Move const eval machine into its own module 2019-12-26 12:10:36 +01:00
David Tolnay
4646a88b7a
Deprecate Error::description for real
`description` has been documented as soft-deprecated since 1.27.0 (17
months ago). There is no longer any reason to call it or implement it.

This commit:

- adds #[rustc_deprecated(since = "1.41.0")] to Error::description;

- moves description (and cause, which is also deprecated) below the
  source and backtrace methods in the Error trait;

- reduces documentation of description and cause to take up much less
  vertical real estate in rustdocs, while preserving the example that
  shows how to render errors without needing to call description;

- removes the description function of all *currently unstable* Error
  impls in the standard library;

- marks #[allow(deprecated)] the description function of all *stable*
  Error impls in the standard library;

- replaces miscellaneous uses of description in example code and the
  compiler.
2019-12-24 22:39:49 -08:00
Mark Rousskov
6891388e66 x.py fmt after previous deignore 2019-12-24 17:38:22 -05:00
Oliver Scherer
2022fac4df Constants reading or referencing statics is illegal
and some uses of it will be illegal forever
(e.g. mutable or interior mutable statics)
2019-12-23 14:54:30 +01:00
Oliver Scherer
ad6b9c79d6 Dynamically prevent constants from accessing statics 2019-12-23 14:54:22 +01:00
Ben Lewis
c010d843aa Add simpler entry points to const eval for common usages. 2019-12-22 11:15:16 +13:00
Mazdak Farrokhzad
56c0bea390
Rollup merge of #66991 - Nashenas88:body_cache_cleanup, r=eddyb
Cleanup BodyCache

After this PR:

- `BodyCache` is renamed to `BodyAndCache`
- `ReadOnlyBodyCache` is renamed to `ReadOnlyBodyAndCache`
- `ReadOnlyBodyAndCache::body` fn is removed and all calls to it are replaced by a deref (possible due to fix of its `Deref` imp in #65947)

cc @eddyb @oli-obk
2019-12-08 03:39:45 +01:00
Adam Perry
7afbbf7e8a Always call const fns with #[track_caller].
The caller location is passed as an implicit argument, so we must consider it when checking the sizedness of arguments.
2019-12-06 18:37:54 -08:00
Adam Perry
4773ded15b Generate &core::panic::Location type in a single place. 2019-12-05 21:02:56 -08:00
Paul Daniel Faria
756aa1e46c rustc: Apply clearer naming to BodyAndCache, fix Deref impl, remove unneeded Index impl, remove body fn
rustc_codegen_ssa: Fix BodyAndCache reborrow to Body and change instances of body() call to derefence
rustc_mir: Fix BodyAndCache reborrow to Body and change intances of body() call to derefence
2019-12-05 22:58:41 -05:00
bors
6d77e45f01 Auto merge of #66866 - oli-obk:const_fn_memoization, r=RalfJung
Only memoize const fn calls during const eval

Miri and other engines may want to execute the function in order to detect UB inside of them.

r? @RalfJung
2019-12-04 17:48:19 +00:00
bors
fdc0011561 Auto merge of #64736 - Nashenas88:mir_predecessors_cache_cleanup, r=oli-obk
Remove interior mutability in mir predecessors cache
2019-12-02 14:51:02 +00:00
Paul Daniel Faria
b2fe254c98 Remove HasLocalDecls impl from BodyCache's, properly reborrow to Body, rename all body_cache back to body 2019-12-02 08:40:56 -05:00
Paul Daniel Faria
fc6b58d0a8 Simplify BodyCache impl and fix all remaining type errors in librustc_mir (lifetime errors still exist) 2019-12-02 08:35:08 -05:00
Ralf Jung
5e51a153f9 fix init_allocation_extra 2019-12-02 09:03:16 +01:00
Ralf Jung
96ea142c89 make alloc_extra machine hook a bit nicer 2019-12-02 09:03:16 +01:00
Ralf Jung
56356a0745 Miri: add helper fn to allocate string; simplify alloc_caller_location 2019-12-02 08:55:42 +01:00
Ralf Jung
a8eea623f5 expose span to M::assert_panic, and provide helper to turn that into CallerLocation 2019-12-02 08:55:42 +01:00
Ralf Jung
b1aa3cac5b Miri: add machine hook for MIR-level assertion panics 2019-12-02 08:55:42 +01:00
Oliver Scherer
55840b0209 Don't repeat the is_const_fn_raw check 2019-11-30 18:22:11 +01:00
Oliver Scherer
f15197e83c find_fn -> find_mir_or_eval_fn rename 2019-11-30 17:53:02 +01:00
Oliver Scherer
735a610f47 Only memoize const fn calls during const eval
Miri and other engines may want to execute the function in order to detect UB inside of them.
2019-11-29 11:57:17 +01:00
bors
2539b5f157 Auto merge of #66294 - davidhewitt:const_fn_memoization, r=oli-obk
Add memoization for const function evaluations

When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism.

With thanks to @oli-obk for mentoring me through this at RustFest Barcelona.

r? @oli-obk
2019-11-28 07:06:40 +00:00
David Hewitt
a28fbd4608
Correct typo in src/librustc_mir/const_eval.rs
Co-Authored-By: lqd <remy.rakic+github@gmail.com>
2019-11-27 16:44:53 +00:00
David Hewitt
539813944d Add memoization for const function evaluations
When a const function is being evaluated, as long as all its
arguments are zero-sized-types (or it has no arguments) then we
can trivially memoize the evaluation result using the existing
query mechanism.
2019-11-27 12:01:04 +00:00
Brian Wignall
16fabd8efd Fix spelling typos 2019-11-26 22:19:54 -05:00
Ralf Jung
b91bf7a334 miri: couple ret place and ret block together (they both exist or both don't) 2019-11-25 22:00:58 +01:00
Ralf Jung
7bfed2e32a refactor goto_block and also add unwind_to_block 2019-11-25 16:25:45 +01:00
bors
5e380b797b Auto merge of #66233 - cjgillot:constkind, r=oli-obk
Split ConstValue into two enums

Hello,

Issue #59210 appeared abandoned, so I gave it a go.
Some further cleanup and refactoring may be mandated.

I did not test beyond `x.py check`, since my home computer dies compiling librustc.

Fixes #59210
2019-11-14 04:54:51 +00:00
Camille GILLOT
7378c25f25 Rename in librustc_mir. 2019-11-12 20:50:45 +01:00
Aaron Hill
2ed1e89706
Rename to 2019-11-11 15:14:38 -05:00
Aaron Hill
4ecb80d5d8
Remove trampoline, pass ret and unwind when handling intrinsics 2019-11-11 15:14:37 -05:00
Aaron Hill
8df4248c71
Some cleanup 2019-11-11 15:14:33 -05:00
Aaron Hill
64a43f45d2
A few minor tweaks 2019-11-11 15:14:33 -05:00
Aaron Hill
199101822a
Formatting improvements
Co-Authored-By: Oliver Scherer <github35764891676564198441@oli-obk.de>
2019-11-11 15:14:31 -05:00
Aaron Hill
187d05f215
Add hooks for Miri panic unwinding
This commits adds in some additional hooks to allow Miri to properly
handle panic unwinding. None of this should have any impact on CTFE mode
2019-11-11 15:14:31 -05:00
Ralf Jung
900fc9a2f0 miri: Rename to_{u,i}size to to_machine_{u,i}size
Having a function `to_usize` that does not return a usize is somewhat confusing
2019-11-08 09:21:49 +01:00
Adam Perry
86e55b1882 Always use consteval to codegen caller_location. 2019-10-27 12:51:55 -07:00
Adam Perry
017877cbbe Implementation of const caller_location. 2019-10-27 12:51:34 -07:00
Adam Perry
743964ad3f Implement core::intrinsics::caller_location.
Returns a `&core::panic::Location` corresponding to where it was
called, also making `Location` a lang item.
2019-10-27 12:50:52 -07:00
Wesley Wiser
dcc6c28c53 Introduce a ConstPropMachine
This allows us to avoid changing things directly in the miri engine just
for const prop.
2019-09-27 20:11:13 -04:00
varkor
93df1bb517 Fix rebase 2019-09-25 15:57:54 +01:00
varkor
e2e0f9af85 Rename sty to kind 2019-09-25 15:50:04 +01:00