summary refs log tree commit diff
path: root/compiler/rustc_infer/src
AgeCommit message (Collapse)AuthorLines
2024-08-29Emit specific message for `time<0.3.35` inference failureEsteban Küber-2/+47
``` error[E0282]: type annotations needed for `Box<_>` --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.34/src/format_description/parse/mod.rs:83:9 | 83 | let items = format_items | ^^^^^ ... 86 | Ok(items.into()) | ---- type must be known at this point | = note: this is an inference error on crate `time` caused by a change in Rust 1.80.0; update `time` to version `>=0.3.35` ``` Partially address #127343. (cherry picked from commit b013a3ddf0060b62ee8050e241f80d024c48cc59)
2024-08-15Revert "Auto merge of #125915 - camelid:const-arg-refactor, r=BoxyUwU"Boxy-2/+2
This reverts commit 8c3a94a1c79c67924558a4adf7fb6d98f5f0f741, reversing changes made to 3d68afc9e821b00d59058abc9bda670b07639955.
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-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?
2024-07-06Uplift push_outlives_componentsMichael Goulet-270/+5
2024-07-06Uplift PredicateEmittingRelation firstMichael Goulet-39/+15
2024-07-06show unit output when there is only output diff in diagnosticsyukang-2/+9
2024-07-05Split out transitive_bounds_that_define_assoc_itemMichael Goulet-14/+25
2024-07-05Split SolverDelegate back out from InferCtxtLikeMichael Goulet-0/+173
2024-07-05Supertrait elaboration doesn't need to use PredicatesMichael Goulet-5/+5
2024-07-05Actually just make can_eq process obligations (almost) everywhereMichael Goulet-17/+3
2024-07-05Process alias-relate obligations when proving receiver_is_validMichael Goulet-0/+4
2024-07-04Use shorter span for float literal suggestionEsteban Küber-3/+3
2024-07-02Instance::resolve -> Instance::try_resolve, and other nitsMichael Goulet-1/+1
2024-07-01Auto merge of #126996 - oli-obk:do_not_count_errors, r=nnethercotebors-49/+37
Automatically taint InferCtxt when errors are emitted r? `@nnethercote` Basically `InferCtxt::dcx` now returns a `DiagCtxt` that refers back to the `Cell<Option<ErrorGuaranteed>>` of the `InferCtxt` and thus when invoking `Diag::emit`, and the diagnostic is an error, we taint the `InferCtxt` directly. That change on its own has no effect at all, because `InferCtxt` already tracks whether errors have been emitted by recording the global error count when it gets opened, and checking at the end whether the count changed. So I removed that error count check, which had a bit of fallout that I immediately fixed by invoking `InferCtxt::dcx` instead of `TyCtxt::dcx` in a bunch of places. The remaining new errors are because an error was reported in another query, and never bubbled up. I think they are minor enough for this to be ok, and sometimes it actually improves diagnostics, by not silencing useful diagnostics anymore. fixes #126485 (cc `@olafes)` There are more improvements we can do (like tainting in hir ty lowering), but I would rather do that in follow up PRs, because it requires some refactorings.
2024-06-27Make queries more explicitMichael Goulet-4/+4
2024-06-26Automatically taint InferCtxt when errors are emittedOli Scherer-32/+20
2024-06-26Restrict diagnostic context lifetime of InferCtxt to itself instead of TyCtxtOli Scherer-8/+8
2024-06-26Restrict diagnostic context lifetime of TypeErrCtxt to InferCtxt instead of ↵Oli Scherer-6/+6
TyCtxt
2024-06-26Restrict diagnostic context lifetime of FnCtxt to InferCtxt instead of TyCtxtOli Scherer-3/+3
2024-06-25Rollup merge of #126915 - SparkyPotato:fix-126903, r=compiler-errorsMatthias Krüger-2/+4
Don't suggest awaiting in closure patterns Fixes #126903. For ```rust async fn do_async() {} fn main() { Some(do_async()).map(|()| {}); } ``` the error is now ```rust error[E0308]: mismatched types --> src/main.rs:4:27 | 4 | Some(do_async()).map(|()| {}); | ^^ | | | expected future, found `()` | expected due to this | = note: expected opaque type `impl Future<Output = ()>` found unit type `()` ``` Ideally, if `main` were to be `async`, it should be ```rs error[E0308]: mismatched types --> src/main.rs:4:27 | 4 | Some(do_async()).map(|()| {}); | ^^ | | | expected future, found `()` | expected due to this | = note: expected opaque type `impl Future<Output = ()>` found unit type `()` help: consider `await`ing on the `Future` | 4 | Some(do_async().await).map(|()| {}); | ++++++ ``` However, this would mean `FnCtx::check_pat_top` would have to be called with an `origin_expr` in `rustc_hir_typeck::check::check_fn`, and that expr would have to be somehow plumbed through `FnCtxt::check_expr_closure` and closure signature deduction. I'm willing to work on the plumbing but unsure how to start.
2024-06-24don't suggest awaiting type expr patternsSparkyPotato-2/+4
2024-06-24Split out IntoIterator and non-Iterator constructors for ↵Michael Goulet-2/+2
AliasTy/AliasTerm/TraitRef/projection
2024-06-21Rename a bunch of thingsMichael Goulet-12/+12
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+3
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.