summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2023-05-31unique borrows are mutating useslcnr-4/+4
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-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*.
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