about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2021-01-31Rollup merge of #80404 - JulianKnodt:arr_ref, r=oli-obkJonas Schievink-77/+4
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-31Rollup merge of #80092 - sexxi-goose:restrict_precision, r=nikomatsakisJonas Schievink-47/+84
2229: Fix issues with move closures and mutability This PR fixes two issues when feature `capture_disjoint_fields` is used. 1. Can't mutate using a mutable reference 2. Move closures try to move value out through a reference. To do so, we 1. Compute the mutability of the capture and store it as part of the `CapturedPlace` that is written in TypeckResults 2. Restrict capture precision. Note this is temporary for now, to allow the feature to be used with move closures and ByValue captures and might change depending on discussions with the lang team. - No Derefs are captured for ByValue captures, since that will result in value behind a reference getting moved. - No projections are applied to raw pointers since these require unsafe blocks. We capture them completely. r? `````@nikomatsakis`````
2021-01-31Auto merge of #81327 - RalfJung:codegen-no-const-fail, r=oli-obkbors-0/+4
codegen: assume constants cannot fail to evaluate https://github.com/rust-lang/rust/pull/80579 landed, so we can finally remove this old hack from codegen and instead assume that consts never fail to evaluate. :) r? `@oli-obk`
2021-01-30Remove const_in_array_rep_exprkadmin-78/+6
2021-01-30codegen: assume constants cannot fail to evaluateRalf Jung-0/+4
also don't submit code to LLVM when the session has errors
2021-01-30Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-seYuki Okushi-2/+2
Stabilize `unsigned_abs` Resolves #74913. This PR stabilizes the `i*::unsigned_abs()` method, which returns the absolute value of an integer _as its unsigned equivalent_. This has the advantage that it does not overflow on `i*::MIN`. I have gone ahead and used this in a couple locations throughout the repository.
2021-01-29Fix typosAman Arora-2/+2
2021-01-29Add fixme for precise path diagnosticsAman Arora-5/+7
2021-01-29Fix incorrect use mut diagnosticsAman Arora-35/+50
2021-01-29Fix unused 'mut' warning for capture's root variableAman Arora-4/+29
2021-01-29Compute mutability of closure capturesAman Arora-7/+2
When `capture_disjoint_fields` is not enabled, checking if the root variable binding is mutable would suffice. However with the feature enabled, the captured place might be mutable because it dereferences a mutable reference. This PR computes the mutability of each capture after capture analysis in rustc_typeck. We store this in `ty::CapturedPlace` and then use `ty::CapturedPlace::mutability` in mir_build and borrow_check.
2021-01-29Auto merge of #81470 - tmiasko:remove-allocations, r=matthewjasperbors-7/+6
Avoid memory allocation when removing dead blocks 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-29Auto merge of #81440 - tmiasko:always-live-locals, r=matthewjasperbors-19/+12
Visit only statements in always live locals No functional changes intended.
2021-01-29Rollup merge of #81333 - RalfJung:const-err-simplify, r=oli-obkYuki Okushi-74/+28
clean up some const error reporting around promoteds These are some error reporting simplifications enabled by https://github.com/rust-lang/rust/pull/80579. Further simplifications are possible but could be blocked on making `const_err` a hard error. r? ``````@oli-obk``````
2021-01-29Rollup merge of #81158 - 1000teslas:issue-80313-fix, r=Aaron1011Yuki Okushi-1/+55
Point to span of upvar making closure FnMut For #80313.
2021-01-28Auto merge of #81441 - tmiasko:ctfe-inline, r=oli-obkbors-0/+1
Try inlining trivial functions used by CTFE r? `@ghost`
2021-01-28Rename NLL* to Nll* accordingly to C-CASEHirochika Matsumoto-60/+60
2021-01-28Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakisYuki Okushi-9/+6
Refractor a few more types to `rustc_type_ir` In the continuation of #79169, ~~blocked on that PR~~. This PR: - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance` - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler. ~~I will split up that commit to make this easier to review and to have a better commit history.~~ EDIT: done, I split the PR in commits of 200-ish lines each r? `````@nikomatsakis````` cc `````@jackh726`````
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-27Inline MemPlace::offsetTomasz Miąsko-0/+1
2021-01-27Check that value is explicitly nonekadmin-2/+1
2021-01-27Visit only statements in always live localsTomasz Miąsko-19/+12
No functional changes intended.
2021-01-27Rollup merge of #80900 - camelid:readpointerasbytes-ice, r=oli-obkYuki Okushi-1/+5
Fix ICE with `ReadPointerAsBytes` validation error Fixes #79690. r? ``````@oli-obk``````
2021-01-25Auto merge of #68828 - oli-obk:inline_cycle, r=wesleywiserbors-18/+256
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-25Point to span of upvar making closure FnMut1000teslas-1/+55
Add expected error Add comment Tweak comment wording Fix after rebase to updated master Fix after rebase to updated master Distinguish mutation in normal and move closures Tweak error message Fix error message for nested closures Refactor code showing mutated upvar in closure Remove debug assert B
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-24clean up some const error reporting around promotedsRalf Jung-74/+28
2021-01-24Reduce log level used by tracing instrumentation from info to debugTomasz Miąsko-2/+2
2021-01-23Rollup merge of #81243 - osa1:fix_80742_2, r=RalfJungJonas Schievink-0/+1
mir: Improve size_of handling when arg is unsized As discussed on Zulip with `@RalfJung.`
2021-01-23Rollup merge of #81072 - RalfJung:place-ref-ty, r=oli-obkJonas Schievink-6/+8
PlaceRef::ty: use method call syntax
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/+239
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-21mir: Improve size_of handling when arg is unsizedÖmer Sinan Ağacan-0/+1
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 #81185 - osa1:fix_80742, r=oli-obkYuki Okushi-4/+7
Fix ICE in mir when evaluating SizeOf on unsized type Not quite ready yet. This tries to fix #80742 as discussed on [Zulip topic][1], by using `delay_span_bug`. I don't understand what `delay_span_bug` does. It seems like my error message is never used. With this patch, in this program: ```rust #![allow(incomplete_features)] #![feature(const_evaluatable_checked)] #![feature(const_generics)] use std::fmt::Debug; use std::marker::PhantomData; use std::mem::size_of; struct Inline<T> where [u8; size_of::<T>() + 1]: , { _phantom: PhantomData<T>, buf: [u8; size_of::<T>() + 1], } impl<T> Inline<T> where [u8; size_of::<T>() + 1]: , { pub fn new(val: T) -> Inline<T> { todo!() } } fn main() { let dst = Inline::<dyn Debug>::new(0); // line 27 } ``` these errors are printed, both for line 27 (annotated line above): - "no function or associated item named `new` found for struct `Inline<dyn Debug>` in the current scope" - "the size for values of type `dyn Debug` cannot be known at compilation time" Second error makes sense, but I'm not sure about the first one and why it's even printed. Finally, I'm not sure about the span passing in `const_eval`. [1]: https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Help.20fixing.20.2380742
2021-01-21Rollup merge of #81178 - tmiasko:no-landing-pads, r=oli-obkYuki Okushi-24/+9
Visit only terminators when removing landing pads No functional changes intended
2021-01-19Fix ICE in mir when evaluating SizeOf on unsized typeÖmer Sinan Ağacan-4/+7
Fixes #80742
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-18Use ty::{IntTy,UintTy,FloatTy} in rustcLeSeulArtichaut-9/+6