about summary refs log tree commit diff
path: root/compiler/rustc_infer/src
AgeCommit message (Collapse)AuthorLines
2023-12-23Give `DiagnosticBuilder` a default type.Nicholas Nethercote-32/+26
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the most common diagnostic level. It makes sense to do likewise for the closely-related (and much more widely used) `DiagnosticBuilder` type, letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many multi-line things becoming single line things.
2023-12-22Auto merge of #118824 - aliemjay:perf-region-cons, r=compiler-errorsbors-20/+21
use Vec for region constraints instead of BTreeMap ~1% perf gain Diagnostic regressions need more investigation. r? `@ghost`
2023-12-22Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errorsbors-39/+28
Fix `EmissionGuarantee` There are some problems with the `DiagCtxt` API related to `EmissionGuarantee`. This PR fixes them. r? `@compiler-errors`
2023-12-20Rollup merge of #119107 - lcnr:uwuwu, r=compiler-errorsMatthias Krüger-12/+3
subtype_predicate: remove unnecessary probe There is no reason to probe here. The failure either results in an actual type error, in which cases the probe is useless, or it is used inside of evaluate, in which case we're already inside of the `fn evaluation_probe`, so it is also not necessary.
2023-12-20Auto merge of #119096 - compiler-errors:yeet-unnecessary-param-envs, r=lcnrbors-63/+34
Yeet unnecessary param envs We don't need to pass in param-envs around in the lexical region resolution code (or in `MatchAgainstFreshVars` in the solver), since it is only used to eval some consts in `structurally_relate_tys` which I removed. This is in preparation for normalizing the outlives clauses in `ParamEnv` for the new trait solver. r? lcnr
2023-12-19Auto merge of #119084 - aliemjay:perf-env-bounds, r=compiler-errorsbors-2/+12
fast path for declared_generic_bounds_from_env ~2% perf gain for diesel
2023-12-19Remove param env from relation altogetherMichael Goulet-32/+22
2023-12-19fast path for declared_generic_bounds_from_envAli MJ Al-Nasrawy-2/+12
2023-12-19Remove unnecessary param-env from lexical region resolution and fully ↵Michael Goulet-34/+15
structural relations
2023-12-19subtype_predicate: remove unnecessary probelcnr-12/+3
2023-12-18Use `.into_diagnostic()` less.Nicholas Nethercote-39/+28
This commit replaces this pattern: ``` err.into_diagnostic(dcx) ``` with this pattern: ``` dcx.create_err(err) ``` in a lot of places. It's a little shorter, makes the error level explicit, avoids some `IntoDiagnostic` imports, and is a necessary prerequisite for the next commit which will add a `level` arg to `into_diagnostic`. This requires adding `track_caller` on `create_err` to avoid mucking up the output of `tests/ui/track-diagnostics/track4.rs`. It probably should have been there already.
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-12/+12
2023-12-17use Vec for region constraintsAli MJ Al-Nasrawy-20/+21
2023-12-15Rollup merge of #119004 - matthiaskrgr:conv, r=compiler-errorsJubilee-7/+2
NFC don't convert types to identical types
2023-12-15NFC don't convert types to identical typesMatthias Krüger-7/+2
2023-12-15Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillotJubilee-18/+8
Collect lang items from AST, get rid of `GenericBound::LangItemTrait` r? `@cjgillot` cc #115178 Looking forward, the work to remove `QPath::LangItem` will also be significantly more difficult, but I plan on doing it as well. Specifically, we have to change: 1. A lot of `rustc_ast_lowering` for things like expr `..` 2. A lot of astconv, since we actually instantiate lang and non-lang paths quite differently. 3. A ton of diagnostics and clippy lints that are special-cased via `QPath::LangItem` Meanwhile, it was pretty easy to remove `GenericBound::LangItemTrait`, so I just did that here.
2023-12-15Move nll_relate to relate::nll submoduleMichael Goulet-5/+5
2023-12-15Add higher_ranked to relate submoduleMichael Goulet-8/+8
2023-12-15Move type relations into submodule in rustc_inferMichael Goulet-41/+42
2023-12-15banish hir::GenericBound::LangItemTraitMichael Goulet-18/+8
2023-12-15Annotate some bugsMichael Goulet-14/+28
2023-12-15Opportunistically resolve region var in canonicalizerMichael Goulet-15/+2
2023-12-14update use of feature flagslcnr-3/+3
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-17/+13
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-17/+13
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-11Auto merge of #118661 - fee1-dead-contrib:restore-const-partialEq, ↵bors-13/+7
r=compiler-errors Restore `const PartialEq` And thus fixes a number of tests. There is a bug that still needs to be fixed, so WIP for now. r? `@compiler-errors`
2023-12-10Auto merge of #118692 - surechen:remove_unused_imports, r=petrochenkovbors-1/+1
remove redundant imports detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR. r? `@petrochenkov`
2023-12-10Revert "Don't print host effect param in pretty path_generic_args"Deadbeef-13/+7
This reverts commit f1bf874fb13703d706fc8184407c6df12555d8e9.
2023-12-10remove redundant importssurechen-1/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
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-07add unused `NormalizesTo` predicatelcnr-44/+26
2023-12-07avoid instantiating infer vars with inferlcnr-4/+9
2023-12-05Add print_trait_sugaredMichael Goulet-2/+2