about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform
AgeCommit message (Collapse)AuthorLines
2021-02-21Make MatchBranchSimplification clean up after itselfSimon Vandel Sillesen-1/+10
2021-02-21Drive-by formatting of commentSimon Vandel Sillesen-2/+2
2021-02-21remove redundant wrapping of return types of allow_internal_unstable() and ↵Matthias Krüger-2/+1
rustc_allow_const_fn_unstable()
2021-02-20all InterpError allocate now, so adjust alloc-error-checkRalf Jung-2/+2
2021-02-20make `super_projection` take a `PlaceRef`Henry Boisdequin-2/+1
2021-02-20Auto merge of #82124 - tmiasko:op-ty-ref, r=oli-obkbors-28/+28
Pass large interpreter types by reference, not value r? `@ghost`
2021-02-18Stabilize `unsafe_op_in_unsafe_fn` lintLeSeulArtichaut-3/+2
2021-02-18Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.Eduard-Mihai Burtescu-3/+3
2021-02-17Reduce size of InterpErrorInfo to 8 bytesTomasz Miąsko-1/+1
2021-02-16./x.py fmtTomasz Miąsko-3/+3
2021-02-16Pass PlaceTy by reference not valueTomasz Miąsko-9/+9
2021-02-16Pass OpTy by reference not valueTomasz Miąsko-17/+17
2021-02-16make `visit_projection` take a `PlaceRef`Henry Boisdequin-12/+2
2021-02-16update formatingHenry Boisdequin-6/+16
2021-02-15Rollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebankJonas Schievink-0/+35
Suggest to create a new `const` item if the `fn` in the array is a `const fn` Fixes #73734. If the `fn` in the array repeat expression is a `const fn`, suggest creating a new `const` item. On nightly, suggest creating an inline `const` block. This PR also removes the `suggest_const_in_array_repeat_expressions` as it is no longer necessary. Example: ```rust fn main() { // Should not compile but hint to create a new const item (stable) or an inline const block (nightly) let strings: [String; 5] = [String::new(); 5]; println!("{:?}", strings); } ``` Gives this error: ``` error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:3:32 | 2 | let strings: [String; 5] = [String::new(); 5]; | ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `String` | = note: the `Copy` trait is required because the repeated element will be copied ``` With this change, this is the error message: ``` error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:3:32 | LL | let strings: [String; 5] = [String::new(); 5]; | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | = help: moving the function call to a new `const` item will resolve the error ```
2021-02-14use option<PlaceRef<'tcx>> to clean up mir code a littleHenry Boisdequin-9/+10
2021-02-13Use debug log level for developer oriented logsTomasz Miąsko-4/+7
The information logged here is of limited general interest, while at the same times makes it impractical to simply enable logging and share the resulting logs due to the amount of the output produced. Reduce log level from info to debug for developer oriented information. For example, when building cargo, this reduces the amount of logs generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB. Continuation of changes from 81350.
2021-02-11Auto merge of #81350 - tmiasko:instrument-debug, r=lcnrbors-1/+1
Reduce log level used by tracing instrumentation from info to debug Restore log level to debug to avoid make info log level overly verbose (the uses of instrument attribute modified there, were for the most part a replacement for `debug!`; one use was novel).
2021-02-05Never MIR inline functions with a different instruction setTomasz Miąsko-0/+5
2021-02-03added a suggestion to create a `const` item if the `fn` in the array repeat ↵Henry Boisdequin-0/+35
expression is a `const fn`
2021-01-31Rollup merge of #80404 - JulianKnodt:arr_ref, r=oli-obkJonas Schievink-63/+3
Remove const_in_array_repeat Fixes #80371. Fixes #81315. Fixes #80767. Fixes #75682. I thought there might be some issue with `Repeats(_, 0)`, but if you increase the items in the array it still ICEs. I'm not sure if this is the best fix but it does fix the given issue.
2021-01-30Remove const_in_array_rep_exprkadmin-64/+5
2021-01-28Avoid memory allocation when removing dead blocksTomasz Miąsko-7/+6
Use `reachable_as_bitset` to reuse a bitset from the traversal rather than allocating it seprately. Additionally check if there are any unreachable blocks before proceeding.
2021-01-27Check that value is explicitly nonekadmin-2/+1
2021-01-25Auto merge of #68828 - oli-obk:inline_cycle, r=wesleywiserbors-18/+254
Prevent query cycles in the MIR inliner r? `@eddyb` `@wesleywiser` cc `@rust-lang/wg-mir-opt` The general design is that we have a new query that is run on the `validated_mir` instead of on the `optimized_mir`. That query is forced before going into the optimization pipeline, so as to not try to read from a stolen MIR. The query should not be cached cross crate, as you should never call it for items from other crates. By its very design calls into other crates can never cause query cycles. This is a pessimistic approach to inlining, since we strictly have more calls in the `validated_mir` than we have in `optimized_mir`, but that's not a problem imo.
2021-01-24Rollup merge of #78578 - oli-obk:const_mut_refs, r=RalfJungJonas Schievink-30/+70
Permit mutable references in all const contexts fixes #71212 cc `@rust-lang/wg-const-eval` `@christianpoveda`
2021-01-24Reduce log level used by tracing instrumentation from info to debugTomasz Miąsko-1/+1
2021-01-23Leave some notes for future changes to the MIR opt level of mir inliningoli-1/+9
2021-01-23Make sure that const prop does not produce unsilenceable lints after inliningoli-1/+9
2021-01-23Prevent query cycles during inliningoli-17/+237
2021-01-23Auto merge of #80579 - RalfJung:no-fallible-promotion, r=oli-obkbors-26/+86
avoid promoting division, modulo and indexing operations that could fail For division, `x / y` will still be promoted if `y` is a non-zero integer literal; however, `1/(1+1)` will not be promoted any more. While at it, also see if we can reject promoting floating-point arithmetic (which are [complicated](https://github.com/rust-lang/unsafe-code-guidelines/issues/237) so maybe we should not promote them). This will need a crater run to see if there's code out there that relies on these things being promoted. If we can land this, promoteds in `fn`/`const fn` cannot fail to evaluate any more, which should let us do some simplifications in codegen/Miri! Cc https://github.com/rust-lang/rfcs/pull/3027 Fixes https://github.com/rust-lang/rust/issues/61821 r? `@oli-obk`
2021-01-23Do not allow arbitrary mutable references in `static mut`, just keep with ↵oli-6/+2
the existing exceptions
2021-01-23Adjust wording of a diagnosticoli-1/+1
2021-01-23Permit mutable references in all const contextsoli-28/+72
2021-01-22Auto merge of #81101 - tmiasko:combine-now, r=nagisabors-284/+77
Combine instructions immediately
2021-01-22do promote array indexing if we know it is in-boundsRalf Jung-15/+49
2021-01-22avoid promoting division, modulo and indexing operations that could failRalf Jung-13/+39
2021-01-21Auto merge of #81122 - tmiasko:no-drop, r=davidtwcobors-41/+20
Visit only terminators when removing unneeded drops No functional changes intended
2021-01-21Rollup merge of #81187 - eltociear:patch-6, r=jonas-schievinkYuki Okushi-1/+1
Fix typo in counters.rs formating -> formatting
2021-01-21Rollup merge of #81178 - tmiasko:no-landing-pads, r=oli-obkYuki Okushi-23/+8
Visit only terminators when removing landing pads No functional changes intended
2021-01-19Fix typo in counters.rsIkko Ashimine-1/+1
formating -> formatting
2021-01-19Auto merge of #81110 - LeSeulArtichaut:fix-unused-unsafe-label, r=RalfJungbors-8/+9
Fix `unused_unsafe` label with `unsafe_block_in_unsafe_fn Previously, the following code: ```rust #![feature(unsafe_block_in_unsafe_fn)] unsafe fn foo() { unsafe { unsf() } } unsafe fn unsf() {} ``` Would give the following warning: ``` warning: unnecessary `unsafe` block --> src/lib.rs:4:5 | 4 | unsafe { unsf() } | ^^^^^^ unnecessary `unsafe` block | = note: `#[warn(unused_unsafe)]` on by default ``` which doesn't point out that the block is in an `unsafe fn`. Tracking issue: #71668 cc #79208
2021-01-18Auto merge of #80707 - oli-obk:stability_hole_const_intrinsics, r=RalfJungbors-8/+18
Stability oddity with const intrinsics cc `@RalfJung` In https://github.com/rust-lang/rust/pull/80699#discussion_r551495670 `@usbalbin` realized we accepted some intrinsics as `const` without a `#[rustc_const_(un)stable]` attribute. I did some digging, and that example works because intrinsics inherit their stability from their parents... including `#[rustc_const_(un)stable]` attributes. While we may want to fix that (not sure, wasn't there just a MCPed PR that caused this on purpose?), we definitely want tests for it, thus this PR adding tests and some fun tracing statements.
2021-01-18Combine instructions immediatelyTomasz Miąsko-147/+79
No functional changes intended
2021-01-18Remove disabled transformation from instcombineTomasz Miąsko-142/+3
2021-01-18Rollup merge of #81121 - tmiasko:simplify-cfg-no-dbg, r=jonas-schievinkAshley Mannix-1/+1
Avoid logging the whole MIR body in SimplifyCfg
2021-01-18Rollup merge of #81116 - bugadani:body-span, r=wesleywiserAshley Mannix-1/+1
ConstProp: Copy body span instead of querying it
2021-01-18Only inherit const stability for methods of `impl const Trait` blocksoli-1/+1
2021-01-18Auto merge of #80865 - oliviacrain:proj_based, r=RalfJungbors-90/+83
Use PlaceRef projection abstractions more consistently in rustc_mir PlaceRef contains abstractions for dealing with the `projections` array. This PR uses these abstractions more consistently within the `rustc_mir` crate. See associated issue: rust-lang/rust#80647. r? `@RalfJung`
2021-01-18Visit only terminators when removing landing padsTomasz Miąsko-23/+8
No functional changes intended