about summary refs log tree commit diff
path: root/compiler/rustc_infer/src
AgeCommit message (Collapse)AuthorLines
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
2024-07-08Rollup merge of #127437 - compiler-errors:uplift-trait-ref-is-knowable, r=lcnr许杰友 Jieyou Xu (Joe)-0/+4
Uplift trait ref is knowable into `rustc_next_trait_solver` Self-explanatory. Eliminates one more delegate method. r? lcnr cc ``@fmease``
2024-07-07Auto merge of #127172 - compiler-errors:full-can_eq-everywhere, r=lcnrbors-15/+5
Make `can_eq` process obligations (almost) everywhere Move `can_eq` to an extension trait on `InferCtxt` in `rustc_trait_selection`, and change it so that it processes obligations. This should strengthen it to be more accurate in some cases, but is most important for the new trait solver which delays relating aliases to `AliasRelate` goals. Without this, we always basically just return true when passing aliases to `can_eq`, which can lead to weird errors, for example #127149. I'm not actually certain if we should *have* `can_eq` be called on the good path. In cases where we need `can_eq`, we probably should just be using a regular probe. Fixes #127149 r? lcnr
2024-07-07Uplift elaborationMichael Goulet-345/+4
2024-07-07Make push_outlives_components into a visitorMichael Goulet-6/+1
2024-07-07Uplift trait_ref_is_knowable and friendsMichael Goulet-0/+4
2024-07-06Don't track visited outlives bounds when decomposing verify for aliasMichael Goulet-22/+14
2024-07-06Rollup merge of #127417 - chenyukang:yukang-method-output-diff, r=oli-obkMichael Goulet-2/+4
Show fnsig's unit output explicitly when there is output diff in diagnostics Fixes #127263
2024-07-06Rollup merge of #127405 - ↵Michael Goulet-39/+15
compiler-errors:uplift-predicate-emitting-relation, r=lcnr uplift `PredicateEmittingRelation` Small follow-up to #127333 r? lcnr
2024-07-06Rollup merge of #127386 - compiler-errors:uplift-outlives-components, r=lcnrMichael Goulet-273/+6
Uplift outlives components to `rustc_type_ir` We need this to uplift `push_outlives_components`, since the elaborator uses `push_outlives_components` to elaborate type outlives obligations and I want to uplift elaboration. This ends up reworking and inlining a fair portion of the `GenericArg::walk_shallow` function, whose only callsite was this one. I believe I got the logic correct, but may be worthwhile to look at it closely just in case. Unfortunately github was too dumb to understand that this is a rename + change -- I could also rework the git history to split the "copy the file over" part from the actual logical changes if that makes this easier to review. r? lcnr
2024-07-06Auto merge of #127388 - compiler-errors:elaboration-tweaks, r=lcnrbors-18/+29
Elaboration tweaks Removes `Filter::OnlySelfThatDefines` and reimplements `transitive_bounds_that_define_assoc_item` as a separate function, since I don't want to have to uplift that mode since it's both an implementation detail (only exists to avoid cycles in astconv) and requires exposing `Ident` as an associated type on `Interner`. r? lcnr
2024-07-06show fnsig's output when there is differenceyukang-8/+3
2024-07-06Import via rustc_type_ir::outlivesMichael Goulet-5/+3
We could use rustc_middle::ty::outlives I guess?