about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src/build
AgeCommit message (Collapse)AuthorLines
2022-01-21Rollup merge of #93046 - est31:let_else, r=davidtwcoMatthias Krüger-21/+17
Use let_else in even more places Followup of #89933, #91018, #91481.
2022-01-18Formally implement let chainsCaio-14/+23
2022-01-18Use let_else in even more placesest31-21/+17
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-39/+2
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-16Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnrbors-6/+4
partially revertish `lazily "compute" anon const default substs` reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049> r? `@lcnr`
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-4/+3
2022-01-15initial revertEllen-6/+4
2022-01-13Auto merge of #89861 - nbdd0121:closure, r=wesleywiserbors-2/+2
Closure capture cleanup & refactor Follow up of #89648 Each commit is self-contained and the rationale/changes are documented in the commit message, so it's advisable to review commit by commit. The code is significantly cleaner (at least IMO), but that could have some perf implication, so I'd suggest a perf run. r? `@wesleywiser` cc `@arora-aman`
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-39/+2
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-8/+3
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-07Remove span from UpvarCapture::ByValueGary Guo-2/+2
This span is unused and is superseded by capture_kind_expr_id in CaptureInfo
2021-12-22Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`Aaron Hill-1/+1
The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
2021-12-03Add initial AST and MIR support for unwinding from inline assemblyAmanieu d'Antras-3/+8
2021-11-18Use more let_else in rustc_mir_buildest31-57/+55
Helps avoid rightward drift.
2021-11-15rustc_mir_build: reorder bindingsKrasimir Georgiev-1/+1
No functional changes intended. I'm playing around with building compiler components using nightly rust (2021-11-02) in a non-standard way. I encountered the following error while trying to build rustc_mir_build: ``` error[E0597]: `wildcard` does not live long enough --> rust/src/nightly/compiler/rustc_mir_build/src/build/matches/mod.rs:1767:82 | 1767 | let mut otherwise_candidate = Candidate::new(expr_place_builder.clone(), &wildcard, false); | ^^^^^^^^^ borrowed value does not live long enough ... 1799 | } | - | | | `wildcard` dropped here while still borrowed | borrow might be used here, when `guard_candidate` is dropped and runs the destructor for type `Candidate<'_, '_>` | = note: values in a scope are dropped in the opposite order they are defined ``` I believe this flags an issue that may become an error in the future. Swapping the order of `wildcard` and `guard_candidate` resolves it.
2021-10-16Adopt let_else across the compilerest31-9/+3
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-08clippy::complexity fixesMatthias Krüger-2/+2
2021-09-29Rollup merge of #89311 - FabianWolff:issue-89305, r=oli-obkEric Huss-3/+6
Add unit assignment to MIR for `asm!()` Fixes #89305. `ExprKind::LlvmInlineAsm` gets a `push_assign_unit()` here: https://github.com/rust-lang/rust/blob/2b6ed3b675475abc01ce7e68bb75b457f0c85684/compiler/rustc_mir_build/src/build/expr/into.rs#L475-L479 The same should probably happen for `ExprKind::InlineAsm`, which fixes the "use of possibly-uninitialized variable" error described in #89305.
2021-09-28Add unit assignment to MIR for `asm!()`Fabian Wolff-3/+6
2021-09-25Use Rvalue::ShallowInitBox for box expressionGary Guo-2/+53
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-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-12Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnrManish Goregaokar-2/+4
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-2/+0
2021-09-09WIP stateEllen-2/+6
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-109/+178
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-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-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-1/+1
same search
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-48/+64
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-76/+96
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-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-07-10Implement Mutation- and BorrowOfLayoutConstrainedField in thir-unsafeckFabian Wolff-1/+3