Commit graph

1310 commits

Author SHA1 Message Date
Jane Lusby
93b7aee2da rename assert_matches module 2021-07-16 09:18:14 -07:00
Yuki Okushi
a5acb7b4ba
Rollup merge of #86947 - m-ou-se:assert-matches-to-submodule, r=yaahc
Move assert_matches to an inner module

Fixes #82913
2021-07-15 21:19:16 +09:00
bors
c7d6bcc788 Auto merge of #87044 - cjgillot:expnhash, r=petrochenkov
Cache expansion hash globally

... instead of computing it multiple times.

Split from #86676
r? `@petrochenkov`
2021-07-13 22:32:58 +00:00
Camille GILLOT
616ce3c5c0 Cache expansion hash. 2021-07-13 23:10:56 +02:00
bors
394804bb23 Auto merge of #86857 - fee1-dead:add-attr, r=oli-obk
Add #[default_method_body_is_const]

`@rustbot` label F-const_trait_impl
2021-07-13 06:59:34 +00:00
Ralf Jung
6b26640583 remove unnecessary deallocate_local hack 2021-07-12 20:09:42 +02:00
Ralf Jung
c8baac5776 remove remaining use of Pointer in Allocation API 2021-07-12 18:45:26 +02:00
bors
e97c29bda2 Auto merge of #86815 - FabianWolff:issue-84210, r=varkor
Improve error reporting for modifications behind `&` references

I had a look at #84210 and noticed that #85823 has effectively already fixed #84210.

However, the string matching in #85823 is _very_ crude and already breaks down when a variable name starts with `mut`. I have made this a bit more robust; further improvements could definitely be made but are complicated by the lack of information provided by an earlier pass:
ce331ee6ee/compiler/rustc_mir_build/src/build/matches/mod.rs (L2103-L2107)

I have also fixed a missing comma in the error message.
2021-07-12 01:00:43 +00:00
Vadim Petrochenkov
28f4dba438 rustc_span: Revert addition of proc_macro field to ExpnKind::Macro
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-10 23:03:35 +03:00
Yuki Okushi
36b142f5c1
Rollup merge of #87028 - aDotInTheVoid:patch-1, r=petrochenkov
Fix type: `'satic` -> `'static`

Pointed out on discord: https://discord.com/channels/273534239310479360/490356824420122645/863434443170250793

~~The fact that this compiles is probably a bug.~~ Nope it's `#![feature(in_band_lifetimes)]` (Thanks to [floppy](https://discord.com/channels/273534239310479360/490356824420122645/863437381671059486)

~~[The docs](https://doc.rust-lang.org/stable/nightly-rustc/rustc_mir/transform/inline/struct.Inliner.html#method.check_codegen_attributes) seem to indicate rust thinks this function is generic over the lifetime `'satic`~~ This is because of `in_band_lifetimes`
2021-07-11 01:15:43 +09:00
Nixon Enraght-Moony
293fa8f39a Fix typo: satic -> static 2021-07-10 16:20:53 +01:00
Deadbeef
a79e08ca2a
Update tests 2021-07-10 20:54:50 +08:00
Deadbeef
5e695bbba1
Update CTFE to allow fns marked with the attr 2021-07-10 20:54:50 +08:00
Deadbeef
554fad7bda
Permit calls to default const fns of impl const 2021-07-10 20:54:50 +08:00
Deadbeef
27e863b3df
functions marked with attr are not const 2021-07-10 20:54:49 +08:00
Deadbeef
56d79adf3b
Skip check for calling functions in same trait 2021-07-10 20:54:48 +08:00
Deadbeef
d8d4cc3b98
Treat trait fns marked with the attr as const 2021-07-10 20:54:48 +08:00
Ralf Jung
5f0dd6db94 remove const_raw_ptr_to_usize_cast feature 2021-07-10 12:08:58 +02:00
Mara Bos
2152c145d3
Rollup merge of #87000 - m-ou-se:const-panic-track-caller, r=oli-obk
Use #[track_caller] in const panic diagnostics.

This change stops const panic diagnostics from reporting inside #[track_caller] functions by skipping over them.
2021-07-09 16:20:36 +02:00
Mara Bos
0a4b53f57d Use #[track_caller] in const panic diagnostics.
It was already used for the message. This also uses it for the spans
used for the error and backtrace.
2021-07-09 15:23:27 +02:00
Scott McMurray
b63b2f1e42 PR feedback
- Add `:Sized` assertion in interpreter impl
- Use `Scalar::from_bool` instead of `ScalarInt: From<bool>`
- Remove unneeded comparison in intrinsic typeck
- Make this UB to call with undef, not just return undef in that case
2021-07-08 14:55:57 -07:00
Scott McMurray
2456495a26 Stop generating allocas+memcmp for simple array equality 2021-07-08 14:55:54 -07:00
Guillaume Gomez
a2654fb64c Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
Mara Bos
e3044432c7 Move [debug_]assert_matches to mod {core, std}::assert. 2021-07-08 02:33:36 +02:00
bors
c0bd5a584d Auto merge of #86901 - sexxi-goose:query_remove, r=nikomatsakis
Make type_implements_trait not a query

r? `@nikomatsakis`
2021-07-07 01:03:41 +00:00
Aman Arora
8ef5212eff Make type_implements_trait not a query 2021-07-06 14:38:10 -04:00
Camille GILLOT
3162c37b59 Store macro parent module in ExpnData. 2021-07-06 08:07:06 +02:00
bors
969a6c2481 Auto merge of #86674 - Aaron1011:new-querify-limits, r=michaelwoerister
Query-ify global limit attribute handling

Currently, we read various 'global limits' from inner attributes the crate root (`recursion_limit`, `move_size_limit`, `type_length_limit`, `const_eval_limit`). These limits are then stored in `Sessions`, allowing them to be access from a `TyCtxt` without registering a dependency on the crate root attributes.

This PR moves the calculation of these global limits behind queries, so that we properly track dependencies on crate root attributes. During the setup of macro expansion (before we've created a `TyCtxt`), we need to access the recursion limit, which is now done by directly calling into the code shared by the normal query implementations.
2021-07-05 16:30:53 +00:00
Yuki Okushi
8bb5f37492
Rollup merge of #86862 - tmiasko:re-export-SwitchIntEdgeEffects, r=jonas-schievink
re-export SwitchIntEdgeEffects

This makes it possible to use `switch_int_edge_effects` outside
`rustc_mir::dataflow::impls`.
2021-07-05 07:13:27 +09:00
Aaron Hill
7e5a88a56c
Combine individual limit queries into single limits query 2021-07-04 13:02:51 -05:00
bors
23c652dfe3 Auto merge of #86866 - nikomatsakis:issue-84841, r=oli-obk
Hack: Ignore inference variables in certain queries

Fixes #84841
Fixes #86753

Some queries are not built to accept types with inference variables, which can lead to ICEs. These queries probably ought to be converted to canonical form, but as a quick workaround, we can return conservative results in the case that inference variables are found.

We should file a follow-up issue (and update the FIXMEs...) to do the proper refactoring.

cc `@arora-aman`

r? `@oli-obk`
2021-07-04 17:39:37 +00:00
Aaron Hill
ff15b5e2c7
Query-ify global limit attribute handling 2021-07-04 12:33:14 -05:00
Niko Matsakis
9bdfde0be4 remove some ad-hoc has_infer_types checks that aren't needed anymore 2021-07-04 11:55:09 -04:00
Niko Matsakis
40ee019c17 allow inference vars in type_implements_trait 2021-07-04 11:28:20 -04:00
Tomasz Miąsko
6bbf1e7aad re-export SwitchIntEdgeEffects
This makes it possible to use `switch_int_edge_effects` outside
`rustc_mir::dataflow::impls`.
2021-07-04 13:33:22 +02:00
bors
39e20f1ae5 Auto merge of #86255 - Smittyvb:mir-alloc-oom, r=RalfJung,oli-obk
Support allocation failures when interpreting MIR

This closes #79601 by handling the case where memory allocation fails during MIR interpretation, and translates that failure into an `InterpError`. The error message is "tried to allocate more memory than available to compiler" to make it clear that the memory shortage is happening at compile-time by the compiler itself, and that it is not a runtime issue.

Now that memory allocation can fail, it would be neat if Miri could simulate low-memory devices to make it easy to see how much memory a Rust program needs.

Note that this breaks Miri because it assumes that allocation can never fail.
2021-07-04 09:15:36 +00:00
Smittyvb
d83c46ffcc
add note about MAX_ALLOC_LIMIT
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-07-03 11:15:14 -04:00
Smitty
b201b2f65f Make vtable_allocation always succeed 2021-07-03 11:14:19 -04:00
Smitty
e9d69d9f8e Allocation failure in constprop panics right away 2021-07-02 16:06:12 -04:00
Fabian Wolff
5eb83f4ec3 Improve error reporting for modifications behind & references 2021-07-02 18:29:49 +02:00
Yuki Okushi
884053a4b4
Remove ty::Binder::bind()
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2021-07-03 01:12:32 +09:00
bors
ecef52abeb Auto merge of #86304 - klensy:hex-length, r=jackh726
rustc_mir: calc hex number length without string allocation
2021-07-01 16:16:12 +00:00
klensy
2b57fc40d8 rustc_mir: calc hex number length without string allocation 2021-07-01 18:01:37 +03:00
Smitty
3e20129a18 Delay ICE on evaluation fail 2021-06-30 15:38:31 -04:00
Smitty
4c934df45f Properly evaluate non-consts in const prop 2021-06-30 12:38:12 -04:00
Smitty
9f227945f1 Simplify memory failure checking 2021-06-30 11:24:52 -04:00
bors
868c702d0c Auto merge of #86695 - sexxi-goose:closure_size, r=nikomatsakis
Introduce -Zprofile-closures to evaluate the impact of 2229

This creates a CSV with name "closure_profile_XXXXX.csv", where the
variable part is the process id of the compiler.

To profile a cargo project you can run one of the following depending on
if you're compiling a library or a binary:

```
cargo +nightly rustc --lib -- -Zprofile-closures
cargo +nightly rustc --bin {binary_name} -- -Zprofile-closures
```

r? `@nikomatsakis`
2021-06-30 13:42:50 +00:00
Smitty
ba542eebc0 Rename is_spurious -> is_volatile 2021-06-30 09:27:30 -04:00
Smitty
d04da1125d Properly handle const prop failures 2021-06-29 20:22:32 -04:00
Smitty
3e735a52fe Unwrap allocated Location at creation 2021-06-29 19:08:29 -04:00