about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2021-09-21Rollup merge of #89113 - BoxyUwU:incr-comp-thir-act, r=lcnrthe8472-3/+6
dont `.ensure()` the `thir_abstract_const` query call in `mir_build` might fix an ICE seen in #89022 (note: this PR does not close that issue) about attempting to read stolen thir. I couldn't repro the ICE but this `.ensure` seems sus anyway. r? `@lcnr`
2021-09-20Fix ICE when `indirect_structural_match` is allowedFabian Wolff-6/+8
2021-09-20no ensureEllen-3/+6
2021-09-16Add `ConstraintCategory::Usage` for handling aggregate constructionAaron Hill-16/+36
In some cases, we emit borrowcheck diagnostics pointing at a particular field expression in a struct expression (e.g. `MyStruct { field: my_expr }`). However, this behavior currently relies on us choosing the `ConstraintCategory::Boring` with the 'correct' span. When adding additional variants to `ConstraintCategory`, (or changing existing usages away from `ConstraintCategory::Boring`), the current behavior can easily get broken, since a non-boring constraint will get chosen over a boring one. To make the diagnostic output less fragile, this commit adds a `ConstraintCategory::Usage` variant. We use this variant for the temporary assignments created for each field of an aggregate we are constructing. Using this new variant, we can emit a message mentioning "this usage", emphasizing the fact that the error message is related to the specific use site (in the struct expression). This is preparation for additional work on improving NLL error messages (see #57374)
2021-09-14Add reachable_patterns lint to rfc-2008-non_exhaustiveDevin Ragotzy-51/+170
Add linting on non_exhaustive structs and enum variants Add ui tests for non_exhaustive reachable lint Rename to non_exhaustive_omitted_patterns and avoid triggering on if let
2021-09-12Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnrManish Goregaokar-244/+5
generic_const_exprs: use thir for abstract consts instead of mir Changes `AbstractConst` building to use `thir` instead of `mir` so that there's less chance of consts unifying when they shouldn't because lowering to mir dropped information (see `abstract-consts-as-cast-5.rs` test) r? `@lcnr`
2021-09-11Rollup merge of #88849 - matthiaskrgr:clony_on_copy, r=petrochenkovJubilee-1/+1
don't clone types that are Copy (clippy::clone_on_copy)
2021-09-11Auto merge of #88327 - bonega:scalar_refactor, r=eddybbors-3/+2
`WrappingRange` (#88242) follow-up (`is_full_for`, `Scalar: Copy`, etc.) Some changes related to feedback during #88242 r? `@RalfJung`
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-1/+1
2021-09-09Ignore automatically derived impls of `Clone` and `Debug` in dead code analysisFabian Wolff-11/+9
2021-09-09Rename `(un)signed` to `(un)signed_int`Andreas Liljeqvist-1/+1
2021-09-09Move `unsigned_max` etc into `Size` againAndreas Liljeqvist-3/+2
2021-09-09rename mir -> thir around abstract constsEllen-2/+2
2021-09-09remove debug stmtsEllen-6/+0
2021-09-09move thir visitor to rustc_middleEllen-242/+1
2021-09-09WIP stateEllen-2/+10
2021-09-05Change scope of temporaries in match guardsMatthew Jasper-5/+5
Each pattern in a match arm has its own copy of the match guard in MIR, with its own temporary, so it has to be dropped before the the guards are joined to the single copy of the arm.
2021-09-02Bless 32bit MIR opt testsMatthew Jasper-4/+4
2021-09-02Remove TODOMatthew Jasper-1/+0
2021-09-01Fix drop handling for `if let` expressionsMatthew Jasper-110/+183
MIR lowering for `if let` expressions is now more complicated now that `if let` exists in HIR. This PR adds a scope for the variables bound in an `if let` expression and then uses an approach similar to how we handle loops to ensure that we reliably drop the correct variables.
2021-08-30Handle irrufutable or unreachable let-elseCameron Steffen-1/+20
2021-08-30Calculate LetSource laterCameron Steffen-40/+42
2021-08-29Auto merge of #88088 - nbdd0121:const2, r=nagisabors-1/+6
Forbid inline const block referencing params from being used in patterns Fix #82518
2021-08-27Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearthbors-12/+65
Rollup of 11 pull requests Successful merges: - #87832 (Fix debugger stepping behavior with `match` expressions) - #88123 (Make spans for tuple patterns in E0023 more precise) - #88215 (Reland #83738: "rustdoc: Don't load all extern crates unconditionally") - #88216 (Don't stabilize creation of TryReserveError instances) - #88270 (Handle type ascription type ops in NLL HRTB diagnostics) - #88289 (Fixes for LLVM change 0f45c16f2caa7c035e5c3edd40af9e0d51ad6ba7) - #88320 (type_implements_trait consider obligation failure on overflow) - #88332 (Add argument types tait tests) - #88340 (Add `c_size_t` and `c_ssize_t` to `std::os::raw`.) - #88346 (Revert "Add type of a let tait test impl trait straight in let") - #88348 (Add field types tait tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-08-26update `TypeFlags` to deal with missing ct substslcnr-4/+6
2021-08-26add `tcx` to `fn walk`lcnr-1/+1
2021-08-26make unevaluated const substs optionallcnr-8/+6
2021-08-25Fix debugger stepping behavior around `match` expressionsWesley Wiser-12/+65
Previously, we would set up the source lines for `match` expressions so that the code generated to perform the test of the scrutinee was matched to the line of the arm that required the test and then jump from the arm block to the "next" block was matched to all of the lines in the `match` expression. While that makes sense, it has the side effect of causing strange stepping behavior in debuggers. I've changed the source information so that all of the generated tests are sourced to `match {scrutinee}` and the jumps are sourced to the last line of the block they are inside. This resolves the weird stepping behavior in all debuggers and resolves some instances of "ambiguous symbol" errors in WinDbg preventing the user from setting breakpoints at `match` expressions.
2021-08-22Fix typos “an”→“a” and a few different ones that appeared in the ↵Frank Steffahn-2/+2
same search
2021-08-22Fix more “a”/“an” typosFrank Steffahn-1/+1
2021-08-22Fix typos “a”→“an”Frank Steffahn-4/+4
2021-08-20Auto merge of #88039 - sexxi-goose:fix-87987, r=nikomatsakisbors-23/+36
RFC2229 Only compute place if upvars can be resolved Closes https://github.com/rust-lang/rust/issues/87987 This PR fixes an ICE when trying to unwrap an Err. This error appears when trying to convert a PlaceBuilder into Place when upvars can't yet be resolved. We should only try to convert a PlaceBuilder into Place if upvars can be resolved. r? `@nikomatsakis`
2021-08-18Remove box syntax from rustc_mir_buildest31-59/+74
2021-08-16Forbid inline const block referencing params from being used in patternsGary Guo-1/+6
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-139/+240
2021-08-15Use correct drop scopes for if expressionsMatthew Jasper-0/+41
2021-08-14Only compute place if upvars can be resolvedRoxane-23/+36
2021-08-14Auto merge of #85020 - lrh2000:named-upvars, r=tmandrybors-13/+8
Name the captured upvars for closures/generators in debuginfo Previously, debuggers print closures as something like ``` y::main::closure-0 (0x7fffffffdd34) ``` The pointer actually references to an upvar. It is not very obvious, especially for beginners. It's because upvars don't have names before, as they are packed into a tuple. This PR names the upvars, so we can expect to see something like ``` y::main::closure-0 {_captured_ref__b: 0x[...]} ``` r? `@tmandry` Discussed at https://github.com/rust-lang/rust/pull/84752#issuecomment-831639489 .
2021-08-05Auto merge of #87737 - LeSeulArtichaut:unsafeck-less-freeze, r=oli-obkbors-18/+16
Only compute `is_freeze` for layout-constrained ADTs Places are usually shallow and quick to visit. By contrast, computing `is_freeze` can be much costlier, involving inference and trait solving. Making sure to call `is_freeze` only when necessary should be beneficial for performance in most cases. See [this comparison](https://perf.rust-lang.org/compare.html?start=81f08a4763e7537b92506fa5a597e6bf774d20cc&end=56a58d347b1c7dd0c2984b8fc3930c408e26fbc2&stat=instructions%3Au) from #87710. r? `@oli-obk`
2021-08-03Only compute `is_freeze` for layout-constrained ADTsLéo Lanteri Thauvin-18/+16
Places are usually shallow and quick to visit. By contrast, computing `is_freeze` can be much costlier, involving inference and trait solving. Making sure to call `is_freeze` only when necessary should be beneficial for performance in most cases.
2021-08-03rustc: Fill out remaining parts of C-unwind ABIAlex Crichton-72/+8
This commit intends to fill out some of the remaining pieces of the C-unwind ABI. This has a number of other changes with it though to move this design space forward a bit. Notably contained within here is: * On `panic=unwind`, the `extern "C"` ABI is now considered as "may unwind". This fixes a longstanding soundness issue where if you `panic!()` in an `extern "C"` function defined in Rust that's actually UB because the LLVM representation for the function has the `nounwind` attribute, but then you unwind. * Whether or not a function unwinds now mainly considers the ABI of the function instead of first checking the panic strategy. This fixes a miscompile of `extern "C-unwind"` with `panic=abort` because that ABI can still unwind. * The aborting stub for non-unwinding ABIs with `panic=unwind` has been reimplemented. Previously this was done as a small tweak during MIR generation, but this has been moved to a separate and dedicated MIR pass. This new pass will, for appropriate functions and function calls, insert a `cleanup` landing pad for any function call that may unwind within a function that is itself not allowed to unwind. Note that this subtly changes some behavior from before where previously on an unwind which was caught-to-abort it would run active destructors in the function, and now it simply immediately aborts the process. * The `#[unwind]` attribute has been removed and all users in tests and such are now using `C-unwind` and `#![feature(c_unwind)]`. I think this is largely the last piece of the RFC to implement. Unfortunately I believe this is still not stabilizable as-is because activating the feature gate changes the behavior of the existing `extern "C"` ABI in a way that has no replacement. My thinking for how to enable this is that we add support for the `C-unwind` ABI on stable Rust first, and then after it hits stable we change the behavior of the `C` ABI. That way anyone straddling stable/beta/nightly can switch to `C-unwind` safely.
2021-08-03Rollup merge of #87645 - LeSeulArtichaut:issue-87414, r=oli-obkYuki Okushi-7/+4
Properly find owner of closure in THIR unsafeck Previously, when encountering a closure in a constant, the THIR unsafeck gets invoked on the owner of the constant instead of the constant itself, producing cycles. Supersedes #87492. ```@FabianWolff``` thanks for your work on that PR, I copied your test file and added you as a co-author. Fixes #87414. r? ```@oli-obk```
2021-07-30Properly find owner of closure in THIR unsafeckLeSeulArtichaut-7/+4
Co-authored-by: FabianWolff <fabian.wolff@alumni.ethz.ch>
2021-07-28Auto merge of #86251 - Smittyvb:thir-tree-again, r=oli-obkbors-0/+8
Support -Z unpretty=thir-tree again Currently `-Z unpretty=thir-tree` is broken after some THIR refactorings. This re-implements it, making it easier to debug THIR-related issues. We have to do analyzes before getting the THIR, since trying to create THIR from invalid HIR can ICE. But doing those analyzes requires the THIR to be built and stolen. We work around this by creating a separate query to construct the THIR tree string representation. Closes https://github.com/rust-lang/project-thir-unsafeck/issues/8, fixes #85552.
2021-07-27Auto merge of #80367 - camelid:check_match-combine-loop, r=Nadrierilbors-8/+3
Combine two loops in `check_match` Suggested by Nadrieril in https://github.com/rust-lang/rust/pull/79051#discussion_r548778186. Opening to get a perf run. Hopefully this code doesn't require everything in the first loop to be done before running the second! (It shouldn't though.) cc `@Nadrieril`
2021-07-27Auto merge of #85305 - MarcusDunn:master, r=pnkfelixbors-48/+1
Stabilize bindings_after_at attempting to stabilze bindings_after_at [#65490](https://github.com/rust-lang/rust/issues/65490), im pretty new to the whole thing so any pointers are greatly appreciated.
2021-07-24Support -Z unpretty=thir-tree againSmitty-0/+8
2021-07-23Implement `AssignToDroppingUnionField` in THIR unsafeckLeSeulArtichaut-17/+31
2021-07-22Combine two loops in `check_match`Camelid-8/+3
Suggested by Nadrieril in https://github.com/rust-lang/rust/pull/79051#discussion_r548778186.
2021-07-18Revert "structural_match: non-structural-match ty closures"Santiago Pastorino-3/+0
Reverts #73353