about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2020-09-21Rollup merge of #76888 - matthiaskrgr:clippy_single_match_2, r=Dylan-DPCecstatic-morse-11/+5
use if let instead of single match arm expressions use if let instead of single match arm expressions to compact code and reduce nesting (clippy::single_match)
2020-09-21Rollup merge of #76807 - ecstatic-morse:const-checking-staged-api, r=oli-obkecstatic-morse-65/+109
Use const-checking to forbid use of unstable features in const-stable functions First step towards #76618. Currently this code isn't ever hit because `qualify_min_const_fn` runs first and catches pretty much everything. One exception is `const_precise_live_drops`, which does not use the newly added code since it runs as part of a separate pass. Also contains some unrelated refactoring, which is split into separate commits. r? @oli-obk
2020-09-21Rollup merge of #76581 - lcnr:bound-too-generic, r=eddybecstatic-morse-4/+2
do not ICE on bound variables, return `TooGeneric` instead fixes #73260, fixes #74634, fixes #76595 r? @nikomatsakis
2020-09-21Add optimization to avoid load of addressSimon Vandel Sillesen-2/+115
2020-09-21Auto merge of #74040 - lcnr:const-occurs-check, r=nikomatsakisbors-5/+10
fix unification of const variables r? `@nikomatsakis` `@varkor` `@eddyb` let's just ping everyone here :sweat_smile:
2020-09-21fix InterpCx resolveBastian Kauschke-5/+10
2020-09-21fix typo in docs and commentsyuk1ty-1/+1
2020-09-21Let user see the full type of type-length limit errorKornel Lesiński-26/+40
2020-09-20Auto merge of #75119 - simonvandel:early-otherwise, r=oli-obkbors-0/+341
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-20Add unstably const support for assume intrinsicLzu Tao-0/+6
2020-09-20Rollup merge of #76890 - matthiaskrgr:matches_simpl, r=lcnrRalf Jung-6/+6
use matches!() macro for simple if let conditions
2020-09-20Correct file path after some restructures in compilerLzu Tao-2/+2
2020-09-20enable on mir-opt-level=1 to test perfSimon Vandel Sillesen-1/+1
2020-09-20add cleanup of cfgSimon Vandel Sillesen-0/+10
2020-09-20insert storageDead for not equal tempSimon Vandel Sillesen-11/+27
2020-09-20correct commentSimon Vandel Sillesen-1/+1
2020-09-20Update src/librustc_mir/transform/early_otherwise_branch.rsSimon Vandel Sillesen-1/+1
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-09-20New MIR optimization pass to reduce branches on match of tuples of enumsSimon Vandel Sillesen-0/+315
2020-09-20Implement destructuring for all aggregates and for referencesOliver Scherer-2/+1
2020-09-20Auto merge of #76964 - RalfJung:rollup-ybn06fs, r=RalfJungbors-16/+16
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-20Add a query for dereferencing constants of reference typeOliver Scherer-1/+45
2020-09-20Rollup merge of #76828 - matthiaskrgr:clippy_manual_strip, r=lcnrRalf Jung-5/+4
use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip)
2020-09-20Rollup merge of #76825 - lcnr:array-windows-apply, r=varkorRalf Jung-7/+2
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-20Rollup merge of #76821 - est31:remove_redundant_nightly_features, ↵Ralf Jung-3/+0
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-20Rollup merge of #76818 - hbina:dont_compile_regex_all_the_time, r=ecstatic-morseRalf Jung-1/+10
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-20use if let instead of single match arm expressions to compact code and ↵Matthias Krüger-11/+5
reduce nesting (clippy::single_match)
2020-09-20Auto merge of #74949 - oli-obk:validate_const_eval_raw, r=RalfJungbors-136/+111
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-20miri: correctly deal with `ConstKind::Bound`Bastian Kauschke-4/+2
2020-09-20Auto merge of #76411 - RalfJung:promote-in-const-fn, r=ecstatic-morsebors-26/+35
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-20use `array_windows` instead of `windows` in the compilerBastian Kauschke-7/+2
2020-09-20Auto merge of #75346 - ↵bors-29/+31
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-20Auto merge of #72632 - jonas-schievink:dest-prop, r=oli-obkbors-1/+1067
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-19Add assertion for len of vecsSimon Vandel Sillesen-3/+4
2020-09-19fix some commentsRalf Jung-6/+7
2020-09-19never promote non-const operations; revert STATIC promotion changeRalf Jung-4/+14
2020-09-19fix doc commentRalf Jung-4/+4
2020-09-19cleanup promotion const_kind checksRalf Jung-30/+28
in particular allow a few more promotions for consistency when they were already allowed in other contexts
2020-09-19Fix #76803Simon Vandel Sillesen-23/+33
Check that the variant index matches the target value from the SwitchInt we came from
2020-09-19Rollup merge of #76757 - matthiaskrgr:clippy_try_into, r=lcnrRalf Jung-11/+3
don't convert types to the same type with try_into (clippy::useless_conversion)
2020-09-19Rollup merge of #75502 - ecstatic-morse:implicit-promotion-in-const-fn, ↵Ralf Jung-1/+8
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-19Reflect the "do not call this query directly" mentality in its nameOliver Scherer-4/+4
2020-09-19RustfmtOliver Scherer-2/+2
2020-09-19Address review commentsOliver Scherer-27/+27
2020-09-19Unify the names of const eval queries and their return typesOliver Scherer-15/+15
2020-09-19Rename const eval queries to reflect the validation changesOliver Scherer-11/+11
2020-09-19Do not call the `const_eval` query in mir interpretation except for caching ↵Oliver Scherer-34/+8
of nulary intrinsics
2020-09-19Replace `and_then` `map_err` `and_then` chain with a matchOliver Scherer-15/+16
2020-09-19`turn_into_const` is infallibleOliver Scherer-11/+7
2020-09-19Document `op_to_const`'s purposeOliver Scherer-0/+2
2020-09-19Stop using the `const_eval` query for initializers of staticsOliver Scherer-39/+20
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.