about summary refs log tree commit diff
path: root/compiler/rustc_infer
AgeCommit message (Collapse)AuthorLines
2024-04-23Rollup merge of #124218 - Xiretza:subsubdiagnostics, r=davidtwcoLeón Orell Valerian Liehr-10/+10
Allow nesting subdiagnostics in #[derive(Subdiagnostic)]
2024-04-23Rollup merge of #120929 - long-long-float:wrap-dyn-in-suggestion, r=fmeaseLeón Orell Valerian Liehr-5/+11
Wrap dyn type with parentheses in suggestion Close #120223 Fix wrong suggestion that is grammatically incorrect. Specifically, I added parentheses to dyn types that need lifetime bound. ``` help: consider adding an explicit lifetime bound | 4 | executor: impl FnOnce(T) -> (dyn Future<Output = ()>) + 'static, | + +++++++++++ ```
2024-04-22Rollup merge of #124183 - compiler-errors:unnecessary-by-ref, r=oli-obkGuillaume Gomez-7/+7
Stop taking `ParamTy`/`ParamConst`/`EarlyParamRegion`/`AliasTy` by ref It's unnecessary and is annoying when we have it by value.
2024-04-23Wrap dyn type with parentheses in suggestionlong-long-float-5/+11
2024-04-21Auto merge of #124203 - lukas-code:delete-deleting-caches, r=compiler-errorsbors-11/+3
fix normalizing in different `ParamEnv`s with the same `InferCtxt` This PR changes the key of the projection cache from just `AliasTy` to `(AliasTy, ParamEnv)` to allow normalizing in different `ParamEnv`s without resetting caches. Previously, normalizing the same alias in different param envs would always reuse the cached result from the first normalization, which is incorrect if the projection clauses in the param env have changed. Fixing this bug allows us to get rid of `InferCtxt::clear_caches`, which was only used by the `AutoTraitFinder`, because it requires normalizing in different param envs. r? `@fmease`
2024-04-21Pass translation closure to add_to_diag_with() as referenceXiretza-10/+10
2024-04-20Rollup merge of #123379 - wutchzone:119266, r=compiler-errors许杰友 Jieyou Xu (Joe)-1/+18
Print note with closure signature on type mismatch Fixes #119266 r? Nilstrieb
2024-04-20remove `InferCtxt::clear_caches`Lukas Markeffsky-9/+0
2024-04-20include ParamEnv in projection cache keyLukas Markeffsky-2/+3
2024-04-20Print note with closure signature on type mismatchDaniel Sedlak-1/+18
2024-04-19Stop taking ParamTy/ParamConst/EarlyParamRegion/AliasTy by refMichael Goulet-7/+7
2024-04-18Rollup merge of #123980 - WaffleLapkin:graph-average-refactor, r=wesleywiserJubilee-1/+1
Add an opt-in to store incoming edges in `VecGraph` + misc r? ```@fmease``` needed for #123939
2024-04-18Auto merge of #124008 - nnethercote:simpler-static_assert_size, r=Nilstriebbors-3/+3
Simplify `static_assert_size`s. We want to run them on all 64-bit platforms. r? `@ghost`
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-3/+3
We want to run them on all 64-bit platforms.
2024-04-17Don't error on subtyping of equal typesOli Scherer-1/+1
2024-04-16Auto merge of #123537 - compiler-errors:shallow, r=lcnrbors-107/+79
Simplify shallow resolver to just fold ty/consts Probably faster than using a whole folder?
2024-04-16Rollup merge of #123979 - oli-obk:define_opaque_types7, r=compiler-errorsGuillaume Gomez-2/+15
Subtype predicates only exist on inference types, so we can allow them to register opaque types within them. We were unable to come up with an example where this could be reached (subtype predicates with either side not being an infer var gets consumed during any `select_where_possible` invocation, of which we have a lot in typeck). To ensure we don't silently accept new behaviour in case we missed a situation where this could occur, I have added an assert that prevents opaque types from having their hidden type constrained. r? `@compiler-errors`
2024-04-16Rollup merge of #123969 - oli-obk:define_opaque_types6, r=compiler-errorsMatthias Krüger-1/+1
The new solver ignores `DefineOpaqueTypes`, so switch it to `Yes` We assert that we are in the new solver in the line above r? ``@compiler-errors``
2024-04-16Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obkbors-0/+1
Implement syntax for `impl Trait` to specify its captures explicitly (`feature(precise_capturing)`) Implements `impl use<'a, 'b, T, U> Sized` syntax that allows users to explicitly list the captured parameters for an opaque, rather than inferring it from the opaque's bounds (or capturing *all* lifetimes under 2024-edition capture rules). This allows us to exclude some implicit captures, so this syntax may be used as a migration strategy for changes due to #117587. We represent this list of captured params as `PreciseCapturingArg` in AST and HIR, resolving them between `rustc_resolve` and `resolve_bound_vars`. Later on, we validate that the opaques only capture the parameters in this list. We artificially limit the feature to *require* mentioning all type and const parameters, since we don't currently have support for non-lifetime bivariant generics. This can be relaxed in the future. We also may need to limit this to require naming *all* lifetime parameters for RPITIT, since GATs have no variance. I have to investigate this. This can also be relaxed in the future. r? `@oli-obk` Tracking issue: - https://github.com/rust-lang/rust/issues/123432
2024-04-16Subtype predicates only exist on inference types, so we can allow them to ↵Oli Scherer-2/+15
register opaque types within them.
2024-04-15Add an opt-in to store incoming edges in `VecGraph` + some docsMaybe Waffle-1/+1
2024-04-16Rollup merge of #123016 - compiler-errors:no-type-var-origin, r=lcnrLeón Orell Valerian Liehr-122/+61
Remove `TypeVariableOriginKind` and `ConstVariableOriginKind` It's annoying to have to import `TypeVariableOriginKind` just to fill it with `MiscVariable` for almost every use. Every other usage other than `TypeParameterDefinition` wasn't even used -- I can see how it may have been useful once for debugging, but I do quite a lot of typeck debugging and I've never really needed it. So let's just remove it, and keep around the only useful thing which is the `DefId` of the param for `var_for_def`. This is based on #123006, which removed the special use of `TypeVariableOriginKind::OpaqueInference`, which I'm pretty sure I was the one that added. r? lcnr or re-roll to types
2024-04-15Simplify shallow resolver to just fold ty/constsMichael Goulet-107/+79
2024-04-15Rebase falloutMichael Goulet-3/+4
2024-04-15nitsMichael Goulet-4/+3
2024-04-15Account for Self params properlyMichael Goulet-20/+19
2024-04-15Remove ConstVariableOriginKindMichael Goulet-32/+15
2024-04-15Remove TypeVariableOriginKindMichael Goulet-74/+31
2024-04-15More polishingMichael Goulet-0/+1
2024-04-15The new solver ignores `DefineOpaqueTypes`, so switch it to `Yes`Oli Scherer-1/+1
We assert that we are in the new solver in the line above
2024-04-15PolyTraitRefs -> TraitRefsMichael Goulet-34/+16
2024-04-11Rollup merge of #123703 - estebank:diag-changes-2, r=NadrierilLeón Orell Valerian Liehr-19/+70
Use `fn` ptr signature instead of `{closure@..}` in infer error When suggesting a type on inference error, do not use `{closure@..}`. Instead, replace with an appropriate `fn` ptr. On the error message, use `short_ty_string` and write long types to disk. ``` error[E0284]: type annotations needed for `Select<{closure@lib.rs:2782:13}, _, Expression<'_>, _>` --> crates/lang/src/parser.rs:41:13 | 41 | let lit = select! { | ^^^ 42 | Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()), | ---- type must be known at this point | = note: the full type name has been written to '/home/gh-estebank/iowo/target/debug/deps/lang-e2d6e25819442273.long-type-4587393693885174369.txt' = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan` help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified | 41 | let lit: Select<for<'a, 'b> fn(tokens::Token<'_>, &'a mut MapExtra<'_, 'b, _, _>) -> Option<Expression<'_>>, _, Expression<'_>, _> = select! { | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ``` instead of ``` error[E0284]: type annotations needed for `Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _>` --> crates/lang/src/parser.rs:41:13 | 41 | let lit = select! { | ^^^ 42 | Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()), | ---- type must be known at this point | = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan` help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified | 41 | let lit: Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _> = select! { | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ``` Address #123630 (test missing).
2024-04-10Use `fn` ptr signature instead of `{closure@..}` in infer errorEsteban Küber-19/+70
When suggesting a type on inference error, do not use `{closure@..}`. Instead, replace with an appropriate `fn` ptr. On the error message, use `short_ty_string` and write long types to disk. ``` error[E0284]: type annotations needed for `Select<{closure@lib.rs:2782:13}, _, Expression<'_>, _>` --> crates/lang/src/parser.rs:41:13 | 41 | let lit = select! { | ^^^ 42 | Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()), | ---- type must be known at this point | = note: the full type name has been written to '/home/gh-estebank/iowo/target/debug/deps/lang-e2d6e25819442273.long-type-4587393693885174369.txt' = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan` help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified | 41 | let lit: Select<for<'a, 'b> fn(tokens::Token<'_>, &'a mut MapExtra<'_, 'b, _, _>) -> Option<Expression<'_>>, _, Expression<'_>, _> = select! { | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ``` instead of ``` error[E0284]: type annotations needed for `Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _>` --> crates/lang/src/parser.rs:41:13 | 41 | let lit = select! { | ^^^ 42 | Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()), | ---- type must be known at this point | = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan` help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified | 41 | let lit: Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _> = select! { | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ``` Fix #123630.
2024-04-09Add a helper for extending a span to include any trailing whitespaceMichael Goulet-6/+2
2024-04-09Don't use bytepos offsets when computing semicolon span for removalMichael Goulet-2/+9
2024-04-08Auto merge of #122077 - oli-obk:eager_opaque_checks4, r=lcnrbors-93/+87
Pass list of defineable opaque types into canonical queries This eliminates `DefiningAnchor::Bubble` for good and brings the old solver closer to the new one wrt cycles and nested obligations. At that point the difference between `DefiningAnchor::Bind([])` and `DefiningAnchor::Error` was academic. We only used the difference for some sanity checks, which actually had to be worked around in places, so I just removed `DefiningAnchor` entirely and just stored the list of opaques that may be defined. fixes #108498 fixes https://github.com/rust-lang/rust/issues/116877 * [x] run crater - https://github.com/rust-lang/rust/pull/122077#issuecomment-2013293931
2024-04-08Ensure the canonical_param_env_cache does not contain inconsistent ↵Oli Scherer-2/+6
information about the defining anchor
2024-04-08Avoid fetching the opaque type origin when only "is this in the defining ↵Oli Scherer-18/+11
scope" is actually needed
2024-04-08Eliminate `DefiningAnchor` now that is just a single-variant enumOli Scherer-65/+62
2024-04-08Adjust a comment to the new status quoOli Scherer-6/+3
2024-04-08Pass list of defineable opaque types into canonical queriesOli Scherer-12/+15
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+2
2024-04-04Switch `can_eq` and `can_sub` to `DefineOpaqueTypes::Yes`Oli Scherer-2/+6
They are mostly used in diagnostics anyway
2024-04-03Check `x86_64` size assertions on `aarch64`, tooZalathar-3/+3
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to notice when these assertions have been violated.
2024-03-29Rollup merge of #123188 - klensy:clippy-me2, r=NilstriebMatthias Krüger-3/+3
compiler: fix few unused_peekable and needless_pass_by_ref_mut clippy lints This fixes few instances of `unused_peekable` and `needless_pass_by_ref_mut`. While i expected to fix more warnings, `needless_pass_by_ref_mut` produced too much for one PR, so i stopped here. Better reviewed commit by commit, as fixes splitted by chunks.
2024-03-28compiler: fix few needless_pass_by_ref_mut clippy lintsklensy-3/+3
warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_session\src\config.rs:2013:16 | 2013 | early_dcx: &mut EarlyDiagCtxt, | ^^^^^^^^^^^^^^^^^^ help: consider changing to: `&EarlyDiagCtxt` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_ast_passes\src\ast_validation.rs:1555:11 | 1555 | this: &mut AstValidator<'_>, | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&AstValidator<'_>` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_infer\src\infer\snapshot\fudge.rs:16:12 | 16 | table: &mut UnificationTable<'_, 'tcx, T>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&UnificationTable<'_, 'tcx, T>` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_expand\src\expand.rs:961:13 | 961 | parser: &mut Parser<'a>, | ^^^^^^^^^^^^^^^ help: consider changing to: `&Parser<'a>` | = warning: changing this function will impact semver compatibility = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28Auto merge of #122832 - oli-obk:no_ord_def_id3, r=michaelwoeristerbors-1/+2
Remove `DefId`'s `Partial/Ord` impls work towards https://github.com/rust-lang/rust/issues/90317 based on https://github.com/rust-lang/rust/pull/122824 and https://github.com/rust-lang/rust/pull/122820 r? `@michaelwoerister`
2024-03-27Remove TypeVariableOriginKind::OpaqueInferenceMichael Goulet-2/+1
2024-03-27Stop doing expensive work in opt_suggest_box_span eagerlyMichael Goulet-83/+12
2024-03-27Remove `Partial/Ord` from `BoundRegion`Oli Scherer-1/+2