about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
AgeCommit message (Collapse)AuthorLines
2024-04-16Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obkbors-2/+261
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-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-37/+20
Because they're a bit redundant.
2024-04-16Avoid unnecessary `rustc_span::DUMMY_SP` usage.Nicholas Nethercote-1/+1
In some cases `DUMMY_SP` is already imported. In other cases this commit adds the necessary import, in files where `DUMMY_SP` is used more than once.
2024-04-16Emit suggestions when equality constraints are wrongly usedGurinder Singh-11/+114
2024-04-15Delay span bug when Self resolves to DefKind::{Mod,Trait}Michael Goulet-0/+11
2024-04-15redundant ::{self}Michael Goulet-1/+1
2024-04-15Do check_coroutine_obligations once per typeck rootMichael Goulet-36/+11
2024-04-15Rename coroutine_stalled_predicatesMichael Goulet-3/+3
2024-04-16Rollup merge of #123926 - compiler-errors:no-ann, r=estebankLeón Orell Valerian Liehr-4/+4
Fix pretty HIR for anon consts in diagnostics This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`. There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh. r? estebank
2024-04-16Rollup merge of #123016 - compiler-errors:no-type-var-origin, r=lcnrLeón Orell Valerian Liehr-5/+5
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-15Fix pretty hir for anon consts in diagnosticsMichael Goulet-4/+4
2024-04-15Remove TypeVariableOriginKindMichael Goulet-5/+5
2024-04-15More polishingMichael Goulet-3/+11
2024-04-15Use a path instead of an ident (and stop manually resolving)Michael Goulet-3/+26
2024-04-15Some ordering and duplication checksMichael Goulet-15/+70
2024-04-15Add hir::Node::PreciseCapturingNonLifetimeArgMichael Goulet-3/+5
2024-04-15Validation and other thingsMichael Goulet-4/+150
2024-04-15Lower and resolve precise captures in HIRMichael Goulet-0/+25
2024-04-15Rollup merge of #123924 - compiler-errors:tuple-sugg, r=estebankMichael Goulet-65/+9
Fix various bugs in `ty_kind_suggestion` Consolidates two implementations of `ty_kind_suggestion` Fixes some misuse of the empty param-env Fixes a problem where we suggested `(42)` instead of `(42,)` for tuple suggestions Suggest a value when `return;`, making it consistent with `break;` Fixes #123906
2024-04-14Don't leak unnameable types in -> _ recoverMichael Goulet-17/+12
2024-04-14Consolidate two copies of ty_kind_suggestionMichael Goulet-65/+9
2024-04-14Rollup merge of #123898 - fmease:gci-cmp-impl-item-lt-params, r=compiler-errorsMatthias Krüger-4/+2
Generic associated consts: Check regions earlier when comparing impl with trait item def Fixes #123836. r? compiler-errors or compiler
2024-04-13Check regions earlier when comparing impl with trait item defLeón Orell Valerian Liehr-4/+2
2024-04-13remove some ancient debug output, looks unused?klensy-3/+0
2024-04-11remove some things that do not need to beMatthias Krüger-1/+1
2024-04-11Rollup merge of #123774 - Lee-Janggun:master, r=lqdMatthias Krüger-1/+1
Fix typo MaybeUnit -> MaybeUninit
2024-04-11Rollup merge of #123738 - spastorino:reuse-lower-const-param, r=compiler-errorsMatthias Krüger-5/+6
Call lower_const_param instead of duplicating the code Follow up of #123689 r? `@oli-obk` I had this commit in my old branch that I had forgotten about, `@fmease` pointed about this in #123689 I've left the branches that are not `Range` as do nothing as that's what we are currently doing but maybe we want to err or something.
2024-04-11Call lower_const_param instead of duplicating the codeSantiago Pastorino-5/+6
2024-04-11Rollup merge of #123704 - estebank:diag-changes, r=compiler-errorsMatthias Krüger-11/+62
Tweak value suggestions in `borrowck` and `hir_analysis` Unify the output of `suggest_assign_value` and `ty_kind_suggestion`. Ideally we'd make these a single function, but doing so would likely require modify the crate dependency tree.
2024-04-11Fix small typoJanggun Lee-1/+1
2024-04-10Handle more cases of "values to suggest" given a typeEsteban Küber-0/+12
Add handling for `String`, `Box`, `Option` and `Result`.
2024-04-10Use suggest_impl_trait in return type suggestionMichael Goulet-42/+56
2024-04-10Handle more cases of value suggestionsEsteban Küber-10/+38
2024-04-10Auto merge of #121346 - m-ou-se:temp-lifetime-if-else-match, r=compiler-errorsbors-0/+13
Propagate temporary lifetime extension into if and match. This PR makes this work: ```rust let a = if true { ..; &temp() // used to error, but now gets lifetime extended } else { ..; &temp() // used to error, but now gets lifetime extended }; ``` and ```rust let a = match () { _ => { ..; &temp() // used to error, but now gets lifetime extended } }; ``` to make it consistent with: ```rust let a = { ..; &temp() // lifetime is extended }; ``` This is one small part of [the temporary lifetimes work](https://github.com/rust-lang/lang-team/issues/253). This part is backwards compatible (so doesn't need be edition-gated), because all code affected by this change previously resulted in a hard error.
2024-04-10Rollup merge of #123689 - spastorino:pattern_types_const_generics, r=oli-obkGuillaume Gomez-0/+18
Add const generics support for pattern types r? `@oli-obk`
2024-04-09Tweak value suggestions in `borrowck` and `hir_analysis`Esteban Küber-5/+16
Unify the output of `suggest_assign_value` and `ty_kind_suggestion`. Ideally we'd make these a single function, but doing so would likely require modify the crate dependency tree.
2024-04-09Handle const generic pattern typesSantiago Pastorino-0/+18
2024-04-09Clarifying commentMichael Goulet-3/+9
2024-04-09Split back out unused_lifetimes -> redundant_lifetimesMichael Goulet-2/+2
2024-04-09Lint redundant lifetimes in impl headerMichael Goulet-5/+6
2024-04-09Move check to wfcheckMichael Goulet-0/+131
2024-04-09Actually, just reuse the UNUSED_LIFETIMES lintMichael Goulet-26/+0
2024-04-09Silence some follow-up errors on trait impls in case the trait has ↵Oli Scherer-2/+8
conflicting or otherwise incoherent impls
2024-04-09Auto merge of #123631 - oli-obk:fail_slow, r=jieyouxubors-7/+4
Ensure we do not accidentally insert new early aborts in the analysis passes pulling the infallible part out into a separate function makes sure that someone needs to change the signature in order to regress this. We only want to stop compilation in the presence of errors after all analyses are done, but before we start running lints. per-item we can still stop doing work if previous queries returned errors, but that's a separate story.
2024-04-09Rollup merge of #123648 - oli-obk:pattern_types_syntax, r=compiler-errorsMatthias Krüger-1/+5
Avoid ICEing without the pattern_types feature gate fixes #123643
2024-04-08Auto merge of #122077 - oli-obk:eager_opaque_checks4, r=lcnrbors-6/+3
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-08Avoid ICEing without the `pattern_types` feature gateOli Scherer-1/+5
2024-04-08Eliminate `DefiningAnchor` now that is just a single-variant enumOli Scherer-6/+3
2024-04-08Ensure we do not accidentally insert new early aborts in the analysis passesOli Scherer-7/+4
2024-04-08Actually create ranged int types in the type system.Oli Scherer-10/+93