about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform
AgeCommit message (Collapse)AuthorLines
2020-10-01Rollup merge of #77324 - Aaron1011:fix/const-item-mutation-ptr, r=petrochenkovDylan DPC-5/+9
Don't fire `const_item_mutation` lint on writes through a pointer Fixes #77321
2020-09-30Rollup merge of #77037 - matthiaskrgr:cl42ppy, r=Dylan-DPCJonas Schievink-1/+1
more tiny clippy cleanups commits stand alone and can be reviewed one by one
2020-09-30Remove E0019, use E0015 for inline assembly in a constDylan MacKenzie-2/+2
2020-09-30Better span for attribute suggestionsDylan MacKenzie-11/+19
`def_span` has the same issues as `body.span`, so do it this way instead.
2020-09-30Validate `rustc_args_required_const`varkor-1/+1
2020-09-29Remove default `build_error` implDylan MacKenzie-29/+12
Now all structured errors must have their own error code
2020-09-29Remove machinery for halting error outputDylan MacKenzie-15/+0
2020-09-29Don't stop const-checking after erroneous trait boundDylan MacKenzie-6/+17
2020-09-29Emit multiple function pointer errors from const-checkerDylan MacKenzie-4/+0
2020-09-29Don't emit duplicate errors for the return placeDylan MacKenzie-1/+2
2020-09-29Priority levelsDylan MacKenzie-10/+74
2020-09-29Bless mut testsDylan MacKenzie-2/+0
2020-09-29Give `MutDeref` a real error messageDylan MacKenzie-0/+9
2020-09-29Remove `ops::non_const`Dylan MacKenzie-58/+55
This helper function was meant to reduce code duplication between const-checking pre- and post-drop-elaboration. Most of the functionality is only relevant for the pre-drop-elaboration pass.
2020-09-29Fix "unstable in stable" errorDylan MacKenzie-1/+6
The "otherwise" note is printed before the suggestion currently.
2020-09-29Return a `DiagnosticBuilder` from structured errorsDylan MacKenzie-75/+64
This ensures that `emit_error` will actually cause compilation to fail.
2020-09-29Forbid generator-specific MIR in all const-contextsDylan MacKenzie-5/+3
2020-09-29`delay_span_bug` if const-checking an `async` functionDylan MacKenzie-2/+17
This errors during AST lowering. Any errors we emit here are just noise.
2020-09-29Continue after `impl Trait` in `const fn`Dylan MacKenzie-2/+0
2020-09-29Continue const-checking after errors when easyDylan MacKenzie-24/+0
This doesn't change any UI test output
2020-09-28Don't fire `const_item_mutation` lint on writes through a pointerAaron Hill-5/+9
Fixes #77321
2020-09-28Auto merge of #77302 - RalfJung:rollup-n8gg3v6, r=RalfJungbors-7/+21
Rollup of 7 pull requests Successful merges: - #76454 (UI to unit test for those using Cell/RefCell/UnsafeCell) - #76474 (Add option to pass a custom codegen backend from a driver) - #76711 (diag: improve closure/generic parameter mismatch) - #77170 (Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]`) - #77194 (Add doc alias for iterator fold) - #77288 (fix building libstd for Miri on macOS) - #77295 (Update unstable-book: Fix ABNF in inline assembly docs) Failed merges: r? `@ghost`
2020-09-28Rollup merge of #77170 - ecstatic-morse:const-fn-ptr, r=oli-obkRalf Jung-7/+21
Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]` `rustc_allow_const_fn_ptr` was a hack to work around the lack of an escape hatch for the "min `const fn`" checks in const-stable functions. Now that we have co-opted `allow_internal_unstable` for this purpose, we no longer need a bespoke attribute. Now this functionality is gated under `const_fn_fn_ptr_basics` (how concise!), and `#[allow_internal_unstable(const_fn_fn_ptr_basics)]` replaces `#[rustc_allow_const_fn_ptr]`. `const_fn_fn_ptr_basics` allows function pointer types to appear in the arguments and locals of a `const fn` as well as function pointer casts to be performed inside a `const fn`. Both of these were allowed in constants and statics already. Notably, this does **not** allow users to invoke function pointers in a const context. Presumably, we will use a nicer name for that (`const_fn_ptr`?). r? @oli-obk
2020-09-27[mir-opt] Introduce a new flag to enable experimental/unsound mir optsWesley Wiser-1/+3
2020-09-27Add a feature gate for basic function pointer use in `const fn`Dylan MacKenzie-7/+21
2020-09-27Rollup merge of #77203 - ecstatic-morse:const-stability-attr-checks, r=oli-obkJonas Schievink-3/+0
Check for missing const-stability attributes in `rustc_passes` Currently, this happens as a side effect of `is_min_const_fn`, which is non-obvious. Also adds a test for this case, since we didn't seem to have one before.
2020-09-27Rollup merge of #77231 - oli-obk:clippy_const_fn, r=ManishearthJonas Schievink-463/+0
Move helper function for `missing_const_for_fn` out of rustc to clippy cc @rust-lang/clippy @ecstatic-morse #76618 r? @Manishearth I also removed all support for suggesting a function could be `const fn` when that would require feature gates to actually work. This means we'll now have to maintain this ourselves in clippy, but that's how most lints work anyway, so...
2020-09-27Rollup merge of #77107 - bugadani:perf, r=oli-obkJonas Schievink-5/+5
Enable const propagation into operands at mir_opt_level=2 Feature was added in #74507 but gated with `mir_opt_level>=3` because of compile time regressions. Let's see whether the LLVM 11 update solves that. As the [perf results](https://github.com/rust-lang/rust/pull/77107#issuecomment-697668154) show, enabling this optimization results in a lot less regression as before. cc @oli-obk r? @ghost
2020-09-26Move `qualify_min_const_fn` out of rustc into clippyOliver Scherer-463/+0
2020-09-26Rollup merge of #77122 - ecstatic-morse:const-fn-arithmetic, r=RalfJung,oli-obkRalf Jung-9/+46
Add `#![feature(const_fn_floating_point_arithmetic)]` cc #76618 This is a template for splitting up `const_fn` into granular feature gates. I think this will make it easier, both for us and for users, to track stabilization of each individual feature. We don't *have* to do this, however. We could also keep stabilizing things out from under `const_fn`. cc @rust-lang/wg-const-eval r? @oli-obk
2020-09-25No need to call `is_min_const_fn` for side-effectsDylan MacKenzie-3/+0
2020-09-25Auto merge of #77198 - jonas-schievink:rollup-i59i41h, r=jonas-schievinkbors-1/+1
Rollup of 15 pull requests Successful merges: - #76932 (Relax promises about condition variable.) - #76973 (Unstably allow assume intrinsic in const contexts) - #77005 (BtreeMap: refactoring around edges) - #77066 (Fix dest prop miscompilation around references) - #77073 (dead_code: look at trait impls even if they don't contain items) - #77086 (Include libunwind in the rust-src component.) - #77097 (Make [].as_[mut_]ptr_range() (unstably) const.) - #77106 (clarify that `changelog-seen = 1` goes to the beginning of config.toml) - #77120 (Add `--keep-stage-std` to `x.py` for keeping only standard library artifacts) - #77126 (Invalidate local LLVM cache less often) - #77146 (Install std for non-host targets) - #77155 (remove enum name from ImplSource variants) - #77176 (Removing erroneous semicolon in transmute documentation) - #77183 (Allow multiple allow_internal_unstable attributes) - #77189 (Remove extra space from vec drawing) Failed merges: r? `@ghost`
2020-09-25Rollup merge of #77066 - jonas-schievink:dest-prop-borrow, r=oli-obkJonas Schievink-1/+1
Fix dest prop miscompilation around references Closes https://github.com/rust-lang/rust/issues/77002
2020-09-25Put floating point arithmetic behind its own feature gateDylan MacKenzie-9/+22
This refactors handling of `Rvalue::{Unary,Binary}Op` in the const-checker. Now we `span_bug` if there's an unexpected type in a primitive operation. This also allows unary negation on `char` values through the const-checker because it makes the code a bit cleaner. `char` does not actually support these operations, and if it did, we could evaluate them at compile-time.
2020-09-25Add `const_fn_floating_point_arithmetic`Dylan MacKenzie-0/+24
2020-09-25Auto merge of #77157 - tmiasko:simplify-cfg-dup, r=jonas-schievinkbors-1/+0
Remove duplicated SimplifyCfg pass
2020-09-25Auto merge of #76844 - simonvandel:fix-76803, r=wesleywiserbors-23/+34
Fix #76803 miscompilation Fixes #76803 Seems like it was an oversight that the discriminant value being set was not compared to the target value from the SwitchInt, as a comment says this is a requirement for the optimization to be sound. r? `@wesleywiser` since you are probably familiar with the optimization and made #76837 to workaround the bug
2020-09-25Rollup merge of #77165 - simonvandel:do-not-fire-on-drop-and-replace, r=oli-obkJonas Schievink-2/+1
Followup to #76673 Resolves https://github.com/rust-lang/rust/pull/76673#discussion_r494426303 r? @tmiasko
2020-09-25Rollup merge of #77160 - ecstatic-morse:const-fn-transmute-suggestion, r=oli-obkJonas Schievink-1/+8
Suggest `const_fn_transmute`, not `const_fn` More fallout from #76850 in the vein of #77134. The fix is the same. I looked through the structured errors file and didn't see any more of this kind of diagnostics bug. r? @oli-obk
2020-09-25Rollup merge of #77136 - ecstatic-morse:issue-77134, r=oli-obkJonas Schievink-1/+8
Suggest `const_mut_refs`, not `const_fn` for mutable references in `const fn` Resolves #77134. Prior to #76850, most uses of `&mut` in `const fn` ~~required~~ involved two feature gates, `const_mut_refs` and `const_fn`. The first allowed all mutable borrows of locals. The second allowed only locals, arguments and return values whose types contained `&mut`. I switched the second check to the `const_mut_refs` gate. However, I forgot update the error message with the new suggestion. Alternatively, we could revert to having two different feature gates for this. OP's code never borrows anything mutably, so it didn't need `const_mut_refs` in the past, only `const_fn`. I'd prefer to keep everything under a single gate, however. r? @oli-obk
2020-09-25Rollup merge of #76724 - ecstatic-morse:dataflow-pass-names, r=lcnrJonas Schievink-2/+9
Allow a unique name to be assigned to dataflow graphviz output Previously, if the same analysis were invoked multiple times in a single compilation session, the graphviz output for later runs would overwrite that of previous runs. Allow callers to add a unique identifier to each run so this can be avoided.
2020-09-24Suggest `const_fn_transmute` instead of `const_fn`Dylan MacKenzie-1/+8
2020-09-24Resolve https://github.com/rust-lang/rust/pull/76673#discussion_r494426303Simon Vandel Sillesen-2/+1
2020-09-24EarlyOtherwiseBranch::run_pass(): don't convert Place to Place ↵Matthias Krüger-1/+1
(clippy::useless_conversion)
2020-09-24Auto merge of #76748 - tmiasko:no-op-jumps, r=matthewjasperbors-9/+10
Fix underflow when calculating the number of no-op jumps folded When removing unwinds to no-op blocks and folding jumps to no-op blocks, remove the unwind target first. Otherwise we cannot determine if target has been already folded or not. Previous implementation incorrectly assumed that all resume targets had been folded already, occasionally resulting in an underflow: ``` remove_noop_landing_pads: removed 18446744073709551613 jumps and 3 landing pads ```
2020-09-23Suggest `const_mut_refs` for mutable references in const fnDylan MacKenzie-1/+8
2020-09-24Remove duplicated SimplifyCfg passTomasz Miąsko-1/+0
2020-09-23Auto merge of #76673 - simonvandel:remove-unneeded-drops, r=oli-obkbors-0/+61
MIR pass to remove unneeded drops on types not needing drop This is heavily dependent on MIR inlining running to actually see the drop statement. Do we want to special case replacing a call to std::mem::drop with a goto aswell?
2020-09-23Enable const prop into operands at mir_opt_level=2Dániel Buga-5/+5
2020-09-23Auto merge of #76659 - simonvandel:76432, r=oli-obkbors-21/+22
SimplifyComparisonIntegral: fix miscompilation Fixes #76432 Only insert StorageDeads if we actually removed one. Fixes an issue where we added StorageDead to a place with no StorageLive r? `@oli-obk`