about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src/nll.rs
AgeCommit message (Collapse)AuthorLines
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-2/+2
2023-12-02Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errorsbors-3/+3
Cleanup error handlers Mostly by making function naming more consistent. More to do after this, but this is enough for one PR. r? compiler-errors
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-1/+1
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-12-02Rename `Handler::span_note_diag` as `struct_span_note`.Nicholas Nethercote-2/+2
Because `span_note_diag` doesn't follow the naming structure used for the error reporting functions.
2023-12-01move and maintain live loans in `LivenessValues`Rémy Rakic-21/+16
Liveness data is pushed from multiple parts of NLL. Instead of changing the call sites to maintain live loans, move the latter to `LivenessValues` where this liveness data is pushed to, and maintain live loans there. This fixes the differences in polonius scopes on some CFGs where a variable was dead in tracing but as a MIR terminator its regions were marked live from "constraint generation"
2023-12-01Auto merge of #118216 - lqd:constraint-generation-non-non, r=matthewjasperbors-137/+15
Refactor NLL constraint generation and most of polonius fact generation As discussed in #118175, NLL "constraint generation" is only about liveness, but currently also contains legacy polonius fact generation. The latter is quite messy, and this PR cleans this up to prepare for its future removal: - splits polonius fact generation out of NLL constraint generation - merges NLL constraint generation to its more natural place, liveness - extracts all of the polonius fact generation from NLLs apart from MIR typeck (as fact generation is somewhat in a single place there already, but should be cleaned up) into its own explicit module, with a single entry point instead of many. There should be no behavior changes, and tests seem to behave the same as master: without polonius, with legacy polonius, with the in-tree polonius. I've split everything into smaller logical commits for easier review, as it required quite a bit of code to be split and moved around, but it should all be trivial changes. r? `@matthewjasper`
2023-11-26Remove Upvar duplicationMark Rousskov-2/+2
This cuts out an extra allocation and copying over from the already cached closure capture information.
2023-11-26move remaining legacy polonius fact generation out of NLL moduleRémy Rakic-22/+6
2023-11-26merge NLL "constraint generation" into livenessRémy Rakic-3/+1
2023-11-26remove polonius fact generation from NLL constraint generationRémy Rakic-8/+1
2023-11-26simplify polonius constraint generationRémy Rakic-1/+1
2023-11-26remove NLL liveness from polonius constraint generationRémy Rakic-1/+0
2023-11-26extract polonius "constraint generation"Rémy Rakic-0/+8
to help review, this duplicates the existing NLL + polonius constraint generation component, before splitting them up to only do what they individually need.
2023-11-26another trivial cleanupRémy Rakic-3/+2
fix a comment and move a variable where it's used
2023-11-26extract polonius loan invalidations fact generationRémy Rakic-4/+8
and move the polonius module to the borrowck root
2023-11-26extract polonius universal regions fact generationRémy Rakic-34/+5
2023-11-26extract polonius move fact generationRémy Rakic-85/+7
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-6/+6
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-10-05compute NLL loan scopes with liveness in `-Zpolonius=next`Rémy Rakic-16/+21
2023-10-04introduce `Polonius` enum for `-Zpolonius`Rémy Rakic-2/+3
this allows to opt into using the legacy version or the in-tree prototype
2023-09-11Disentangle `Debug` and `Display` for `Ty`.Nicholas Nethercote-1/+5
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attribute) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path.
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-3/+3
r? @WaffleLapkin
2023-05-29Rename `tcx.mk_re_*` => `Region::new_*`Maybe Waffle-1/+1
2023-05-23Allow consumers to retrieve borrowck outputJonáš Fiala-4/+9
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-2/+2
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-2/+2
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-22Auto merge of #109753 - compiler-errors:replenish-region-constraints, r=aliemjaybors-1/+1
Clone region var origins instead of taking them in borrowck Fixes an issue with the new solver where reporting a borrow-checker error ICEs because it calls `InferCtxt::evaluate_obligation`. This also removes a handful of unnecessary `tcx.infer_ctxt().build()` calls that are only there to mitigate this same exact issue, but with the old solver. Fixes compiler-errors/next-solver-hir-issues#12. ---- This implements `@aliemjay's` solution where we just don't *take* the region constraints, but clone them. This potentially makes it easier to write a bug about taking region constraints twice or never at all, but again, not many folks are touching this code.
2023-04-21Clone region var origins instead of taking in borrowckMichael Goulet-1/+1
2023-04-20Remove WithOptconstParam.Camille GILLOT-1/+1
2023-04-16Various minor Idx-related tweaksScott McMurray-4/+4
Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.
2023-04-13Remove `ToRegionVid`.Nicholas Nethercote-16/+1
It is only implemented for `Region`, where it is equivalent to the inherent `as_var` method.
2023-04-13Remove `impl ToRegionVid for RegionVid`.Nicholas Nethercote-6/+0
It's weird and unnecessary.
2023-04-02Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray-3/+3
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-03-17Remove VecMapMichael Goulet-3/+3
2023-03-04tweak debug output and bless testsAli MJ Al-Nasrawy-14/+18
2023-02-19some conditional importsb-naber-5/+0
2023-02-19sccs infob-naber-0/+1
2023-02-19collect region contexts during mir renumberingb-naber-6/+10
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-0/+2
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-1/+1
2022-12-01Create `format_args` as late as possibleOli Scherer-6/+4
2022-11-18require an `ErrorGuaranteed` to taint infcx with errorsBoxy-1/+4
2022-11-09lint auto passAndyJado-0/+2
Revert "lint auto pass" This reverts commit e58e4466384924c491a932d3f18ef50ffa5a5065.
2022-11-05simplify applying closure requirementsAli MJ Al-Nasrawy-2/+0
Don't use `ConstraintCategory::ClosureBounds`! Set the category and the span for the promoted constraints to that of the original constraint earlier than before. This eliminates the need for `closure_bounds_mapping`.
2022-10-07Remove TypeckResults from InferCtxtCameron Steffen-7/+7
2022-09-13Use def_span for external requirements.Camille GILLOT-2/+3
2022-07-19Use LocalDefId in OpaqueTypeKeyMichael Goulet-3/+3
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-2/+2
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-06-15implement (unused) matching solverNiko Matsakis-1/+1