about summary refs log tree commit diff
path: root/compiler/rustc_borrowck
AgeCommit message (Collapse)AuthorLines
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*.
2023-04-01Use `FieldIdx` in various things related to aggregatesScott McMurray-13/+13
Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
2023-03-31Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkinbors-3/+4
Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>` And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-3/+4
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-sebors-1/+1
Partial stabilization of `once_cell` This PR aims to stabilize a portion of the `once_cell` feature: - `core::cell::OnceCell` - `std::cell::OnceCell` (re-export of the above) - `std::sync::OnceLock` This will leave `LazyCell` and `LazyLock` unstabilized, which have been moved to the `lazy_cell` feature flag. Tracking issue: https://github.com/rust-lang/rust/issues/74465 (does not fully close, but it may make sense to move to a new issue) Future steps for separate PRs: - ~~Add `#[inline]` to many methods~~ #105651 - Update cranelift usage of the `once_cell` crate - Update rust-analyzer usage of the `once_cell` crate - Update error messages discussing once_cell ## To be stabilized API summary ```rust // core::cell (in core/cell/once.rs) pub struct OnceCell<T> { .. } impl<T> OnceCell<T> { pub const fn new() -> OnceCell<T>; pub fn get(&self) -> Option<&T>; pub fn get_mut(&mut self) -> Option<&mut T>; pub fn set(&self, value: T) -> Result<(), T>; pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T; pub fn into_inner(self) -> Option<T>; pub fn take(&mut self) -> Option<T>; } impl<T: Clone> Clone for OnceCell<T>; impl<T: Debug> Debug for OnceCell<T> impl<T> Default for OnceCell<T>; impl<T> From<T> for OnceCell<T>; impl<T: PartialEq> PartialEq for OnceCell<T>; impl<T: Eq> Eq for OnceCell<T>; ``` ```rust // std::sync (in std/sync/once_lock.rs) impl<T> OnceLock<T> { pub const fn new() -> OnceLock<T>; pub fn get(&self) -> Option<&T>; pub fn get_mut(&mut self) -> Option<&mut T>; pub fn set(&self, value: T) -> Result<(), T>; pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T; pub fn into_inner(self) -> Option<T>; pub fn take(&mut self) -> Option<T>; } impl<T: Clone> Clone for OnceLock<T>; impl<T: Debug> Debug for OnceLock<T>; impl<T> Default for OnceLock<T>; impl<#[may_dangle] T> Drop for OnceLock<T>; impl<T> From<T> for OnceLock<T>; impl<T: PartialEq> PartialEq for OnceLock<T> impl<T: Eq> Eq for OnceLock<T>; impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T>; unsafe impl<T: Send> Send for OnceLock<T>; unsafe impl<T: Sync + Send> Sync for OnceLock<T>; impl<T: UnwindSafe> UnwindSafe for OnceLock<T>; ``` No longer planned as part of this PR, and moved to the `rust_cell_try` feature gate: ```rust impl<T> OnceCell<T> { pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>; } impl<T> OnceLock<T> { pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>; } ``` I am new to this process so would appreciate mentorship wherever needed.
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-1/+1
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-13/+16
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-25Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray-3/+3
Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
2023-03-23Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obkbors-0/+7
Add `CastKind::Transmute` to MIR ~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~ Includes lowering `transmute` calls to it, so it's used. Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2023-03-23Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgrbors-9/+4
Rollup of 9 pull requests Successful merges: - #108954 (rustdoc: handle generics better when matching notable traits) - #109203 (refactor/feat: refactor identifier parsing a bit) - #109213 (Eagerly intern and check CrateNum/StableCrateId collisions) - #109358 (rustc: Remove unused `Session` argument from some attribute functions) - #109359 (Update stdarch) - #109378 (Remove Ty::is_region_ptr) - #109423 (Use region-erased self type during IAT selection) - #109447 (new solver cleanup + implement coherence) - #109501 (make link clickable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-23Auto merge of #108861 - b-naber:eager-nll-type-relating, r=lcnrbors-29/+18
Make NLL Type Relating Eager We previously instantiated bound regions in nll type relating lazily. Making this eager is more consistent with how we handle type relating in [`higher_ranked_sub`](https://github.com/rust-lang/rust/blob/0a3b557d528dd7c8a88ceca6f7dc0699b89a3ef4/compiler/rustc_infer/src/infer/higher_ranked/mod.rs#L28) and should allow us to short circuit in case there's structural equality.
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-0/+7
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-22Rollup merge of #109378 - MU001999:master, r=scottmcmMatthias Krüger-9/+4
Remove Ty::is_region_ptr Fixes #109372
2023-03-23Rollup merge of #109280 - compiler-errors:no-vec-map, r=Mark-SimulacrumDylan DPC-11/+8
Remove `VecMap` Not sure what the use of this data structure is over just using `FxIndexMap` or a `Vec`. r? ```@ghost```
2023-03-22print sccs_info strings correctlyb-naber-5/+6
2023-03-22assertion for only collection nll region variable information for debug in ↵b-naber-24/+12
non-canonicalization contexts
2023-03-22Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errorsbors-15/+7
a general type system cleanup removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context. changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR. also removes some other small - and imo unnecessary - helpers. r? types
2023-03-21IdentitySubsts::identity_for_item takes Into<DefId>Michael Goulet-1/+1
2023-03-21remove some trait solver helperslcnr-15/+7
they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.
2023-03-20Remove Ty::is_region_ptrMu42-9/+4
2023-03-17Remove VecMapMichael Goulet-11/+8
2023-03-17Rollup merge of #109215 - est31:sort_by_key, r=NilstriebMatthias Krüger-2/+2
Use sort_by_key instead of sort_by I went over the cases where sort_by is used and in these two, one can use sort_by_key instead.
2023-03-16Auto merge of #108944 - cjgillot:clear-local-info, r=oli-obkbors-90/+69
Wrap the whole LocalInfo in ClearCrossCrate. MIR contains a lot of information about locals. The primary purpose of this information is the quality of borrowck diagnostics. This PR aims to drop this information after MIR analyses are finished, ie. starting from post-cleanup runtime MIR.
2023-03-16Use sort_by_key instead of sort_byest31-2/+2
I went over the cases where sort_by is used and in these two, one can use sort_by_key instead.
2023-03-15unequal → not equalgimbles-1/+1
2023-03-14Remove LocalKind::Var.Camille GILLOT-8/+10
2023-03-14Make is_block_tail a variant of LocalInfo.Camille GILLOT-3/+3
2023-03-14Wrap the whole LocalInfo in ClearCrossCrate.Camille GILLOT-79/+56
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-10Auto merge of #108977 - matthiaskrgr:rollup-1bnl1hu, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #108879 (Unconstrained terms should account for infer vars being equated) - #108936 (Rustdoc: don't hide anonymous reexport) - #108940 (Add myself to compiler reviewers list) - #108945 (Make some report and emit errors take DefIds instead of BodyIds) - #108946 (Document the resulting values produced when using `From<bool>` on floats) - #108956 (Make ptr::from_ref and ptr::from_mut in #106116 const.) - #108960 (Remove `body_def_id` from `Inherited`) - #108963 (only call git on git checkouts during bootstrap) - #108964 (Fix the docs for pointer method with_metadata_of) Failed merges: - #108950 (Directly construct Inherited in typeck.) r? `@ghost` `@rustbot` modify labels: rollup
2023-03-09Remove body_def_id from InheritedMichael Goulet-1/+1
2023-03-09Document borrowck behaviour.Camille GILLOT-1/+3
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-2/+10
2023-03-08Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiaskoMatthias Krüger-43/+1
Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-43/+1
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-07Auto merge of #108735 - clubby789:borrowck-unstable, r=Nilstriebbors-61/+66
Remove `allow(potential_query_instability)` from `borrowck` cc #84447 Replace uses of `FxHash*` with `FxIndex*`. One `#[allow]` for a HashMap in an external crate but the output is sorted afterwards.
2023-03-07Auto merge of #108691 - aliemjay:closure-subject, r=jackh726bors-126/+72
fix multiple issues when promoting type-test subject Multiple interdependent fixes. See linked issues for a short description of each. When Promoting a type-test `T: 'a` from within the closure back to its parent function, there are a couple pre-existing bugs and limitations. They were exposed by the recent changes to opaque types because the type-test subject (`T`) is no longer a simple ParamTy. Commit 1: Fixes #108635 Fixes #107426 Commit 2: Fixes #108639 Commit 3: Fixes #107516
2023-03-05Remove `allow(potential_query_instability)` from `borrowck`clubby789-61/+66
2023-03-05Auto merge of #108351 - petrochenkov:rmdit, r=cjgillotbors-5/+3
rustc_middle: Remove trait `DefIdTree` This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-05Auto merge of #107844 - Zeegomo:no-drop-and-rep, r=cjgillotbors-8/+48
Desugaring of drop and replace at MIR build This commit desugars the drop and replace deriving from an assignment at MIR build, avoiding the construction of the `DropAndReplace` terminator (which will be removed in a following PR). In order to retain the same error messages for replaces a new `DesugaringKind::Replace` variant is introduced. The changes in the borrowck are also useful for future work in moving drop elaboration before borrowck, as no `DropAndReplace` would be present there anymore. Notes on test diffs: * `tests/ui/borrowck/issue-58776-borrowck-scans-children`: the assignment deriving from the desugaring kills the borrow. * `tests/ui/async-await/async-fn-size-uninit-locals.rs`, `tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir`, `tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir`: drop elaboration generates (or reads from) a useless drop flag due to an issue with the dataflow analysis. Will be fixed independently by https://github.com/rust-lang/rust/pull/106430. See https://github.com/rust-lang/rust/pull/104488 for more context
2023-03-04tweak debug output and bless testsAli MJ Al-Nasrawy-14/+18
2023-03-04tweak ClosureOutlivesSubjectTyAli MJ Al-Nasrawy-1/+1
2023-03-03Rollup merge of #108694 - est31:backticks_matchmaking_comments, r=NilstriebMatthias Krüger-3/+3
Match unmatched backticks in compiler/ comments r? ``@Nilstrieb`` as per [advice](https://github.com/rust-lang/rust/pull/108685#issuecomment-1453018499)
2023-03-03use helper function for error reportingGiacomo Pasini-17/+29
2023-03-03Desugars drop and replace at MIR buildGiacomo Pasini-10/+38
This commit desugars the drop and replace deriving from an assignment at MIR build, avoiding the construction of the DropAndReplace terminator (which will be removed in a followign PR) In order to retain the same error messages for replaces a new DesugaringKind::Replace variant is introduced.
2023-03-03ignore bivariant regions in opaque typesAli MJ Al-Nasrawy-0/+30
2023-03-03smarter algorithm for finding an equal regionAli MJ Al-Nasrawy-92/+9
Smarter and simpler!
2023-03-03promote subject even if it has unnamed regionsAli MJ Al-Nasrawy-22/+17
Don't require a region to have an `external_name` in order to be promoted.
2023-03-03Match end user facing unmatched backticks in compiler/est31-1/+1
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-3/+3