about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2024-07-04Align the changes to the lang decisionMaybe Lapkin-0/+8
2024-07-03Rollup merge of #127294 - ldm0:ldm_coroutine2, r=lcnrMatthias Krüger-1/+5
Less magic number for corountine
2024-07-04Less magic number for corountineLiu Dingming-1/+5
2024-07-03cache type sizes in type-size limit visitorRémy Rakic-3/+16
2024-07-03Add `constness` to `TraitDef`Deadbeef-1/+9
2024-07-03Rollup merge of #127145 - compiler-errors:as_lang_item, r=lcnrMatthias Krüger-45/+68
Add `as_lang_item` to `LanguageItems`, new trait solver Add `as_lang_item` which turns `DefId` into a `TraitSolverLangItem` in the new trait solver, so we can turn the large chain of if statements in `assemble_builtin_impl_candidates` into a match instead. r? lcnr
2024-07-03Auto merge of #125507 - compiler-errors:type-length-limit, r=lcnrbors-80/+213
Re-implement a type-size based limit r? lcnr This PR reintroduces the type length limit added in #37789, which was accidentally made practically useless by the caching changes to `Ty::walk` in #72412, which caused the `walk` function to no longer walk over identical elements. Hitting this length limit is not fatal unless we are in codegen -- so it shouldn't affect passes like the mir inliner which creates potentially very large types (which we observed, for example, when the new trait solver compiles `itertools` in `--release` mode). This also increases the type length limit from `1048576 == 2 ** 20` to `2 ** 24`, which covers all of the code that can be reached with craterbot-check. Individual crates can increase the length limit further if desired. Perf regression is mild and I think we should accept it -- reinstating this limit is important for the new trait solver and to make sure we don't accidentally hit more type-size related regressions in the future. Fixes #125460
2024-07-03Auto merge of #123720 - amandasystems:dyn-enable-refactor, r=nikomatsakisbors-0/+3
Rewrite handling of universe-leaking placeholder regions into outlives constraints This commit prepares for Polonius by moving handling of leak check/universe errors out of the inference step by rewriting any universe error into an outlives-static constraint. This variant is a work in progress but seems to pass most tests. Note that a few debug assertions no longer hold; a few extra eyes on those changes are appreciated!
2024-07-02Instance::resolve -> Instance::try_resolve, and other nitsMichael Goulet-8/+20
2024-07-02Make fn traits into first-class TraitSolverLangItems to avoid needing ↵Michael Goulet-9/+7
fn_trait_kind_from_def_id
2024-07-02add TyCtxt::as_lang_item, use in new solverMichael Goulet-37/+62
2024-07-02Fix spansMichael Goulet-7/+14
2024-07-02Re-implement a type-size based limitMichael Goulet-11/+119
2024-07-02Give Instance::expect_resolve a spanMichael Goulet-5/+7
2024-07-02Miscellaneous renamingMichael Goulet-60/+64
2024-07-02Miri function identity hack: account for possible inliningRalf Jung-26/+53
2024-07-02Rollup merge of #127230 - hattizai:patch01, r=saethlinMatthias Krüger-1/+1
chore: remove duplicate words remove duplicate words in comments to improve readability.
2024-07-02Rollup merge of #127224 - tgross35:pretty-print-exhaustive, r=RalfJungMatthias Krüger-16/+18
Make `FloatTy` checks exhaustive in pretty print This should prevent the default fallback if we add more float types in the future.
2024-07-02Rollup merge of #127146 - compiler-errors:fast-reject, r=lcnrMatthias Krüger-388/+4
Uplift fast rejection to new solver Self explanatory. r? lcnr
2024-07-02chore: remove duplicate wordshattizai-1/+1
2024-07-01Make `FloatTy` checks exhaustive in pretty printTrevor Gross-16/+18
This should prevent the default fallback if we add more float types in the future.
2024-07-01Handle universe leaks by rewriting the constraint graphAmanda Stjerna-0/+3
This version is a squash-rebased version of a series of exiermental commits, since large parts of them were broken out into PR #125069. It explicitly handles universe violations in higher-kinded outlives constraints by adding extra outlives static constraints.
2024-06-30Uplift fast rejection to new solverMichael Goulet-388/+4
2024-06-29Auto merge of #120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obkbors-4/+30
Implement new effects desugaring cc `@rust-lang/project-const-traits.` Will write down notes once I have finished. * [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>` * [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>` * [ ] add types and traits to minicore test * [ ] update rustc-dev-guide Fixes #119717 Fixes #123664 Fixes #124857 Fixes #126148
2024-06-29Rollup merge of #127045 - compiler-errors:explicit, r=oli-obkMatthias Krüger-56/+30
Rename `super_predicates_of` and similar queries to `explicit_*` to note that they're not elaborated Rename: * `super_predicates_of` -> `explicit_super_predicates_of` * `implied_predicates_of` -> `explicit_implied_predicates_of` * `supertraits_containing_assoc_item` -> `explicit_supertraits_containing_assoc_item` This makes it clearer that, unlike (for example) [`TyCtxt::super_traits_of`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.super_traits_of), we don't automatically elaborate this set of predicates. r? ``@lcnr`` or ``@oli-obk`` or someone from t-types idc
2024-06-28address review commentsDeadbeef-2/+2
2024-06-28Implement `Min` trait in new solverDeadbeef-0/+5
2024-06-28implement new effects desugaringDeadbeef-4/+25
2024-06-28Rollup merge of #124741 - nebulark:patchable-function-entries-pr, ↵Matthias Krüger-0/+27
r=estebank,workingjubilee patchable-function-entry: Add unstable compiler flag and attribute Tracking issue: #123115 Add the -Z patchable-function-entry compiler flag and the #[patchable_function_entry(prefix_nops = m, entry_nops = n)] attribute. Rebased and adjusted the canditate implementation to match changes in the RFC.
2024-06-27supertrait_def_ids was already implemented in middleMichael Goulet-37/+3
2024-06-27supertrait_def_idsMichael Goulet-3/+2
2024-06-27Make queries more explicitMichael Goulet-18/+27
2024-06-27Rollup merge of #126721 - Zalathar:nested-cov-attr, r=oli-obkJacob Pratt-4/+10
coverage: Make `#[coverage(..)]` apply recursively to nested functions This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to. Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value. --- Fixes #126625.
2024-06-26Add `-Zdump-mir-exclude-alloc-bytes`Josh Stone-0/+3
2024-06-26Auto merge of #126844 - scottmcm:more-ptr-cast-gvn, r=saethlinbors-13/+29
Remove more `PtrToPtr` casts in GVN This addresses two things I noticed in MIR: 1. `NonNull::<T>::eq` does `(a as *mut T) == (b as *mut T)`, but it could just compare the `*const T`s, so this removes `PtrToPtr` casts that are on both sides of a pointer comparison, so long as they're not fat-to-thin casts. 2. `NonNull::<T>::addr` does `transmute::<_, usize>(p as *const ())`, but so long as `T: Thin` that cast doesn't do anything, and thus we can directly transmute the `*const T` instead. r? mir-opt
2024-06-26coverage: Apply `#[coverage(..)]` recursively to nested functionsZalathar-1/+2
2024-06-26coverage: Detach `#[coverage(..)]` from codegen attribute handlingZalathar-4/+9
2024-06-25Support `#[patchable_function_entries]`Matthew Maurer-0/+4
See [RFC](https://github.com/maurer/rust-rfcs/blob/patchable-function-entry/text/0000-patchable-function-entry.md) (yet to be numbered) TODO before submission: * Needs an RFC * Improve error reporting for malformed attributes
2024-06-25Support for -Z patchable-function-entryMatthew Maurer-0/+23
`-Z patchable-function-entry` works like `-fpatchable-function-entry` on clang/gcc. The arguments are total nop count and function offset. See MCP rust-lang/compiler-team#704
2024-06-25Auto merge of #125740 - RalfJung:transmute-size-check, r=oli-obkbors-8/+17
transmute size check: properly account for alignment Fixes another place where ZST alignment was ignored when checking whether something is a newtype. I wonder how many more of these there are... Fixes https://github.com/rust-lang/rust/issues/101084
2024-06-25Auto merge of #126813 - compiler-errors:SliceLike, r=lcnrbors-9/+28
Add `SliceLike` to `rustc_type_ir`, use it in the generic solver code (+ some other changes) First, we split out `TraitRef::new_from_args` which takes *just* `ty::GenericArgsRef` from `TraitRef::new` which takes `impl IntoIterator<Item: Into<GenericArg>>`. I will explain in a minute why. Second, we introduce `SliceLike`, which allows us to be generic over `List<T>` and `[T]`. This trait has an `as_slice()` and `into_iter()` method, and some other convenience functions. However, importantly, since types like `I::GenericArgs` now implement `SliceLike` rather than `IntoIter<Item = I::GenericArg>`, we can't use `TraitRef::new` on this directly. That's where `new_from_args` comes in. Finally, we adjust all the code to use these slice operators. Some things get simpler, some things get a bit more annoying since we need to use `as_slice()` in a few places. 🤷 r? lcnr
2024-06-24Auto merge of #126784 - scottmcm:smaller-terminator, r=compiler-errorsbors-6/+6
Save 2 pointers in `TerminatorKind` (96 → 80 bytes) These things don't need to be `Vec`s; boxed slices are enough. The frequent one here is call arguments, but MIR building knows the number of arguments from the THIR, so the collect is always getting the allocation right in the first place, and thus this shouldn't ever add the shrink-in-place overhead.
2024-06-24Replace Deref bounds on Interner in favor of a SliceLike traitMichael Goulet-0/+14
2024-06-24Split out IntoIterator and non-Iterator constructors for ↵Michael Goulet-9/+14
AliasTy/AliasTerm/TraitRef/projection
2024-06-23Rollup merge of #126833 - RalfJung:extern-type-field-ice, r=compiler-errorsMatthias Krüger-0/+2
don't ICE when encountering an extern type field during validation "extern type" is a pain that keeps on giving... Fixes https://github.com/rust-lang/rust/issues/126814 r? ```@oli-obk```
2024-06-23Replace `f16` and `f128` pattern matching stubs with real implementationsTrevor Gross-1/+15
This section of code depends on `rustc_apfloat` rather than our internal types, so this is one potential ICE that we should be able to melt now. This also fixes some missing range and match handling in `rustc_middle`.
2024-06-22Add a `pointee_metadata_ty_or_projection` helperScott McMurray-13/+29
2024-06-22don't ICE when encountering an extern type field during validationRalf Jung-0/+2
2024-06-21Rollup merge of #126787 - Strophox:get-bytes, r=RalfJungJubilee-3/+23
Add direct accessors for memory addresses in `Machine` (for Miri) The purpose of this PR is to enable direct (immutable) access to memory addresses in `Machine`, which will be needed for further extension of Miri. This is done by adding (/completing missings pairs of) accessor functions, with the relevant signatures as follows: ```rust /* rust/compiler/rustc_middle/src/mir/interpret/allocation.rs */ pub trait AllocBytes { // .. fn as_ptr(&self) -> *const u8; /*fn as_mut_ptr(&mut self) -> *mut u8; -- Already in the compiler*/ } impl<Prov: Provenance, Extra, Bytes: AllocBytes> Allocation<Prov, Extra, Bytes> { // .. pub fn get_bytes_unchecked_raw(&self) -> *const u8; /*pub fn get_bytes_unchecked_raw_mut(&mut self) -> *mut u8; -- Already in the compiler*/ } ``` ```rust /* rust/compiler/rustc_const_eval/src/interpret/memory.rs */ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // .. pub fn get_alloc_bytes_unchecked_raw(&self, id: AllocId) -> InterpResult<'tcx, *const u8>; pub fn get_alloc_bytes_unchecked_raw_mut(&mut self, id: AllocId) -> InterpResult<'tcx, *mut u8>; } ``` r? ``@RalfJung``
2024-06-21Save 2 pointers in `TerminatorKind` (96 → 80 bytes)Scott McMurray-6/+6
These things don't need to be `Vec`s; boxed slices are enough. The frequent one here is call arguments, but MIR building knows the number of arguments from the THIR, so the collect is always getting the allocation right in the first place, and thus this shouldn't ever add the shrink-in-place overhead.