about summary refs log tree commit diff
path: root/compiler/rustc_infer/src
AgeCommit message (Collapse)AuthorLines
2024-10-07Remove unused features.Nicholas Nethercote-3/+0
2024-10-04Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnayJubilee-1/+0
Stabilize the `map`/`value` methods on `ControlFlow` And fix the stability attribute on the `pub use` in `core::ops`. libs-api in https://github.com/rust-lang/rust/issues/75744#issuecomment-2231214910 seemed reasonably happy with naming for these, so let's try for an FCP. Summary: ```rust impl<B, C> ControlFlow<B, C> { pub fn break_value(self) -> Option<B>; pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C>; pub fn continue_value(self) -> Option<C>; pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T>; } ``` Resolves #75744 ``@rustbot`` label +needs-fcp +t-libs-api -t-libs --- Aside, in case it keeps someone else from going down the same dead end: I looked at the `{break,continue}_value` methods and tried to make them `const` as part of this, but that's disallowed because of not having `const Drop`, so put it back to not even unstably-const.
2024-10-04Auto merge of #131191 - nnethercote:lattice_op, r=lcnrbors-403/+231
Merge `glb` and `lub` modules Tons of code is duplicated across them, and it's easy to factor that out. r? `@lcnr`
2024-10-04Remove `LatticeDir` trait.Nicholas Nethercote-104/+69
It's no longer necessary now that the `glb` and `lub` modules have been merged.
2024-10-04Merge `rustc_infer::infer::relate::{glb,lub}`.Nicholas Nethercote-333/+196
Most of the code in these two modules is duplicated in the other module. This commit eliminates the duplication by replacing them with a new module `lattice_op`. The new `LatticeOpKind` enum is used to distinguish between glb and lub in the few places where the behaviour differs.
2024-10-02Auto merge of #130821 - lcnr:nalgebra-hang-2, r=compiler-errorsbors-5/+59
add caching to most type folders, rm region uniquification Fixes the new minimization of the hang in nalgebra and nalgebra itself :3 this is a bit iffy, especially the cache in `TypeRelating`. I believe all the caches are correct, but it definitely adds some non-local complexity in places. The first commit removes region uniquification, reintroducing the ICE from https://github.com/rust-lang/trait-system-refactor-initiative/issues/27. This does not affect coherence and I would like to fix this by introducing OR-region constraints r? `@compiler-errors`
2024-10-02reviewlcnr-3/+5
2024-10-01add caches to multiple type folderslcnr-5/+57
2024-09-27Get rid of a_is_expected from ToTraceMichael Goulet-109/+36
2024-09-27Instantiate binders when checking supertrait upcastingMichael Goulet-1/+18
2024-09-25Stabilize the `map`/`value` methods on `ControlFlow`Scott McMurray-1/+0
And fix the stability attribute on the `pub use` in `core::ops`.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-86/+73
2024-09-11Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errorsJubilee-2/+2
Remove needless returns detected by clippy in the compiler
2024-09-10generalize: track relevant info in cache keylcnr-9/+9
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-2/+2
2024-09-07Rename variant `AddrOfRegion` of `RegionVariableOrigin` to `BorrowRegion`Gurinder Singh-3/+3
because "Borrow" is the more idiomatic Rust term than "AddrOf".
2024-09-02chore: Fix typos in 'compiler' (batch 1)Alexander Cyon-4/+4
2024-08-31Rollup merge of #129767 - nnethercote:rm-extern-crate-tracing-4, r=jieyouxuMatthias Krüger-3/+26
Remove `#[macro_use] extern crate tracing`, round 4 Because explicit importing of macros via use items is nicer (more standard and readable) than implicit importing via #[macro_use]. Continuing the work from #124511, #124914, and #125434. After this PR no `rustc_*` crates use `#[macro_use] extern crate tracing` except for `rustc_codegen_gcc` which is a special case and I will do separately. r? ```@jieyouxu```
2024-08-30Remove `#[macro_use] extern crate tracing` from `rustc_infer`.Nicholas Nethercote-3/+26
2024-08-29Stop using ty::GenericPredicates for non-predicates_of queriesMichael Goulet-1/+1
2024-08-27Add `warn(unreachable_pub)` to `rustc_infer`.Nicholas Nethercote-11/+12
2024-08-26Remove a couple of unused feature enablesbjorn3-2/+0
2024-08-21Point at explicit `'static` obligations on a traitEsteban Küber-4/+8
Given `trait Any: 'static` and a `struct` with a `Box<dyn Any + 'a>` field, point at the `'static` bound in `Any` to explain why `'a: 'static`. ``` error[E0478]: lifetime bound not satisfied --> f202.rs:2:12 | 2 | value: Box<dyn std::any::Any + 'a>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here --> f202.rs:1:14 | 1 | struct Hello<'a> { | ^^ note: but lifetime parameter must outlive the static lifetime --> /home/gh-estebank/rust/library/core/src/any.rs:113:16 | 113 | pub trait Any: 'static { | ^^^^^^^ ``` Partially address #33652.
2024-08-14Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errorsbors-1/+1
Shrink `TyKind::FnPtr`. By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI. r? `@compiler-errors`
2024-08-11Use assert_matches around the compilerMichael Goulet-1/+4
2024-08-09Shrink `TyKind::FnPtr`.Nicholas Nethercote-1/+1
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
2024-07-29Use Vec in instantiate_binder_with_fresh_varsBryanskiy-24/+22
2024-07-29Reformat `use` declarations.Nicholas Nethercote-203/+187
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-22Get rid of can_eq_shallowMichael Goulet-12/+0
2024-07-21Move all error reporting into rustc_trait_selectionMichael Goulet-11578/+33
2024-07-21Move need_type_info tooMichael Goulet-38/+19
2024-07-21Make type_var_origin take a vidMichael Goulet-10/+4
2024-07-21Move some stuff to TypeErrCtxtMichael Goulet-15/+11
2024-07-21Auto merge of #120812 - compiler-errors:impl-sorting, r=lcnrbors-2/+1
Remove unnecessary impl sorting in queries and metadata Removes unnecessary impl sorting because queries already return their keys in HIR definition order: https://github.com/rust-lang/rust/issues/120371#issuecomment-1926422838 r? `@cjgillot` or `@lcnr` -- unless I totally misunderstood what was being asked for here? 😆 fixes #120371
2024-07-19Auto merge of #125915 - camelid:const-arg-refactor, r=BoxyUwUbors-2/+2
Represent type-level consts with new-and-improved `hir::ConstArg` ### Summary This is a step toward `min_generic_const_exprs`. We now represent all const generic arguments using an enum that differentiates between const *paths* (temporarily just bare const params) and arbitrary anon consts that may perform computations. This will enable us to cleanly implement the `min_generic_const_args` plan of allowing the use of generics in paths used as const args, while disallowing their use in arbitrary anon consts. Here is a summary of the salient aspects of this change: - Add `current_def_id_parent` to `LoweringContext` This is needed to track anon const parents properly once we implement `ConstArgKind::Path` (which requires moving anon const def-creation outside of `DefCollector`). - Create `hir::ConstArgKind` enum with `Path` and `Anon` variants. Use it in the existing `hir::ConstArg` struct, replacing the previous `hir::AnonConst` field. - Use `ConstArg` for all instances of const args. Specifically, use it instead of `AnonConst` for assoc item constraints, array lengths, and const param defaults. - Some `ast::AnonConst`s now have their `DefId`s created in rustc_ast_lowering rather than `DefCollector`. This is because in some cases they will end up becoming a `ConstArgKind::Path` instead, which has no `DefId`. We have to solve this in a hacky way where we guess whether the `AnonConst` could end up as a path const since we can't know for sure until after name resolution (`N` could refer to a free const or a nullary struct). If it has no chance as being a const param, then we create a `DefId` in `DefCollector` -- otherwise we decide during ast_lowering. This will have to be updated once all path consts use `ConstArgKind::Path`. - We explicitly use `ConstArgHasType` for array lengths, rather than implicitly relying on anon const type feeding -- this is due to the addition of `ConstArgKind::Path`. - Some tests have their outputs changed, but the changes are for the most part minor (including removing duplicate or almost-duplicate errors). One test now ICEs, but it is for an incomplete, unstable feature and is now tracked at https://github.com/rust-lang/rust/issues/127009. ### Followup items post-merge - Use `ConstArgKind::Path` for all const paths, not just const params. - Fix (no github dont close this issue) #127009 - If a path in generic args doesn't resolve as a type, try to resolve as a const instead (do this in rustc_resolve). Then remove the special-casing from `rustc_ast_lowering`, so that all params will automatically be lowered as `ConstArgKind::Path`. - (?) Consider making `const_evaluatable_unchecked` a hard error, or at least trying it in crater r? `@BoxyUwU`
2024-07-18Revert "sort suggestions for object diagnostic"Michael Goulet-2/+1
This reverts commit 540be28f6c2571e7be3ab3936b62635fa0d3caf3.
2024-07-18Remove tag field from relationsMichael Goulet-39/+16
2024-07-18valtree construction: keep track of which type was valtree-incompatibleRalf Jung-3/+3
2024-07-18Rollup merge of #127810 - compiler-errors:less-tcx, r=lcnrMatthias Krüger-17/+17
Rename `tcx` to `cx` in `rustc_type_ir` Self-explanatory. Forgot that we had to do this in type_ir too, and not just the new solver crate lol. r? lcnr
2024-07-17Fix precise capturing suggestion for hidden type when APITs are involvedMichael Goulet-16/+110
2024-07-17Fix relationsMichael Goulet-17/+17
2024-07-16Use `ConstArg` for array lengthsNoah Lev-2/+2
2024-07-15Move rustc_infer::infer::error_reporting to rustc_infer::error_reporting::inferMichael Goulet-65/+479
2024-07-12Rollup merge of #127619 - compiler-errors:precise-capturing-better-sugg, ↵Jubilee-12/+138
r=oli-obk Suggest using precise capturing for hidden type that captures region Adjusts the "add `+ '_`" suggestion for opaques to instead suggest adding or reusing the `+ use<>` in the opaque. r? oli-obk or please re-roll if you're busy!
2024-07-11Make it translatable tooMichael Goulet-13/+39
2024-07-11Suggest using precise capturing for hidden type that captures regionMichael Goulet-12/+112
2024-07-11Avoid follow-up errors and ICEs after missing lifetime errors on data structuresOli Scherer-0/+3
2024-07-08Consolidate region error reporting in rustc_inferMichael Goulet-1263/+1268
2024-07-08Auto merge of #127438 - compiler-errors:compute-outlives-visitor, r=lcnrbors-22/+9
Make `push_outlives_components` into a `TypeVisitor` This involves removing the `visited: &mut SsoHashSet<GenericArg<'tcx>>` that is being passed around the `VerifyBoundCx`. The fact that we were using it when decomposing different type tests seems sketchy, so I don't think, though it may technically result in us registering more redundant outlives components 🤷 I did end up deleting some of the comments that referred back to RFC 1214 during this refactor. I can add them back if you think they were useful. r? lcnr
2024-07-08Rollup merge of #127439 - compiler-errors:uplift-elaborate, r=lcnr许杰友 Jieyou Xu (Joe)-345/+4
Uplift elaboration into `rustc_type_ir` Allows us to deduplicate and consolidate elaboration (including these stupid elaboration duplicate fns i added for pretty printing like 3 years ago) so I'm pretty hyped about this change :3 r? lcnr