about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2021-06-24Rollup merge of #86566 - fee1-dead:mir-pretty-print, r=oli-obkYuki Okushi-27/+19
Use `use_verbose` for `mir::Constant` Fixes #79799.
2021-06-23Use HTTPS links where possibleSmitty-1/+1
2021-06-23Use `use_verbose` for mir::ConstantDeadbeef-27/+19
2021-06-22implemented separate_const_switch MIR optThéo Degioanni-0/+345
un-update itertools improve predecessor amount short-circuiting cleanup and comments somewhat improved drawing
2021-06-22Rollup merge of #86517 - camsteffen:unused-unsafe-async, r=LeSeulArtichautYuki Okushi-0/+1
Fix `unused_unsafe` around `await` Enables `unused_unsafe` lint for `unsafe { future.await }`. The existing test for this is `unsafe { println!() }`, so I assume that `println!` used to contain compiler-generated unsafe but this is no longer true, and so the existing test is broken. I replaced the test with `unsafe { ...await }`. I believe `await` is currently the only instance of compiler-generated unsafe. Reverts some parts of #85421, but the issue predates that PR.
2021-06-21Fix unused_unsafe with compiler-generated unsafeCameron Steffen-0/+1
2021-06-21Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3bors-0/+102
Add MIR pass to lower call to `core::slice::len` into `Len` operand During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator. It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how. Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
2021-06-20Squashed implementation of the passAlex Vlasov-0/+102
2021-06-19Auto merge of #86437 - nikomatsakis:tait-docs, r=oli-obkbors-2/+55
add various coments to explain how the TAIT code works r? `@oli-obk`
2021-06-19Rollup merge of #86407 - LingMan:map-or, r=LeSeulArtichautYuki Okushi-6/+3
Use `map_or` instead of open-coding it `@rustbot` modify labels +C-cleanup +T-compiler
2021-06-18fix typosNiko Matsakis-3/+4
2021-06-18add various coments to explain how the code worksNiko Matsakis-2/+54
2021-06-18Auto merge of #85421 - Smittyvb:rm_pushpop_unsafe, r=matthewjasperbors-1/+0
Remove some last remants of {push,pop}_unsafe! These macros have already been removed, but there was still some code handling these macros. That code is now removed.
2021-06-17Use `map_or` instead of open-coding itLingMan-6/+3
2021-06-17Auto merge of #86399 - JohnTitor:rollup-qlm2dvz, r=JohnTitorbors-27/+42
Rollup of 7 pull requests Successful merges: - #85663 (Document Arc::from) - #85802 (Rename IoSlice(Mut)::advance to advance_slice and add IoSlice(Mut)::advance) - #85970 (Remove methods under Implementors on trait pages) - #86340 (Use better error message for hard errors in CTFE) - #86343 (Do not emit invalid suggestions on multiple mutable borrow errors) - #86355 (Remove invalid suggestions for assoc consts on placeholder type error) - #86389 (Make `sum()` and `product()` documentation hyperlinks refer to `Iterator` methods.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-06-17Rollup merge of #86343 - JohnTitor:issue-85581, r=estebankYuki Okushi-8/+26
Do not emit invalid suggestions on multiple mutable borrow errors Fixes #85581
2021-06-17Rollup merge of #86340 - Smittyvb:ctfe-hard-error-message, r=RalfJungYuki Okushi-19/+16
Use better error message for hard errors in CTFE I noticed this while working on #86255: currently the same message is used for hard errors and soft errors in CTFE. This changes the error messages to make hard errors use a message that indicates the reality of the situation correctly, since usage of the constant is never allowed when there was a hard error evaluating it. This doesn't affect the behaviour of these error messages, only the content. This changes the error logic to check if the error should be hard or soft where it is generated, instead of where it is emitted, to allow this distinction in error messages.
2021-06-17Auto merge of #85755 - b-naber:unexpected_concrete_region, r=nikomatsakisbors-27/+11
Replace parent substs of associated types with inference vars in borrow checker Fixes https://github.com/rust-lang/rust/issues/83190 Fixes https://github.com/rust-lang/rust/issues/78450 When we normalize an associated type that refers to an opaque type, it can happen that the substs of the associated type do not occur in the projection (they are parent substs). We previously didn't replace those substs with inference vars, which left a concrete region after all regions should have already been replaced with inference vars and triggered a `delay_span_bug`. After we normalize the opaque type, we now try to replace any remaining concrete regions with inference vars.
2021-06-17use to_region_vid in opaque type codeNiko Matsakis-33/+13
Normalization can pull in named regions from the parameter environment. We need to be prepared for that in the opaque types code.
2021-06-16Move some hard error logic to InterpErrorSmitty-15/+17
2021-06-17Rollup merge of #86341 - LingMan:ret_val, r=davidtwcoYuki Okushi-11/+14
Stop returning a value from `report_assert_as_lint` This function only ever returns `None`. Make that explicity by not returning a value at all. `@rustbot` modify labels +C-cleanup +T-compiler
2021-06-17Rollup merge of #85870 - ptrojahn:mir_dump_whitespace, r=davidtwcoYuki Okushi-1/+4
Allow whitespace in dump_mir filter At least on my system this is necessary to get more complex filters with spaces like in https://rustc-dev-guide.rust-lang.org/mir/debugging.html working.
2021-06-16Auto merge of #86291 - crlf0710:trait_vtbl_refactor, r=bjorn3bors-45/+68
Refactor vtable codegen This refactor the codegen of vtables of miri interpreter, llvm, cranelift codegen backends. This is preparation for the implementation of trait upcasting feature. cc #65991 Note that aside from code reorganization, there's an internal behavior change here that now InstanceDef::Virtual's index now include the three metadata slots, and now the first method is with index 3. cc `@RalfJung` `@bjorn3`
2021-06-16Do not emit invalid suggestions on multiple mutable borrow errorsYuki Okushi-8/+26
2021-06-16Stop returning a value from `report_assert_as_lint`LingMan-11/+14
This function only ever returns `None`. Make that explicity by not returning a value at all.
2021-06-15Use better error message for hard errors in CTFESmitty-9/+4
Currently the same message is used for hard errors and soft errors. This makes hard errors use a message that indicates the reality of the situation correctly, since usage of the constant is never allowed when there was a hard error evaluating it.
2021-06-15Refactor to make interpreter and codegen backend neutral to vtable internal ↵Charles Lew-45/+68
representation.
2021-06-14Adjust `throw_validation_failure` macro to shorten the use of ↵Rémy Rakic-13/+10
`with_no_trimmed_paths`
2021-06-13Improve CTFE validation error messageRémy Rakic-8/+12
2021-06-13Turn incorrect vtable size/alignment errors into hard const-UB errorsRémy Rakic-9/+10
They were "freeform const UB" error message, but could reach validation and trigger ICEs there. We now catch them during validation to avoid that.
2021-06-12Rollup merge of #86174 - lqd:const-ub-align, r=RalfJungYuki Okushi-1/+3
Detect incorrect vtable alignment during const eval This PR fixes #86132 by detecting invalid alignment values for trait objects in the interpreter, and emitting an error about this conversion failure, to avoid the ICE. I've noticed that the error emitted at https://github.com/rust-lang/rust/blob/a50d72158e08e02cfc051b863017bdbd2c45b637/compiler/rustc_mir/src/interpret/traits.rs#L163-L166 doesn't seem to be present in the const-ub tests, so I've tried adding a test that triggers both of these cases: one for the invalid size, and another for the invalid alignment that #86132 tracks (I have found different magic values triggering different `Align::from_bytes` errors than the "power of 2" one, if need be). However, when doing that, I *cannot* for the life of me figure out the correct incantation to make these 2 errors trigger with the "it is undefined behavior to use this value" message rather than the "any use of this value will cause an error" lint. I've tried Oli's suggestions of different values, tuples and arrays, using the transparent wrapper trick from the other tests and I was only able to trigger the regular const-ub errors about the size of the vtable, or that the drop pointer was invalid. Maybe these "type validation failed" errors happen before this part of the interpreter is reached and there just needs some magic incorrect values to bypass them, I don't know. Since this fixes an ICE, and if the constants are indeed used, these 2 tests will turn into a hard error, I thought I'd open the PR anyways. And if ```@RalfJung``` you know of a way I could manage that (if you think that these tests are worth checking that the `throw_ub_format!` does indeed create const-ub errors as we expect) I'd be grateful. For that reason, r? ```@RalfJung``` and cc ```@oli-obk.```
2021-06-12Rollup merge of #85823 - fee1-dead:borrowck-0, r=jackh726Yuki Okushi-2/+6
Do not suggest ampmut if rhs is already mutable Removes invalid suggestion in #85765, although it should highlight the user type instead of the local variable. Looking at the comments of this line: https://github.com/rust-lang/rust/blob/84b1005bfd22e2cb2a4c13b0b81958fe72628354/compiler/rustc_mir_build/src/build/matches/mod.rs#L2107 It was intentionally set to `None`, causing it to highlight the local variable instead. I am not sure if I will be able to fix it. Fixes #85765
2021-06-11Auto merge of #85994 - tmiasko:monomorphic-needs-drop, r=RalfJungbors-1/+6
Disallow non-monomorphic calls to `needs_drop` in interpreter otherwise evaluation could change after further substitutions.
2021-06-09detect incorrect vtable alignment during const eval instead of ICE-ingRémy Rakic-1/+3
also add tests for these 2 kinds of errors for size and alignment, as the existing size check wasn't apparently tested
2021-06-09Auto merge of #86118 - spastorino:tait-soundness-bug, r=nikomatsakisbors-43/+37
Create different inference variables for different defining uses of TAITs Fixes #73481 r? `@nikomatsakis` cc `@oli-obk`
2021-06-09Auto merge of #86107 - Smittyvb:peephole-optim-eq-bool, r=wesleywiserbors-7/+14
Peephole optimize `x == false` and `x != true` This adds peephole optimizations to make `x == false`, `false == x`, `x != true`, and `true != x` get optimized to `!x` in the `instcombine` MIR pass. That pass currently handles `x == true` -> `x` already.
2021-06-08Simplify code by using VecMap::get_bySantiago Pastorino-3/+1
2021-06-07Remove substs from OpaqueTypeDecl, use the one in OpaqueTypeKeySantiago Pastorino-1/+1
2021-06-07Use substs from opaque type key instead of using it from opaque_declSantiago Pastorino-11/+7
2021-06-07Make opaque type map key be of type OpaqueTypeKeySantiago Pastorino-2/+4
2021-06-07Remove ResolvedOpaqueTy and just use Ty, SubstsRef is already thereSantiago Pastorino-27/+18
2021-06-07Make OpaqueTypeKey the key of opaque types mapSantiago Pastorino-28/+34
2021-06-07Change concrete opaque type to be a `VecMap`Santiago Pastorino-2/+3
2021-06-07Change opaque type map to be a `VecMap`Santiago Pastorino-1/+1
2021-06-07Peephole optimize `x == false` and `x != true`Smitty-7/+14
2021-06-07Rollup merge of #85973 - LingMan:indentation, r=jyn514Yuki Okushi-25/+22
Replace a `match` with an `if let` Seems like a better fit here and saves one level of indentation. `@rustbot` modify labels +C-cleanup +T-compiler
2021-06-06Remove some last remants of {push,pop}_unsafe!Smitty-1/+0
These macros have already been removed, but there was still some code handling these macros. That code is now removed.
2021-06-06Add variance-related information to lifetime error messagesAaron Hill-101/+172
2021-06-05Explain that `ensure_monomorphic_enough` omission is intentionalTomasz Miąsko-0/+2
2021-06-05Disallow non-monomorphic calls to `needs_drop` in interpreterTomasz Miąsko-1/+4
otherwise evaluation could change after further substitutions.