about summary refs log tree commit diff
path: root/compiler/rustc_borrowck
AgeCommit message (Collapse)AuthorLines
2023-04-25Fix lifetime suggestion for type aliases with objects in themMichael Goulet-3/+13
2023-04-25Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, ↵Matthias Krüger-1/+1
r=compiler-errors Switch to `EarlyBinder` for `explicit_item_bounds` Part of the work to finish https://github.com/rust-lang/rust/issues/105779. This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`. r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 :smiley:)
2023-04-25Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle-10/+17
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-17/+17
2023-04-23Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillotbors-1/+1
Run various queries from other queries instead of explicitly in phases These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps. This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-22Auto merge of #109753 - compiler-errors:replenish-region-constraints, r=aliemjaybors-31/+18
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-22Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJungbors-5/+7
Evaluate place expression in `PlaceMention` https://github.com/rust-lang/rust/pull/102256 introduces a `PlaceMention(place)` MIR statement which keep trace of `let _ = place` statements from surface rust, but without semantics. This PR proposes to change the behaviour of `let _ =` patterns with respect to the borrow-checker to verify that the bound place is live. Specifically, consider this code: ```rust let _ = { let a = 5; &a }; ``` This passes borrowck without error on stable. Meanwhile, replacing `_` by `_: _` or `_p` errors with "error[E0597]: `a` does not live long enough", [see playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c448d25a7c205dc95a0967fe96bccce8). This PR *does not* change how `_` patterns behave with respect to initializedness: it remains ok to bind a moved-from place to `_`. The relevant test is `tests/ui/borrowck/let_underscore_temporary.rs`. Crater check found no regression. For consistency, this PR changes miri to evaluate the place found in `PlaceMention`, and report eventual dangling pointers found within it. r? `@RalfJung`
2023-04-22Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors-1/+2
Add offset_of! macro (RFC 3308) Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented: * Nested field accesses (without array indexing) * DST support (for `Sized` fields) I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it. cc `@thomcc` (RFC author)
2023-04-21Allow `LocalDefId` as the argument to `def_path_str`Oli Scherer-1/+1
2023-04-21Evaluate place expression in `PlaceMention`.Camille GILLOT-5/+7
2023-04-21offset_ofDrMeepster-1/+2
2023-04-21Clone region var origins instead of taking in borrowckMichael Goulet-31/+18
2023-04-20add EarlyBinder to output of explicit_item_bounds; replace ↵Kyle Matsuda-1/+1
bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query
2023-04-20Remove WithOptconstParam.Camille GILLOT-57/+41
2023-04-19Extend and use `hir::Node::body_id`Maybe Waffle-20/+1
2023-04-19 Add suggestion to use a closure arg instead of a capture on bck errorMaybe Waffle-3/+182
2023-04-19Add `#[track_caller]` to `struct_span_err_with_code` (drive-by cleanup)Maybe Waffle-0/+1
We use caller information to track where a diagnostic was created, so all "helper" diagnostic functions should use `#[track_caller]`
2023-04-19Remove useless check (drive-by cleanup)Maybe Waffle-15/+1
While it might *seem* that this does something, it actually doesn't. `mut_borrow_of_mutable_ref` returns a `bool` that is ignored by the let-else. This was basically ```rust if !self.body.local_decls.get(local).is_some() { return } ``` Which is pretty useless
2023-04-19Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwcobors-1/+2
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros` Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-18Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb-1/+2
Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-17Spelling - compilerJosh Soref-3/+3
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17Rollup merge of #110394 - scottmcm:less-idx-new, r=WaffleLapkinMatthias Krüger-17/+15
Various minor Idx-related tweaks Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify. cc https://github.com/rust-lang/compiler-team/issues/606 r? `@WaffleLapkin`
2023-04-17Rollup merge of #104055 - AndyJado:bck_errors, r=davidtwcoMatthias Krüger-252/+612
Migrate diagnostics in `rustc_borrowck` sorry for making a new PR, [#103559](https://github.com/rust-lang/rust/pull/103559) and [#103960](https://github.com/rust-lang/rust/pull/103960). I am crawling, joyfully.
2023-04-16Move some utils out of `rustc_const_eval`Nilstrieb-7/+46
This allows us to get rid of the `rustc_const_eval->rustc_borrowck` dependency edge which was delaying the compilation of borrowck. The added utils in `rustc_middle` are small and should not affect compile times there.
2023-04-16Various minor Idx-related tweaksScott McMurray-17/+15
Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.
2023-04-15fix clippy::{clone_on_copy, useless_conversion}Matthias Krüger-1/+1
2023-04-13Remove `ToRegionVid`.Nicholas Nethercote-55/+32
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-23/+12
It's weird and unnecessary.
2023-04-13Make `Region::as_var` infallible.Nicholas Nethercote-15/+4
It's what all the call sites require.
2023-04-13migrate ftl msg accroding to #103042AndyJado-12/+138
2023-04-13rm var_span_label to var_subdiag & eager subdiagAndyJado-240/+474
2023-04-12Auto merge of #110249 - matthiaskrgr:rollup-7iig04q, r=matthiaskrgrbors-60/+35
Rollup of 8 pull requests Successful merges: - #110153 (Fix typos in compiler) - #110165 (rustdoc: use CSS `overscroll-behavior` instead of JavaScript) - #110175 (Symbol cleanups) - #110203 (Remove `..` from return type notation) - #110205 (rustdoc: make settings radio and checks thicker, less contrast) - #110222 (Improve the error message when forwarding a matched fragment to another macro) - #110237 (Split out a separate feature gate for impl trait in associated types) - #110241 (tidy: Issue an error when UI test limits are too high) Failed merges: - #110218 (Remove `ToRegionVid`) r? `@ghost` `@rustbot` modify labels: rollup
2023-04-12Rollup merge of #110175 - nnethercote:symbol-cleanups, r=jackh726Matthias Krüger-44/+17
Symbol cleanups r? ```@jackh726``` cc ```@b-naber```
2023-04-12Rename `NllVisitor` as `RegionRenumberer`.Nicholas Nethercote-6/+6
It's a more descriptive name.
2023-04-11Add `sym::anon`.Nicholas Nethercote-7/+4
2023-04-11Use the existing `static` and `env` symbols instead of interning.Nicholas Nethercote-8/+7
2023-04-11Fix `RegionCtxt::preference_value`.Nicholas Nethercote-3/+1
There's a bad pattern matching confusion present in this function. `_anon` gets assigned to, and then `_anon` is used as an unbound variable in the pattern, which is unrelated to the first `_anon`. If the `_anon` didn't start with `_` the compiler would give warnings. This was introduced in #104239. I have rewritten the function to remove the confusion and preserve the existing behaviour. This seems safest, because the original intent is not clear.
2023-04-11Introduce `Region::get_name_or_anon`.Nicholas Nethercote-27/+6
For a common pattern.
2023-04-11Rename a variable.Nicholas Nethercote-2/+2
2023-04-11Inline and remove `renumber_regions`.Nicholas Nethercote-19/+6
It has a single callsite.
2023-04-10Fix typos in compilerDaniPopes-16/+18
2023-04-07Auto merge of #110036 - jackh726:placeholder_boundvar, r=nnethercotebors-14/+14
Remove u32 on BrAnon and BoundTyKind::Anon in favor of BoundVar on Placeholder types r? `@nnethercote` Better alternative to #110025
2023-04-06Remove index from BrAnonJack Huey-4/+2
2023-04-06Use BoundTy and BoundRegion instead of kind of PlaceholderTy and ↵Jack Huey-10/+12
PlaceholderRegion
2023-04-06Rename `Abort` terminator to `Terminate`Gary Guo-5/+5
Unify terminology used in unwind action and terminator, and reflect the fact that a nounwind panic is triggered instead of an immediate abort is triggered for this terminator.
2023-04-06Add `UnwindAction::Terminate`Gary Guo-2/+6
2023-04-06Add `UnwindAction::Unreachable`Gary Guo-24/+23
This also makes eval machine's `StackPopUnwind` redundant so that is replaced.
2023-04-06Refactor unwind from Option to a new enumGary Guo-15/+18
2023-04-03Doc-comment `IndexVec::from_elem` and use it in a few more placesScott McMurray-2/+2
2023-04-02Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray-26/+28
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.