about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2023-04-03Auto merge of #109819 - scottmcm:index-slice, r=WaffleLapkinbors-18/+25
Use `&IndexSlice` instead of `&IndexVec` where possible All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*. r? `@ghost`
2023-04-03fix(middle): emit error rather than delay bug when reaching limitbohan-5/+17
2023-04-02Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray-18/+25
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-04-02Auto merge of #109849 - scottmcm:more-fieldidx-rebase, r=oli-obkbors-3/+4
Use `FieldIdx` in various things related to aggregates Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`. Part 3/? of https://github.com/rust-lang/compiler-team/issues/606 [`IndexSlice`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_index/vec/struct.IndexVec.html#deref-methods-IndexSlice%3CI,+T%3E) was added in https://github.com/rust-lang/rust/pull/109787
2023-04-01Use `FieldIdx` in various things related to aggregatesScott McMurray-3/+4
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-04-01use and_then/flat_map for map().flatten()Matthias Krüger-1/+1
2023-04-01fix clippy::iter_kv_mapMatthias Krüger-1/+1
2023-03-31Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obkbors-2/+23
Insert alignment checks for pointer dereferences when debug assertions are enabled Closes https://github.com/rust-lang/rust/issues/54915 - [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit) - [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue! - [x] Implement a more helpful panic message like slice bounds checking. r? `@oli-obk`
2023-03-31Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkinbors-29/+30
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-31Auto merge of #109750 - compiler-errors:deep-reject-less-permissive-num-var, ↵bors-0/+4
r=lcnr numeric vars can only be unified with numerical types in deep reject Don't consider numeric vars (int and float vars) to unify with non-numeric types during deep reject. This helps us reject incompatible impls sooner.
2023-03-30Auto merge of #109791 - compiler-errors:rollup-c3o710k, r=compiler-errorsbors-1/+5
Rollup of 6 pull requests Successful merges: - #109347 (Skip no_mangle if the item has no name.) - #109522 (Implement current_dll_path for AIX) - #109679 (Freshen normalizes-to hack goal RHS in the evaluate loop) - #109704 (resolve: Minor improvements to effective visibilities) - #109739 (Closures always implement `FnOnce` in new solver) - #109758 (Parallel compiler cleanups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-30Rollup merge of #109704 - petrochenkov:effvisclean, r=jackh726Michael Goulet-1/+5
resolve: Minor improvements to effective visibilities See individual commits.
2023-03-30Auto merge of #109740 - ↵bors-1/+5
compiler-errors:new-solver-deep-reject-placeholder-consts, r=lcnr Don't ICE on placeholder consts in deep reject Since we canonicalize const params into placeholder consts, we need to be able to handle them during deep reject. r? `@lcnr` (though maybe `@oli-obk` can look at this one too, if he wants 😸) Fixes compiler-errors/next-solver-hir-issues#10
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-29/+30
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/+0
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-30deep reject only unify numeric var with concrete numericMichael Goulet-0/+4
2023-03-29Don't ICE on placeholder consts in deep rejectMichael Goulet-1/+5
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-1/+0
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29Rollup merge of #109716 - scottmcm:field-to-fieldidx, r=oli-obkMatthias Krüger-50/+46
Move `mir::Field` → `abi::FieldIdx` 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 already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-29Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3bors-12/+47
Support TLS access into dylibs on Windows This allows access to `#[thread_local]` in upstream dylibs on Windows by introducing a MIR shim to return the address of the thread local. Accesses that go into an upstream dylib will call the MIR shim to get the address of it. `convert_tls_rvalues` is introduced in `rustc_codegen_ssa` which rewrites MIR TLS accesses to dummy calls which are replaced with calls to the MIR shims when the dummy calls are lowered to backend calls. A new `dll_tls_export` target option enables this behavior with a `false` value which is set for Windows platforms. This fixes https://github.com/rust-lang/rust/issues/84933.
2023-03-29Auto merge of #109670 - lqd:init-mask, r=oli-obkbors-101/+445
Make init mask lazy for fully initialized/uninitialized const allocations There are a few optimization opportunities in the `InitMask` and related const `Allocation`s (e.g. by taking advantage of the fact that it's a bitset that represents initialization, which is often entirely initialized or uninitialized in a single call, or gradually built up, etc). There's a few overwrites to the same state, multiple writes in a row to the same indices, the RLE scheme for `memcpy` doesn't always compress, etc. Here, we start with: - avoiding materializing the bitset's blocks if the allocation is fully initialized/uninitialized - dealloc blocks when fully overwriting, including when participating in `memcpy`s - take care of the fixme about allocating blocks of 0s before overwriting them to the expected value - expanding unit test coverage of the init mask This should be most visible on benchmarks and crates where const allocations dominate the runtime (like `ctfe-stress-5` of course), but I was especially looking at the worst cases from #93215. This first change allows the majority of `set_range` calls to stay with a lazy init mask when bootstrapping rustc (not that the init mask is a big part of the process in cpu time or memory usage). r? `@oli-obk` I have another in-progress branch where I'll switch the singular initialized/uninitialized value to a watermark, recording the point after which everything is uninitialized. That will take care of cases where full initialization is monotonic and done in multiple steps (e.g. an array of a type without padding), which should then allow the vast majority of const allocations' init masks to stay lazy during bootstrapping (though interestingly I've seen such gradual initialization in both left-to-right and right-to-left directions, and I don't think a single watermark can handle both).
2023-03-29Support TLS access into dylibs on WindowsJohn Kåre Alsaker-12/+47
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-50/+46
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-29Inline and remove `generic_args_may_unify`.Nicholas Nethercote-19/+12
It has a single callsite.
2023-03-29Introduce `DeepRejectCtxt::substs_refs_may_unify`.Nicholas Nethercote-4/+11
It factors out a repeated code pattern.
2023-03-28effvis: Stop considering crate root its own parentVadim Petrochenkov-1/+5
It helped to reuse `update_def` for the crate root, but it created confusion and caused some mistakes when I implemented #109500
2023-03-28Auto merge of #109692 - Nilstrieb:rollup-hq65rps, r=Nilstriebbors-45/+14
Rollup of 8 pull requests Successful merges: - #91793 (socket ancillary data implementation for FreeBSD (from 13 and above).) - #92284 (Change advance(_back)_by to return the remainder instead of the number of processed elements) - #102472 (stop special-casing `'static` in evaluation) - #108480 (Use Rayon's TLV directly) - #109321 (Erase impl regions when checking for impossible to eagerly monomorphize items) - #109470 (Correctly substitute GAT's type used in `normalize_param_env` in `check_type_bounds`) - #109562 (Update ar_archive_writer to 0.1.3) - #109629 (remove obsolete `givens` from regionck) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-28address review commentsRémy Rakic-6/+8
Move tests and limit the init mask's structures/fields visibility.
2023-03-28Rollup merge of #108480 - Zoxc:rayon-tlv, r=cuvipernils-45/+14
Use Rayon's TLV directly This accesses Rayon's `TLV` thread local directly avoiding wrapper functions. This makes rustc work with https://github.com/rust-lang/rustc-rayon/pull/10. r? `@cuviper`
2023-03-27readability tweaksRémy Rakic-22/+22
2023-03-27add more InitMask test coverageRémy Rakic-0/+175
2023-03-27make InitMask lazy for fully init/uninit casesRémy Rakic-58/+225
Avoid materializing bits in the InitMask bitset when a single value would be enough: when the mask represents a fully initialized or fully uninitialized const allocation.
2023-03-27Some tracing/instrument cleanupsOli Scherer-21/+2
2023-03-27Add a builtin `FnPtr` traitlcnr-13/+27
2023-03-26Rollup merge of #109621 - scottmcm:update-variantidx, r=compiler-errorsMatthias Krüger-8/+7
Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT` 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](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/abi/struct.VariantIdx.html).
2023-03-25Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray-8/+7
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-26transmute testMichael Goulet-2/+2
2023-03-25Update indexmap and rayon cratesJohn Kåre Alsaker-1/+1
2023-03-25Use Rayon's TLV directlyJohn Kåre Alsaker-45/+14
2023-03-24Auto merge of #109547 - matthiaskrgr:rollup-zczqgdk, r=matthiaskrgrbors-0/+15
Rollup of 9 pull requests Successful merges: - #108629 (rustdoc: add support for type filters in arguments and generics) - #108924 (panic_immediate_abort requires abort as a panic strategy) - #108961 (Refine error spans for const args in hir typeck) - #108986 (sync LVI tests) - #109142 (Add block-based mutex unlocking example) - #109368 (fix typo in the creation of OpenOption for RustyHermit) - #109493 (Return nested obligations from canonical response var unification) - #109515 (Add AixLinker to support linking on AIX) - #109536 (resolve: Rename some cstore methods to match queries and add comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-24Rollup merge of #108961 - compiler-errors:refine-ct-errors, r=BoxyUwUMatthias Krüger-0/+15
Refine error spans for const args in hir typeck Improve just a couple of error messages having to do with mismatched consts. r? `@ghost` i'll put this up when the dependent commits are merged
2023-03-23Auto merge of #109202 - compiler-errors:new-solver-fast-reject-faster-2, r=lcnrbors-30/+33
Don't pass `TreatProjections` separately to `fast_reject` Don't pass `TreatProjections` separately to `fast_reject`, and instead use the original approach of switching on two variants of `TreatParams` (undoes this: https://github.com/rust-lang/rust/pull/108830#pullrequestreview-1330371417). Fixes the regression introduced in https://github.com/rust-lang/rust/pull/108830#issuecomment-1468116419
2023-03-23A MIR transform that checks pointers are alignedBen Kimock-2/+23
2023-03-23Don't split up TreatProjections and TreatParams anymoreMichael Goulet-30/+33
2023-03-23Refine error spans for const args in hir typeckMichael Goulet-0/+15
2023-03-23Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obkbors-1/+9
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 #108221 - petrochenkov:cratecfg, r=michaelwoeristerbors-2/+2
rustc_interface: Add a new query `pre_configure` It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early. Crate-level cfg attributes on the crate itself are then expanded normally during the main expansion pass, like attributes on any other nodes. This is a continuation of https://github.com/rust-lang/rust/pull/92473 and one more step to very unstable crate-level proc macro attributes maybe actually working. Previously crate attributes were pre-configured simultaneously with feature extraction, and then written directly into `ast::Crate`.
2023-03-23Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgrbors-11/+34
Rollup of 7 pull requests Successful merges: - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs) - #109137 (resolve: Querify most cstore access methods (subset 2)) - #109380 (add `known-bug` test for unsoundness issue) - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate)) - #109475 (Simpler checked shifts in MIR building) - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.) - #109506 (make param bound vars visibly bound vars with -Zverbose) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-23rustc_interface: Add a new query `pre_configure`Vadim Petrochenkov-2/+2
It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early. Crate-level cfg attributes are then expanded normally during the main expansion pass, like attributes on any other nodes.
2023-03-23Rollup merge of #109506 - BoxyUwU:debugable_bound_var_printing, ↵Matthias Krüger-1/+5
r=compiler-errors make param bound vars visibly bound vars with -Zverbose I was trying to debug some type/const bound var stuff and it was shockingly tricky due to the fact that even with `-Zverbose` enabled the `T` in `for<T> T: Trait` prints as `T` making it seem like its `TyKind::Param` when it is infact `TyKind::Bound`. This PR "fixes" this when `-Zverbose` is set to allow rendering it as `^T` or `^1_T` depending on binder depth. r? ```@compiler-errors```