Commit graph

575 commits

Author SHA1 Message Date
yuk1ty
16047d46a1 fix typo in docs and comments 2020-09-21 12:14:28 +09:00
Nicholas-Baron
99e2e7075c Moved all functions prefixed with 'check' to a separate file 2020-09-20 19:00:31 -07:00
Nicholas-Baron
f896ddfc73 Moved the Expectation enum to its own file 2020-09-20 18:58:32 -07:00
Nicholas-Baron
428a8c6eae Moved the Diverges struct to its own file 2020-09-20 18:58:32 -07:00
Nicholas-Baron
b1e9379679 Formatted use statements for fewer lines 2020-09-20 18:58:32 -07:00
Nicholas-Baron
7995d5cda4 Moved Inherited struct to own file 2020-09-20 18:58:30 -07:00
Nicholas-Baron
45fdf97d11 Removed util.rs
Per suggestion of @oli-obk.
This file was rather short and joining it did not cause mod.rs to become
significantly bigger.
2020-09-20 18:56:09 -07:00
Nicholas-Baron
c8162c22eb Moved the FnCtxt struct to its own file 2020-09-20 18:56:01 -07:00
Nicholas-Baron
c190f66060 Moved GatherLocalsVisitor to its own file 2020-09-20 18:48:31 -07:00
Nicholas-Baron
3e770645aa Moved a struct only need by util into util 2020-09-20 18:48:31 -07:00
Nicholas-Baron
6fd80e35e0 Moved another struct and used pub(super) to be explicit 2020-09-20 18:48:31 -07:00
Nicholas-Baron
bfe5bc9cb9 Formatter moved one use statement 2020-09-20 18:48:31 -07:00
Nicholas-Baron
63dbfb3c30 Start of moving some functionality to separate files 2020-09-20 18:48:31 -07:00
bors
0f9f0b384a Auto merge of #76295 - mati865:remove-mmx, r=Amanieu,oli-obk
Remove MMX from Rust

Follow-up to https://github.com/rust-lang/stdarch/pull/890
This removes most of MMX from Rust (tests pass with small changes), keeping stable `is_x86_feature_detected!("mmx")` working.
2020-09-21 00:43:26 +00:00
Kornel Lesiński
34d3c7df80 Let user see the full type of type-length limit error 2020-09-21 00:39:58 +01:00
bors
2e0edc0f28 Auto merge of #75119 - simonvandel:early-otherwise, r=oli-obk
New MIR optimization pass to reduce branches on match of tuples of enums

Fixes #68867 by adding a new pass that turns something like
```rust
let x: Option<()>;
let y: Option<()>;
match (x,y) {
    (Some(_), Some(_)) => {0},
    _ => {1}
}
```
into something like
```rust
let x: Option<()>;
let y: Option<()>;
let discriminant_x = // get discriminant of x
let discriminant_y = // get discriminant of x
if discriminant_x != discriminant_y {1} else {0}
```

The opt-diffs still have the old basic blocks like
```
bb3: {
          _8 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:21:21: 21:30
          switchInt(move _8) -> [1_isize: bb7, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:21:21: 21:30
      }

      bb4: {
          _9 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:22:23: 22:34
          switchInt(move _9) -> [2_isize: bb8, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:22:23: 22:34
      }

      bb5: {
          _10 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:23:23: 23:34
          switchInt(move _10) -> [3_isize: bb9, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:23:23: 23:34
      }
```

These do get removed on later passes. I'm not sure if I should include those passes in the test to make it clear?
2020-09-20 17:54:44 +00:00
Julian Wollersberger
53aaa1e532 To avoid monomorphizing psm::on_stack::with_on_stack 1500 times, I made a change in stacker to wrap the callback in dyn. 2020-09-20 19:07:52 +02:00
Ralf Jung
fc58224b79
Rollup merge of #76940 - Aaron1011:fix/trait-on-tait, r=oli-obk
Don't allow implementing trait directly on type-alias-impl-trait

This is specifically disallowed by the RFC, but we never added a check
for it.

Fixes #76202
2020-09-20 15:52:09 +02:00
Ralf Jung
7ff17c13bc
Rollup merge of #76910 - lcnr:foreign-item-like, r=oli-obk
transmute: use diagnostic item

closes #66075, we now have no remaining uses of `match_def_path`  in the compiler while some uses still remain in `clippy`.

cc @RalfJung
2020-09-20 15:52:04 +02:00
Ralf Jung
9567b5a9f5
Rollup merge of #76891 - lcnr:less-ref, r=ecstatic-morse
don't take `TyCtxt` by reference

small cleanup
2020-09-20 15:52:03 +02:00
Ralf Jung
8405d50e12
Rollup merge of #76890 - matthiaskrgr:matches_simpl, r=lcnr
use matches!() macro for simple if let conditions
2020-09-20 15:52:01 +02:00
Ralf Jung
c847eaa91d
Rollup merge of #76832 - khyperia:backend_target_override, r=eddyb
Let backends define custom targets

Add a target_override hook that takes priority over builtin targets.
2020-09-20 15:51:48 +02:00
Ralf Jung
39b9a25e60
Rollup merge of #76732 - camelid:mir-basic-block-docs, r=RalfJung
Add docs for `BasicBlock`

Fixes #76715.

---

@rustbot modify labels: A-mir T-doc C-enhancement
2020-09-20 15:51:46 +02:00
Mateusz Mikuła
5de2c95e6e Remove MMX from Rust 2020-09-20 15:13:11 +02:00
Simon Vandel Sillesen
e25738f529 enable on mir-opt-level=1 to test perf 2020-09-20 14:45:47 +02:00
Simon Vandel Sillesen
27068cbfdc add cleanup of cfg 2020-09-20 14:45:47 +02:00
Simon Vandel Sillesen
118aae2af1 insert storageDead for not equal temp 2020-09-20 14:45:47 +02:00
Simon Vandel Sillesen
2530274023 correct comment 2020-09-20 14:45:46 +02:00
Simon Vandel Sillesen
5cc93950ac Update src/librustc_mir/transform/early_otherwise_branch.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-09-20 14:45:46 +02:00
Simon Vandel Sillesen
5fb32c2e33 New MIR optimization pass to reduce branches on match of tuples of enums 2020-09-20 14:45:46 +02:00
bors
41507ed0d5 Auto merge of #76964 - RalfJung:rollup-ybn06fs, r=RalfJung
Rollup of 15 pull requests

Successful merges:

 - #76722 (Test and fix Send and Sync traits of BTreeMap artefacts)
 - #76766 (Extract some intrinsics out of rustc_codegen_llvm)
 - #76800 (Don't generate bootstrap usage unless it's needed)
 - #76809 (simplfy condition in ItemLowerer::with_trait_impl_ref())
 - #76815 (Fix wording in mir doc)
 - #76818 (Don't compile regex at every function call.)
 - #76821 (Remove redundant nightly features)
 - #76823 (black_box: silence unused_mut warning when building with cfg(miri))
 - #76825 (use `array_windows` instead of `windows` in the compiler)
 - #76827 (fix array_windows docs)
 - #76828 (use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip))
 - #76840 (Move to intra doc links in core/src/future)
 - #76845 (Use intra docs links in core::{ascii, option, str, pattern, hash::map})
 - #76853 (Use intra-doc links in library/core/src/task/wake.rs)
 - #76871 (support panic=abort in Miri)

Failed merges:

r? `@ghost`
2020-09-20 11:02:36 +00:00
Ralf Jung
bfa1904765
Rollup merge of #76828 - matthiaskrgr:clippy_manual_strip, r=lcnr
use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip)
2020-09-20 12:08:29 +02:00
Ralf Jung
50d56bc774
Rollup merge of #76825 - lcnr:array-windows-apply, r=varkor
use `array_windows` instead of `windows` in the compiler

I do think these changes are beautiful, but do have to admit that using type inference for the window length
can easily be confusing. This seems like a general issue with const generics, where inferring constants adds an additional
complexity which users have to learn and keep in mind.
2020-09-20 12:08:26 +02:00
Ralf Jung
4322e1b92d
Rollup merge of #76821 - est31:remove_redundant_nightly_features, r=oli-obk,Mark-Simulacrum
Remove redundant nightly features

Removes a bunch of redundant/outdated nightly features. The first commit removes a `core_intrinsics` use for which a stable wrapper has been provided since. The second commit replaces the `const_generics` feature with `min_const_generics` which might get stabilized this year. The third commit is the result of a trial/error run of removing every single feature and then adding it back if compile failed. A bunch of unused features are the result that the third commit removes.
2020-09-20 12:08:22 +02:00
Ralf Jung
3268e33199
Rollup merge of #76818 - hbina:dont_compile_regex_all_the_time, r=ecstatic-morse
Don't compile regex at every function call.

Use `SyncOnceCell` to only compile it once.
I believe this still adds some kind of locking mechanism?

Related issue: https://github.com/rust-lang/rust/issues/76817
2020-09-20 12:08:20 +02:00
Ralf Jung
c12feb35db
Rollup merge of #76815 - pickfire:patch-6, r=jonas-schievink
Fix wording in mir doc
2020-09-20 12:08:19 +02:00
Ralf Jung
9b9192a2d5
Rollup merge of #76809 - matthiaskrgr:simplify_cond, r=varkor
simplfy condition in ItemLowerer::with_trait_impl_ref()
2020-09-20 12:08:17 +02:00
Ralf Jung
2911b8cb30
Rollup merge of #76766 - khyperia:generic_intrinsics, r=eddyb
Extract some intrinsics out of rustc_codegen_llvm

A significant amount of intrinsics do not actually need backend-specific behaviors to be implemented, instead relying on methods already in rustc_codegen_ssa. So, extract those methods out to rustc_codegen_ssa, so that each backend doesn't need to reimplement the same code.

Almost everything should be a pretty direct translation. A notable not-direct-translation is `add_with_overflow` and friends being changed to `bx.checked_binop`, but it's pretty simple.

I could have been a lot more aggressive here and pulled out way more methods, and add a few new methods in the rustc_codegen_ssa "API". However, because this is my second rustc PR, I thought that moving those to a follow-up PR and doing more incremental changes here would be better (and I guess ask if this work is even desired in the first place). I'm hoping to eventually remove the mess of intrinsic handling in the backend entirely, which would be hecking fantastic 
2020-09-20 12:08:13 +02:00
Matthias Krüger
c690c82ad4 use if let instead of single match arm expressions to compact code and reduce nesting (clippy::single_match) 2020-09-20 11:42:52 +02:00
est31
c2dad1c6b9 Remove unused static_assert macro 2020-09-20 11:40:51 +02:00
est31
812ff66803 Use const_cstr macro in consts.rs 2020-09-20 11:34:34 +02:00
bors
5e449b9adf Auto merge of #74949 - oli-obk:validate_const_eval_raw, r=RalfJung
Validate constants during `const_eval_raw`

This PR implements the groundwork for https://github.com/rust-lang/rust/issues/72396

* constants are now validated during `const_eval_raw`
* to prevent cycle errors, we do not validate references to statics anymore beyond the fact that they are not dangling
* the `const_eval` query ICEs if used on `static` items
* as a side effect promoteds are now evaluated to `ConstValue::Scalar` again (since they are just a reference to the actual promoted allocation in most cases).
2020-09-20 08:58:32 +00:00
est31
43193dcb88 Use as_secs_f64 in profiling.rs 2020-09-20 10:27:14 +02:00
est31
cebbd9fcd3 Use as_nanos in bench.rs and base.rs 2020-09-20 10:16:01 +02:00
Bastian Kauschke
6734230425 do not ICE on ty::Bound in Layout::compute 2020-09-20 08:22:35 +02:00
Bastian Kauschke
2a00dda902 miri: correctly deal with ConstKind::Bound 2020-09-20 08:22:35 +02:00
bors
10b3595ba6 Auto merge of #76411 - RalfJung:promote-in-const-fn, r=ecstatic-morse
Some promotion cleanup

Based on top of both https://github.com/rust-lang/rust/pull/75502 and https://github.com/rust-lang/rust/pull/75585, this does some cleanup of the promotion code. The last 2 commits are new.

* Remove the remaining cases where `const fn` is treated different from `fn`. This means no longer promoting ptr-to-int casts, raw ptr operations, and union field accesses in `const fn` -- or anywhere, for that matter. These are all unstable in const-context so this should not break any stable code. Fixes https://github.com/rust-lang/rust/issues/75586.
* ~~Promote references to statics even outside statics (i.e., in functions) for consistency.~~
* Promote `&mut []` everywhere, not just in non-`const` functions, for consistency.
* Explain why we do not promote deref's of statics outside statics. ~~(This is the only remaining direct user of `const_kind`.)~~

This can only land once the other two PRs land; I am mostly putting this up already because I couldn't wait ;) and to get some feedback from `@rust-lang/wg-const-eval` .
2020-09-20 06:20:16 +00:00
Bastian Kauschke
bfb221b21e array pattern 2020-09-20 08:11:05 +02:00
Bastian Kauschke
3435683fd5 use array_windows instead of windows in the compiler 2020-09-20 08:11:05 +02:00
bors
a3bc0e752f Auto merge of #75346 - davidtwco:issue-69925-polymorphic-instancedef-fnptrshim, r=nikomatsakis
shim: monomorphic `FnPtrShim`s during construction

Fixes #69925.

This PR adjusts MIR shim construction so that substitutions are applied to function pointer shims during construction, rather than during codegen (as determined by `substs_for_mir_body`).

r? `@eddyb`
2020-09-20 04:15:43 +00:00
bors
255a4c58f5 Auto merge of #72632 - jonas-schievink:dest-prop, r=oli-obk
Implement a generic Destination Propagation optimization on MIR

This takes the work that was originally started by `@eddyb` in https://github.com/rust-lang/rust/pull/47954, and then explored by me in https://github.com/rust-lang/rust/pull/71003, and implements it in a general (ie. not limited to acyclic CFGs) and dataflow-driven way (so that no additional infrastructure in rustc is needed).

The pass is configured to run at `mir-opt-level=2` and higher only. To enable it by default, some followup work on it is still needed:
* Performance needs to be evaluated. I did some light optimization work and tested against `tuple-stress`, which caused trouble in my last attempt, but didn't go much in depth here.
  * We can also enable the pass only at `opt-level=2` and higher, if it is too slow to run in debug mode, but fine when optimizations run anyways.
* Debuginfo needs to be fixed after locals are merged. I did not look into what is required for this.
* Live ranges of locals (aka `StorageLive` and `StorageDead`) are currently deleted. We either need to decide that this is fine, or if not, merge the variable's live ranges (or remove these statements entirely – https://github.com/rust-lang/rust/issues/68622).

Some benchmarks of the pass were done in https://github.com/rust-lang/rust/pull/72635.
2020-09-20 01:38:26 +00:00
Aaron Hill
367efa86d5
Don't allow implementing trait directly on type-alias-impl-trait
This is specifically disallowed by the RFC, but we never added a check
for it.

Fixes #76202
2020-09-19 17:10:54 -04:00
Bastian Kauschke
30cbc97296 words 2020-09-19 22:27:52 +02:00
Bastian Kauschke
d4039c55c9 wip emit errors during AbstractConst building 2020-09-19 22:17:52 +02:00
Ralf Jung
9216eb8258 fix some comments 2020-09-19 22:14:17 +02:00
Ralf Jung
7b99c8e1cf never promote non-const operations; revert STATIC promotion change 2020-09-19 22:14:17 +02:00
Ralf Jung
7febd5a257 fix doc comment 2020-09-19 22:14:17 +02:00
Ralf Jung
4d1ef03c9e cleanup promotion const_kind checks
in particular allow a few more promotions for consistency when they were already allowed in other contexts
2020-09-19 22:14:17 +02:00
Bastian Kauschke
1146c39da7 cache types during normalization 2020-09-19 17:27:13 +02:00
Bastian Kauschke
bfa2030ccb update docs 2020-09-19 15:36:53 +02:00
bors
b3aae050cd Auto merge of #76880 - shepmaster:cc-rs, r=Mark-Simulacrum
Update cc crate to 1.0.60 to understand aarch64-apple-darwin with clang

r? `@Mark-Simulacrum`

/cc `@alexcrichton`
2020-09-19 13:31:23 +00:00
ishitatsuyuki
7c98f6f584 Add fast path for match checking 2020-09-19 22:00:10 +09:00
bors
8e9d5db839 Auto merge of #76912 - RalfJung:rollup-q9ur56h, r=RalfJung
Rollup of 14 pull requests

Successful merges:

 - #73963 (deny(unsafe_op_in_unsafe_fn) in libstd/path.rs)
 - #75099 (lint/ty: move fns to avoid abstraction violation)
 - #75502 (Use implicit (not explicit) rules for promotability by default in `const fn`)
 - #75580 (Add test for checking duplicated branch or-patterns)
 - #76310 (Add `[T; N]: TryFrom<Vec<T>>` (insta-stable))
 - #76400 (Clean up vec benches bench_in_place style)
 - #76434 (do not inline black_box when building for Miri)
 - #76492 (Add associated constant `BITS` to all integer types)
 - #76525 (Add as_str() to string::Drain.)
 - #76636 (assert ScalarMaybeUninit size)
 - #76749 (give *even better* suggestion when matching a const range)
 - #76757 (don't convert types to the same type with try_into (clippy::useless_conversion))
 - #76796 (Give a better error message when x.py uses the wrong stage for CI)
 - #76798 (Build fixes for RISC-V 32-bit Linux support)

Failed merges:

r? `@ghost`
2020-09-19 11:29:00 +00:00
Bastian Kauschke
67f319c30b take TyCtxt by value 2020-09-19 12:41:12 +02:00
Bastian Kauschke
a219ad64a6 extend is_ty_or_ty_ctxt to self types 2020-09-19 12:41:12 +02:00
Bastian Kauschke
f7d5080ec3 don't take TyCtxt by reference 2020-09-19 12:41:12 +02:00
Ralf Jung
4831523ac4
Rollup merge of #76757 - matthiaskrgr:clippy_try_into, r=lcnr
don't convert types to the same type with try_into (clippy::useless_conversion)
2020-09-19 11:47:52 +02:00
Ralf Jung
5631b5d684
Rollup merge of #76749 - guswynn:hir_ranges, r=estebank
give *even better* suggestion when matching a const range

notice that the err already has "constant defined here"
so this is now *exceedingly clear*

extension to #76222

r? @estebank
2020-09-19 11:47:50 +02:00
Ralf Jung
8a7cb1eac1
Rollup merge of #76636 - RalfJung:miri-size-assert, r=oli-obk
assert ScalarMaybeUninit size

I noticed most low-level Miri types have such an assert but `ScalarMaybeUninit` does not, so let's add that. Good t see that the `Option`-like optimization kicks in and this is no bigger than `Scalar`. :)

r? @oli-obk
2020-09-19 11:47:49 +02:00
Ralf Jung
fef3324043
Rollup merge of #76492 - fusion-engineering-forks:int-bits, r=dtolnay
Add associated constant `BITS` to all integer types

Recently I've regularly come across this snippet (in a few different crates, including `core` and `std`):
```rust
std::mem::size_of<usize>() * 8
```

I think it's time for a `usize::BITS`.
2020-09-19 11:47:45 +02:00
Ralf Jung
f62ba52f5c
Rollup merge of #75502 - ecstatic-morse:implicit-promotion-in-const-fn, r=RalfJung
Use implicit (not explicit) rules for promotability by default in `const fn`

For crater run. See https://github.com/rust-lang/const-eval/pull/54#discussion_r469995552.

cc #75586
2020-09-19 11:47:35 +02:00
Ralf Jung
aa25f9ebd8
Rollup merge of #75099 - davidtwco:is-zst-abstraction-violation, r=eddyb
lint/ty: move fns to avoid abstraction violation

This PR moves `transparent_newtype_field` and `is_zst` to `LateContext` where they are used, rather than being on the `VariantDef` and `TyS` types, hopefully addressing @eddyb's concern [from this comment](https://github.com/rust-lang/rust/pull/74340#discussion_r456534910).
2020-09-19 11:47:34 +02:00
Bastian Kauschke
0eecbd4f97 wording 2020-09-19 11:33:11 +02:00
Bastian Kauschke
4debbdc6b9 transmute: use diagnostic item 2020-09-19 11:33:11 +02:00
bors
fd702d2919 Auto merge of #76886 - Aaron1011:fix/ensure-stack-predicate, r=Mark-Simulacrum
Wrap recursive predicate evaluation with `ensure_sufficient_stack`

I haven't been able to come up with a minimized test case for #76770,
but this fixes a stack overflow in rustc as well.
2020-09-19 09:21:22 +00:00
Oliver Scherer
b8e6883a2f Reflect the "do not call this query directly" mentality in its name 2020-09-19 10:57:14 +02:00
Oliver Scherer
c3c8c981a8 Rustfmt 2020-09-19 10:36:36 +02:00
Oliver Scherer
182ed8544d Address review comments 2020-09-19 10:36:36 +02:00
Oliver Scherer
888afd50d9 Unify the names of const eval queries and their return types 2020-09-19 10:36:36 +02:00
Oliver Scherer
69a6be73e6 Rename const eval queries to reflect the validation changes 2020-09-19 10:36:36 +02:00
Oliver Scherer
dd9702a059 Do not call the const_eval query in mir interpretation except for caching of nulary intrinsics 2020-09-19 10:36:36 +02:00
Oliver Scherer
48f366fced Replace and_then map_err and_then chain with a match 2020-09-19 10:36:36 +02:00
Oliver Scherer
b1bd34df0c turn_into_const is infallible 2020-09-19 10:36:36 +02:00
Oliver Scherer
4397d66d42 Document op_to_const's purpose 2020-09-19 10:36:36 +02:00
Oliver Scherer
2d7ac728e4 Stop using the const_eval query for initializers of statics
As a side effect, we now represent most promoteds as `ConstValue::Scalar` again. This is useful because all implict promoteds are just references anyway and most explicit promoteds are numeric arguments to `asm!` or SIMD instructions.
2020-09-19 10:36:36 +02:00
Oliver Scherer
083f1d7a37 Validate constants during const_eval_raw 2020-09-19 10:36:36 +02:00
Mara Bos
1e2dba1e7c Use T::BITS instead of size_of::<T> * 8. 2020-09-19 06:54:42 +02:00
bors
a2c82df1f5 Auto merge of #76838 - est31:dogfood_uninit_features, r=oli-obk
Dogfood new_uninit and maybe_uninit_slice in rustc_arena

Dogfoods a few cool `MaybeUninit` related features in the compiler's rustc_arena crate.

Split off from #76821

r? `@oli-obk`
2020-09-19 02:21:19 +00:00
Jonas Schievink
2f9271b14c Clarify FIXME 2020-09-18 21:23:01 +02:00
Jonas Schievink
ffd9445812 Return Place by value 2020-09-18 21:23:01 +02:00
Jonas Schievink
682de94e31 Move inner items outside 2020-09-18 21:23:01 +02:00
Jonas Schievink
cd5d7201ad Fix rebase fallout 2020-09-18 21:23:01 +02:00
Jonas Schievink
7af964fecf Limit block count 2020-09-18 21:23:01 +02:00
Jonas Schievink
5728834448 Fix rebase fallout 2020-09-18 21:23:01 +02:00
Jonas Schievink
484db5b08a Properly inherit conflicts when merging locals 2020-09-18 21:23:01 +02:00
Jonas Schievink
934634eacc More logging 2020-09-18 21:23:01 +02:00
Jonas Schievink
88538adf9a Record intra-statement/terminator conflicts
Some MIR statements and terminators have an (undocumented...) invariant
that some of their input and outputs must not overlap. This records
conflicts between locals used in these positions.
2020-09-18 21:23:01 +02:00
Jonas Schievink
ddd6930b54 perf: bail out when there's >500 candidate locals 2020-09-18 21:23:01 +02:00
Jonas Schievink
ab26fb140c perf: only calculate conflicts for candidates 2020-09-18 21:23:01 +02:00
Jonas Schievink
402f863d8a perf: walk liveness backwards in Conflicts::build 2020-09-18 21:23:00 +02:00
Jonas Schievink
812d4bbc8d Fix dataflow assert errors 2020-09-18 21:23:00 +02:00
Jonas Schievink
78ff69ba10 Implement a destination propagation pass 2020-09-18 21:23:00 +02:00
Bastian Kauschke
925cd26162 don't take TyCtxt by reference 2020-09-18 20:49:25 +02:00
Matthias Krüger
40dddd3305 use matches!() macro for simple if let conditions 2020-09-18 20:28:35 +02:00
bors
9f8ac718f4 Auto merge of #76575 - lcnr:abstract-const, r=oli-obk
compare generic constants using `AbstractConst`s

This is a MVP of rust-lang/compiler-team#340. The changes in this PR should only be relevant if `feature(const_evaluatable_checked)` is enabled.

~~currently based on top of #76559, so blocked on that.~~

r? `@oli-obk` cc `@varkor` `@eddyb`
2020-09-18 16:59:50 +00:00
Aaron Hill
6a96aea36a
Wrap recursive predicate evaluation with ensure_sufficient_stack
I haven't been able to come up with a minimized test case for #76770,
but this fixes a stack overflow in rustc as well.
2020-09-18 12:24:42 -04:00
Bastian Kauschke
b7641209d7 add const-evaluatable_checked check back in 2020-09-18 17:36:11 +02:00
Bastian Kauschke
09e6254496 review, small cleanup 2020-09-18 17:11:34 +02:00
Bastian Kauschke
1b275d08ad document const_evaluatable 2020-09-18 17:11:34 +02:00
Bastian Kauschke
7fff155d2a remove allow(warnings) 2020-09-18 17:11:34 +02:00
Bastian Kauschke
30ff1ef3d0 support const_evaluatable_checked across crate boundaries 2020-09-18 17:11:34 +02:00
Bastian Kauschke
82ebbd7d6b add test for let-bindings 2020-09-18 17:11:34 +02:00
Bastian Kauschke
c7d16df1d8 add function calls 2020-09-18 17:11:34 +02:00
Bastian Kauschke
d1294e0ce2 allow unary operations and ignore StorageLive/Dead stmts 2020-09-18 17:11:34 +02:00
Bastian Kauschke
5a277822a5 use newtype_index for abstract_const::NodeId 2020-09-18 17:11:34 +02:00
Bastian Kauschke
f24d532749 refactor AbstractConstBuilder 2020-09-18 17:11:34 +02:00
Bastian Kauschke
c3a772f55f use abstract consts when unifying ConstKind::Unevaluated 2020-09-18 17:11:34 +02:00
Bastian Kauschke
d327fa112b initial working state 2020-09-18 16:25:25 +02:00
bors
fdc3405c20 Auto merge of #72412 - VFLashM:issue-72408-nested-closures-exponential, r=tmandry
Issue 72408 nested closures exponential

This fixes #72408.

Nested closures were resulting in exponential compilation time.

This PR is enhancing asymptotic complexity, but also increasing the constant, so I would love to see perf run results.
2020-09-18 14:08:39 +00:00
Jake Goulding
9803c9b252 Update cc crate to understand aarch64-apple-darwin with clang 2020-09-18 09:22:07 -04:00
khyperia
0bc405e352 Remove DeclareMethods 2020-09-18 13:11:59 +02:00
bors
2c69266c06 Auto merge of #76837 - wesleywiser:disable_consideredequal, r=oli-obk
[mir-opt] Disable the `ConsideredEqual` logic in SimplifyBranchSame opt

The logic is currently broken and we need to disable it to fix a beta
regression (see #76803)

r? `@oli-obk`
2020-09-18 10:54:14 +00:00
Tyler Mandry
3ccb1c37e6 Remove redundancy in cache key 2020-09-18 09:03:53 +00:00
Juan Aguilar Santillana
28cfa9730e Simplify panic_if_treat_err_as_bug avoiding allocations 2020-09-18 05:57:01 +00:00
est31
2805a05154 Add bench_typed_arena_clear_100 bench 2020-09-18 05:52:45 +02:00
est31
daccd1709e Replace loop with drop_in_place call 2020-09-18 04:49:02 +02:00
est31
5acfcceb47 Dogfood new_uninit and maybe_uninit_slice in rustc_arena 2020-09-18 04:49:02 +02:00
Valerii Lashmanov
f583513dc2 Intorduced MiniMap - a tiny small storage optimized map implementation
This makes everything about 1% faster in rustc-perf,
mostly negating performance hit of previous commit.
2020-09-17 20:44:11 -05:00
Valerii Lashmanov
17d2e3b5d2 Better handling for exponential-sized types in misc places
Mostly to fix ui/issues/issue-37311-type-length-limit/issue-37311.rs.

Most parts of the compiler can handle deeply nested types with a lot
of duplicates just fine, but some parts still attempt to naively
traverse type tree.

Before such problems were caught by type length limit check,
but now these places will have to be changed to handle
duplicated types gracefully.
2020-09-17 20:44:11 -05:00
Valerii Lashmanov
2f3296192b Only visit types once when walking the type tree
This fixes #72408.

Nested closures were resulting in exponential compilation time.

As a performance optimization this change introduces MiniSet,
which is a simple small storage optimized set.
2020-09-17 20:44:11 -05:00
Camelid
451f7f6b12 Use relative link instead of absolute 2020-09-17 11:38:40 -07:00
Dylan MacKenzie
e03f4164d9 Default to implicit (not explicit) rules for promotability in const fn 2020-09-17 08:39:11 -07:00
Wesley Wiser
dbd7226d29 [mir-opt] Disable the ConsideredEqual logic in SimplifyBranchSame opt
The logic is currently broken and we need to disable it to fix a beta
regression (see #76803)
2020-09-17 09:36:50 -04:00
bors
7bdb5dee7b Auto merge of #76634 - RalfJung:miri-guaranteed-eq-ne, r=oli-obk
move guaranteed{ne,eq} implementation to compile-time machine

Currently, Miri needs a special hack to avoid using the core engine implementation of these intrinsics. That seems silly, so let's move them to the CTFE machine, which is the only machine that wants to use them.

I also added a reference to https://github.com/rust-lang/rust/issues/73722 as a warning to anyone who wants to adjust `guaranteed_eq`.
2020-09-17 12:15:57 +00:00
Matthias Krüger
026922ad60 make replace_prefix only take &str as arguments
https://github.com/rust-lang/rust/pull/76828#issuecomment-694078200
2020-09-17 13:12:04 +02:00
Juan Aguilar Santillana
7b5d9836c4 Remove redundant to_string 2020-09-17 10:27:04 +00:00
khyperia
48655c2d2c PR feedback 2020-09-17 12:18:09 +02:00
khyperia
c946c40d9d Let backends define custom targets
Add a target_override hook that takes priority over builtin targets.
2020-09-17 12:01:12 +02:00
Matthias Krüger
012974da7a use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip) 2020-09-17 10:13:16 +02:00
est31
ebdea01143 Remove redundant #![feature(...)] 's from compiler/ 2020-09-17 07:58:45 +02:00
est31
4fe6ca3789 Replace const_generics feature gate with min_const_generics
The latter is on the path to stabilization.
2020-09-17 07:08:53 +02:00
Joshua Nelson
2f1bfd6399 Preserve doc-comments when generating queries
This also changes some comments into doc-comments.
2020-09-17 00:28:31 -04:00
est31
b479139620 Remove intrinsics::arith_offset use from libarena
The use of arith_offset was added in 803e9ae67b
before the stable wrapper of the intrinsic was available.

https://doc.rust-lang.org/stable/std/intrinsics/fn.arith_offset.html
2020-09-17 06:12:40 +02:00
bors
95386b656e Auto merge of #76028 - aticu:improve_e0118, r=estebank,jyn514,GuillaumeGomez
Improve E0118

- Changes the "base type" terminology to "nominal type" (according to the [reference](https://doc.rust-lang.org/stable/reference/items/implementations.html#inherent-implementations)).
- Suggests removing a reference, if one is present on the type.
- Clarify what is meant by a "nominal type".

closes #69392

This is my first not-entirely-trivial PR, so please let me know if I missed anything or if something could be improved. Though I probably won't be able to fix anything in the upcoming week.
2020-09-17 03:56:38 +00:00
Hanif Bin Ariffin
f4a7149f49 Don't compile regex at every function call.
Use `SyncOnceCell` to only compile it once.
I believe this still adds some kind of locking mechanism?
2020-09-17 11:03:08 +08:00
Ivan Tham
b7c8bea6cb
Fix wording in mir doc 2020-09-17 09:07:19 +08:00
Matthias Krüger
0e3414248a don't lazily evaulate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations) 2020-09-17 01:37:35 +02:00
Camelid
57eb29cd2d Update based on review suggestions 2020-09-16 15:31:56 -07:00
Dylan MacKenzie
81b3b66487 Error if an unstable const eval feature is used in a stable const fn 2020-09-16 14:17:51 -07:00
Dylan MacKenzie
e4edc161f2 Give name to extra Span in LiveDrop error 2020-09-16 14:17:51 -07:00