about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2022-11-04Rollup merge of #103780 - compiler-errors:bound-closure-lifetimes, r=jackh726Matthias Krüger-35/+94
Fix late-bound lifetime closure ICEs in HIR typeck and MIR borrowck During HIR typeck, we need to teach astconv to treat late-bound regions within a closure body as free, fixing escaping bound vars ICEs in both of the issues below. However, this then gets us to MIR borrowck, which itself needs to be taught how to instantiate free region vids for late-bound regions that come from items that _aren't_ the typeck root (for now, just closures). Fixes #103771 Fixes #103736
2022-11-02Use TraitEngine lessMichael Goulet-35/+27
2022-11-01Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwcoManish Goregaokar-1/+1
Change #[suggestion_*] attributes to use style="..." As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter. It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all. Best reviewed commit-by-commit, there's a bit of noise in there. cc #100717 `@compiler-errors` r? `@davidtwco`
2022-11-01Auto merge of #103590 - compiler-errors:ocx-more, r=lcnrbors-23/+18
(almost) Always use `ObligationCtxt` when dealing with canonical queries Hope this is a step in the right direction. cc rust-lang/types-team#50. r? `@lcnr`
2022-10-31Add bug! back to late_bound_vars queryMichael Goulet-0/+4
2022-10-31Make external/local late-bound region registration more explicitMichael Goulet-25/+68
2022-10-31Collect late-bound regions from all closure parents in `closure_mapping`Michael Goulet-40/+44
2022-10-31Create NLL infer vars for late-bound regions from closuresMichael Goulet-27/+35
2022-10-29Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errorsGuillaume Gomez-1/+1
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions` This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3 r? `@compiler-errors`
2022-10-28Remove #![allow(rustc::potential_query_instability)] from rustc_inferCastilloDel-4/+4
Change reported_violations to use IndexSet It is being used to iterate and to insert, without a lot of lookups so hopefully it won't be a perf hit Change MiniGraph.nodes to use IndexSet It is being used to iterate and to insert, without performing lookups so hopefully it won't be a perf hit Change RegionConstraintData.givens to a FxIndexSet This might result in a perf hit. Remove was being used in `givens`, and `FxIndexSet` doesn't allow calling remove without losing the fixed iteration order. So it was necessary to change remove to `shift_remove`, but this method is slower. Change OpaqueTypesVisitor to use stable sets and maps This could also be a perf hit. Make TraitObject visitor use a stable set
2022-10-28Rollup merge of #103641 - compiler-errors:issue-103624, r=cjgillotMatthias Krüger-52/+53
Don't carry MIR location in `ConstraintCategory::CallArgument` It turns out that `ConstraintCategory::CallArgument` cannot just carry a MIR location in it, since we may bubble them up to totally different MIR bodies. So instead, revert the commit a6b5f95fb028f9feb4a2957c06b35035be2c6155, and instead just erase regions from the original `Option<Ty<'tcx>>` that it carried, so that it doesn't ICE with the changes in #103220. Best reviewed in parts -- the first is just a revert, and the second is where the meaningful changes happen. Fixes #103624
2022-10-27Erase regions from CallArgument, add test + blessMichael Goulet-1/+1
2022-10-27Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"Michael Goulet-52/+53
This reverts commit a6b5f95fb028f9feb4a2957c06b35035be2c6155.
2022-10-27(almost) Always use ObligationCtxt when dealing with canonical queriesMichael Goulet-23/+18
2022-10-27Rollup merge of #103255 - oli-obk:opaque_wrong_eq_relation, r=compiler-errorsMatthias Krüger-23/+10
Clean up hidden type registration work on https://github.com/rust-lang/rust/issues/101186 Actually passing down the relation and using it instead of `eq` for the hidden type comparison has *no* effect whatsoever and allows for no further improvements at the call sites. I decided the increased complexity was not worth it and thus did not include that change in this PR. r? `@compiler-errors`
2022-10-27Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functionsMaybe Waffle-1/+1
Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions`
2022-10-26Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]Xiretza-1/+1
Using the following command: find compiler/ -type f -name '*.rs' -exec perl -i -gpe \ 's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \ '{}' +
2022-10-25Use the general type API instead of directly accessing register_hidden_typeOli Scherer-8/+6
2022-10-25Pull opaque type handling out of the type relating delegateOli Scherer-15/+4
2022-10-25Rollup merge of #103382 - compiler-errors:anon-apit-lt-region-ice, r=cjgillotYuki Okushi-8/+92
Don't ICE when reporting borrowck errors involving regions from `anonymous_lifetime_in_impl_trait` The issue here is that when we have: ``` trait Trait<'a> { .. } fn foo(arg: impl Trait) { .. } ``` The anonymous lifetime `'_` that we generate for `arg: impl Trait` doesn't end up in the argument type (which is a param) but in a where-clause of the function, in a predicate whose self type is that param ty. Fixes #101660 r? ``@cjgillot``
2022-10-23Migrate all diagnosticsNilstrieb-19/+19
2022-10-22Don't ICE on regions from anonymous_lifetime_in_impl_traitMichael Goulet-8/+92
2022-10-20Add context to compiler error messageb4den-1/+1
Changed `creates a temporary which is freed while still in use` to `creates a temporary value which is freed while still in use`
2022-10-20Auto merge of #103290 - matthiaskrgr:rollup-ngozai3, r=matthiaskrgrbors-2/+9
Rollup of 6 pull requests Successful merges: - #103197 (Stabilize proc_macro::Span::source_text) - #103251 (Fix item declaration highlighting) - #103262 (Adjusting test to needs-unwind, with linking issue) - #103268 (rustdoc: remove no-op CSS `nav.sub { font-size: 1rem }`) - #103272 (Remove extra spaces in docs) - #103276 (Erase regions before checking for `Default` in uninitialized binding error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-20Rollup merge of #103276 - compiler-errors:default-on-uninit-ice, r=TaKO8KiMatthias Krüger-2/+9
Erase regions before checking for `Default` in uninitialized binding error Fixes #103250
2022-10-20Auto merge of #103220 - compiler-errors:deny-infers, r=lcnrbors-53/+52
Deny hashing ty/re/ct inference variables cc `@cjgillot` and https://github.com/rust-lang/rust/pull/102695#issuecomment-1275706528 r? `@lcnr` best reviewed one commit at a time, mostly because the second commit that fixes `ClosureOutlivesRequirement` is mostly noise because of losing its `<'tcx>` lifetime parameter.
2022-10-20Auto merge of #102417 - oli-obk:opaque_lifetimes2, r=jackh726bors-1/+1
Require lifetime bounds for opaque types in order to allow hidden types to capture said lifetimes fixes #96996 cc `@aliemjay`
2022-10-19Erase regions before checking for default in uninitialized binding errorMichael Goulet-2/+9
2022-10-19Make ClosureOutlivesRequirement not rely on an unresolved typeMichael Goulet-53/+52
2022-10-17mir constants: type traversing bye byelcnr-24/+2
2022-10-16Auto merge of #102080 - yanchen4791:issue-99824-fix, r=cjgillotbors-134/+45
Fix missing explanation of where the borrowed reference is used when the same borrow occurs multiple times due to loop iterations Fix #99824. Problem of the issue: If a borrow occurs in a loop, the borrowed reference could be invalidated at the same place at next iteration of the loop. When this happens, the point where the borrow occurs is the same as the intervening point that might invalidate the reference in the loop. This causes a problem for the current code finding the point where the resulting reference is used, so that the explanation of the cause will be missing. As the second point of "explain all errors in terms of three points" (see [leveraging intuition framing errors in terms of points"](https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points), this explanation is very helpful for user to understand the error. In the current implementation, the searching region for finding the location where the borrowed reference is used is limited to between the place where the borrow occurs and the place where the reference is invalidated. If those two places happen to be the same, which indicates that the borrow and invalidation occur at the same place in a loop, the search will fail. One solution to the problem is when these two places are the same, find the terminator of the loop, and then use the location of the loop terminator instead of the location of the borrow for the region to find the place where the borrowed reference is used.
2022-10-14Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8KiDylan DPC-1/+1
More dupe word typos I only picked those changes (from the regex search) that I am pretty certain doesn't change meaning and is just a typo fix. Do correct me if any fix is undesirable and I can revert those. Thanks.
2022-10-14Require lifetime bounds for opaque types in order to allow hidden types to ↵Oli Scherer-1/+1
capture said lifetimes
2022-10-14more dupe word typosRageking8-1/+1
2022-10-13Auto merge of #102700 - oli-obk:0xDEAD_TAIT, r=compiler-errorsbors-257/+7
Check hidden types in dead code fixes #99490 r? `@compiler-errors` best reviewed commit by commit
2022-10-12Rollup merge of #102187 - b-naber:inline-const-source-info, r=eholkDylan DPC-0/+9
Use correct location for type tests in promoted constants Previously we forgot to remap the location in a type test collected when visiting the body of a promoted constant back to the usage location, causing an ICE when trying to get span information for that type test. Fixes https://github.com/rust-lang/rust/issues/102117
2022-10-08Rollup merge of #99818 - aliemjay:fix-closure-normalize, r=jackh726Michael Howell-58/+15
don't ICE when normalizing closure input tys We were ICEing while rendering diagnostics because `universe_causes` is expected to track every universe created in the typeck's infcx. `normalize_and_add_constraints` doesn't update `universe_causes` when creating new universes, causing an ICE. Remove it! Add spans to better track normalization constraints. Fix couple places where `universe_causes` is not updated correctly to track newly added universes. Fixes #102800 ~Fixess #99665~ (UPDATE: no longer true; the issue has a different failure path than when this PR was created and should be fixed by #101708, but the changes in this PR are still correct and should prevent potential future ICEs)
2022-10-08Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obkMatthias Krüger-10/+89
Remove `mir::CastKind::Misc` As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast. r? ````@oli-obk````
2022-10-08don't ICE when normalizing closure input tysAli MJ Al-Nasrawy-58/+15
`normalize_and_add_constraints` doesn't add entries in `universe_causes` when creating new universes, causing an ICE. Remove it! Add spans to track normalization constraints. Fix couple places where `universe_causes` is not updated correctly to track newly added universes.
2022-10-07Remap hidden types from typeck before storing them in the TypeckResultOli Scherer-1/+1
2022-10-07Move ReverseMapper logic onto OpaqueHiddenTypeOli Scherer-233/+7
2022-10-07Remove some dead codeOli Scherer-25/+1
2022-10-07Change InferCtxtBuilder from enter to buildCameron Steffen-174/+133
2022-10-07Remove TypeckResults from InferCtxtCameron Steffen-43/+43
2022-10-07Introduce TypeErrCtxtCameron Steffen-36/+34
TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't need to.
2022-10-06Remove `mir::CastKind::Misc`ouz-a-10/+89
2022-10-06Auto merge of #99324 - reez12g:issue-99144, r=jyn514bors-3/+3
Enable doctests in compiler/ crates Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-04It's not about types or consts, but the lack of regionsOli Scherer-1/+1
2022-10-02Remove 'E0312' from 'compile_fail,E0312' statement temporarilyreez12g-3/+3
2022-09-29Generate synthetic impl region even in closure body in associated fnMichael Goulet-5/+3