about summary refs log tree commit diff
path: root/compiler/rustc_infer/src/infer
AgeCommit message (Collapse)AuthorLines
2023-12-15Annotate some bugsMichael Goulet-14/+28
2023-12-15unify query canonicalization modeAli MJ Al-Nasrawy-56/+27
2023-12-15Opportunistically resolve region var in canonicalizerMichael Goulet-15/+2
2023-12-14update use of feature flagslcnr-2/+2
2023-12-14Auto merge of #117749 - aliemjay:perf-canon-cache, r=lcnrbors-115/+123
cache param env canonicalization Canonicalize ParamEnv only once and store it. Then whenever we try to canonicalize `ParamEnvAnd<'tcx, T>` we only have to canonicalize `T` and then merge the results. Prelimiary results show ~3-4% savings in diesel and serde benchmarks. Best to review commits individually. Some commits have a short description. Initial implementation had a soundness bug (https://github.com/rust-lang/rust/pull/117749#issuecomment-1840453387) due to cache invalidation: - When canonicalizing `Ty<'?0>` we first try to resolve region variables in the current InferCtxt which may have a constraint `?0 == 'static`. This means that we register `Ty<'?0> => Canonical<Ty<'static>>` in the cache, which is obviously incorrect in another inference context. - This is fixed by not doing region resolution when canonicalizing the query *input* (vs. response), which is the only place where ParamEnv is used, and then in a later commit we *statically* guard against any form of inference variable resolution of the cached canonical ParamEnv's. r? `@ghost`
2023-12-14remove canonicalize_query_preserving_universesAli MJ Al-Nasrawy-47/+0
unused!
2023-12-14make infcx optional in canonicalizerAli MJ Al-Nasrawy-45/+35
This doesn't change behavior. It should prevent unintentional resolution of inference variables during canonicalization, which previously caused a soundness bug. See PR description for more.
2023-12-13Tweak `short_ty_string` to reduce number of filesEsteban Küber-57/+46
When shortening types and writing them to disk, make `short_ty_string` capable of reusing the same file, instead of writing a file per shortened type.
2023-12-13don't resolve regions in query inputAli MJ Al-Nasrawy-15/+15
fixes a soundness regression described in the PR description.
2023-12-13don't store OriginalQueryValues::universe_mapAli MJ Al-Nasrawy-0/+1
ParamEnv is canonicalized in *queries input* rather than query response. In such case we don't "preserve universes" of canonical variable. This means that `universe_map` always has the default value, which is wasteful to store in the cache.
2023-12-13global param_env canonicalization cacheAli MJ Al-Nasrawy-16/+80
2023-12-13Auto merge of #118500 - ZetaNumbers:tcx_hir_refactor, r=petrochenkovbors-14/+12
Move some methods from `tcx.hir()` to `tcx` https://github.com/rust-lang/rust/pull/118256#issuecomment-1826442834 Renamed: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id
2023-12-12Rollup merge of #118889 - matthiaskrgr:compl_2023_2, r=WaffleLapkinJubilee-1/+1
more clippy::complexity fixes redundant_guards redundant_slicing filter_next needless_borrowed_reference useless_format
2023-12-12more clippy::complexity fixesMatthias Krüger-1/+1
redundant_guards redundant_slicing filter_next needless_borrowed_reference useless_format
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-14/+12
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-12refactor writeback: emit normalization errors with new solverlcnr-27/+1
2023-12-12Auto merge of #118742 - lcnr:infer-var-cleanup, r=compiler-errorsbors-89/+33
refactor infer var storage cleanup the code, discovered while working on #118725
2023-12-10Revert "Don't print host effect param in pretty path_generic_args"Deadbeef-13/+7
This reverts commit f1bf874fb13703d706fc8184407c6df12555d8e9.
2023-12-09Don't print host effect param in pretty path_generic_argsMichael Goulet-7/+13
2023-12-08Rollup merge of #118730 - jyn514:cmp_refs, r=estebank,compiler-errorsMatthias Krüger-42/+52
recurse into refs when comparing tys for diagnostics before: ![image](https://github.com/rust-lang/rust/assets/23638587/bf6abd62-c7f3-4c09-a47e-31b6e129de19) after: ![image](https://github.com/rust-lang/rust/assets/23638587/b704d728-ddba-4204-aebe-c07dcbbcb55c) this diff from the test suite is also quite nice imo: ```diff `@@` -4,8 +4,8 `@@` error[E0308]: mismatched types LL | debug_assert_eq!(iter.next(), Some(value)); | ^^^^^^^^^^^ expected `Option<<I as Iterator>::Item>`, found `Option<&<I as Iterator>::Item>` | - = note: expected enum `Option<<I as Iterator>::Item>` - found enum `Option<&<I as Iterator>::Item>` + = note: expected enum `Option<_>` + found enum `Option<&_>` ```
2023-12-08Uplift canonicalizer into new trait solver crateMichael Goulet-22/+55
2023-12-08cleanup type variable storagelcnr-89/+33
2023-12-07recurse into refs when comparing tys for diagnosticsjyn-42/+52
2023-12-08update fixmelcnr-4/+3
2023-12-08implement and use `NormalizesTo`lcnr-26/+40
2023-12-07avoid instantiating infer vars with inferlcnr-4/+9
2023-12-05Add print_trait_sugaredMichael Goulet-2/+2
2023-12-04cleanup and commentslcnr-26/+34
2023-12-04generalize: handle occurs check failure in aliaseslcnr-23/+120
2023-12-04do not fetch variance info during generalizationlcnr-1/+1
2023-12-02Use `Session::diagnostic` in more places.Nicholas Nethercote-12/+12
2023-12-02Rename `Handler::delay_good_path_bug` as `Handler::good_path_delayed_bug`.Nicholas Nethercote-1/+1
In line with the previous commits.
2023-12-02Rename `HandlerInner::delayed_span_bugs` as `HandlerInner::span_delayed_bugs`.Nicholas Nethercote-1/+1
For reasons similar to the previous commit.
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-11/+11
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-29Rollup merge of #118269 - compiler-errors:poly, r=wesleywiserMatthias Krüger-22/+6
Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs` I did this recently with `FnSigs` and `PolyFnSigs` but didn't think to do it with `TraitRefs` and `PolyTraitRefs`.
2023-11-26Rollup merge of #118302 - mu001999:dead_code/clean, r=cjgillotGuillaume Gomez-3/+0
Clean dead codes Clean dead codes detected by #118257
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-6/+6
cleanup
2023-11-26Clean dead codesr0cky-3/+0
2023-11-25Remove some more unused codepaths in (region) error reportingMichael Goulet-6/+0
2023-11-25Rollup merge of #118199 - compiler-errors:qpath, r=lcnrGuillaume Gomez-1/+1
Remove `HirId` from `QPath::LangItem` Remove `HirId` from `QPath::LangItem`, since there was only *one* use-case (`ObligationCauseCode::AwaitableExpr`), which we can instead recover by walking the HIR tree.
2023-11-25Rollup merge of #117871 - klensy:unused-pub, r=cjgillotGuillaume Gomez-12/+1
remove unused pub fns This removes some unused `pub fn`; also fixes few obsoleted fn names or added fixmes with reminders to update them.
2023-11-25Remove HirId from QPath::LangItemMichael Goulet-1/+1
2023-11-25Rollup merge of #118259 - spastorino:move-eager-resolver-to-infer, ↵León Orell Valerian Liehr-0/+82
r=compiler-errors Move EagerResolution to rustc_infer::infer::resolve `EagerResolver` fits better in `rustc_infer::infer::resolver`. Started to disentagle #118118 that has a lot of unrelated things. r? `@compiler-errors` `@lcnr`
2023-11-24Unify TraitRefs and PolyTraitRefsMichael Goulet-22/+6
2023-11-24Move EagerResolution to rustc_infer::infer::resolveSantiago Pastorino-0/+82
2023-11-24Replace `option.map(cond) == Some(true)` with `option.is_some_and(cond)`David Tolnay-2/+1
2023-11-24Auto merge of #118189 - compiler-errors:cache-flags-for-const, r=nnethercotebors-3/+5
Cache flags for `ty::Const` Not sure if this has been attempted yet, but worth a shot. It does make the code simpler in `rustc_type_ir`, since we can assume that consts have a `flags` method that is no-cost. r? `@ghost`
2023-11-23remove unused pub fnklensy-12/+1
2023-11-22Cache flags for ty::ConstMichael Goulet-3/+5
2023-11-22Auto merge of #118120 - compiler-errors:closure-kind, r=lcnrbors-2/+4
Remove `PredicateKind::ClosureKind` We don't need the `ClosureKind` predicate kind -- instead, `Fn`-family trait goals are left as ambiguous, and we only need to make progress on `FnOnce` projection goals for inference purposes. This is similar to how we do confirmation of `Fn`-family trait and projection goals in the new trait solver, which also doesn't use the `ClosureKind` predicate. Some hacky logic is added in the second commit so that we can keep the error messages the same.