rust/compiler
bors 11432fe952 Auto merge of #102080 - yanchen4791:issue-99824-fix, r=cjgillot
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-16 07:40:56 +00:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Use tidy-alphabetical in the compiler 2022-10-12 17:49:10 +05:30
rustc_ast_lowering Rollup merge of #102998 - nathanwhit:let-chains-drop-order, r=eholk 2022-10-15 15:45:32 +05:30
rustc_ast_passes errors: AddToDiagnostic::add_to_diagnostic_with 2022-10-10 14:20:16 +01:00
rustc_ast_pretty Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
rustc_attr
rustc_borrowck Auto merge of #102080 - yanchen4791:issue-99824-fix, r=cjgillot 2022-10-16 07:40:56 +00:00
rustc_builtin_macros Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
rustc_codegen_cranelift more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_codegen_gcc Remove type argument of array_alloca and rename to byte_array_alloca 2022-10-02 13:42:14 +00:00
rustc_codegen_llvm Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki 2022-10-14 16:19:15 +05:30
rustc_codegen_ssa Auto merge of #101832 - compiler-errors:dyn-star-plus, r=eholk 2022-10-15 07:36:38 +00:00
rustc_const_eval Surround type with backticks 2022-10-15 15:28:29 +05:30
rustc_data_structures more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_driver Remove -Ztime option. 2022-10-06 15:49:44 +11:00
rustc_error_codes fix small word dupe typos 2022-10-13 00:53:46 +08:00
rustc_error_messages Add missing checks for doc(cfg_hide(...)) attribute 2022-10-14 11:29:54 +02:00
rustc_errors UPDATE - Move IntoDiagnosticArg implementations to diagnostic_impls file 2022-10-12 16:55:28 -04:00
rustc_expand more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_feature Auto merge of #102975 - Dylan-DPC:rollup-vzuwsh2, r=Dylan-DPC 2022-10-12 17:48:31 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Use tidy-alphabetical in the compiler 2022-10-12 17:49:10 +05:30
rustc_hir_analysis Auto merge of #102931 - camsteffen:inline-overlapping-impls, r=cjgillot 2022-10-16 02:05:30 +00:00
rustc_hir_pretty pretty: fix to print some lifetimes on HIR pretty-print 2022-10-15 23:34:21 +09:00
rustc_incremental Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki 2022-10-10 00:09:42 +09:00
rustc_index
rustc_infer more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_interface Use tidy-alphabetical in the compiler 2022-10-12 17:49:10 +05:30
rustc_lexer
rustc_lint more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_lint_defs more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_llvm
rustc_log
rustc_macros Get rid of rustc_query_description! 2022-10-14 22:35:56 +02:00
rustc_metadata Add suggestion to the "missing native library" error 2022-10-13 07:35:36 -04:00
rustc_middle Auto merge of #102895 - Nilstrieb:query-cleanups, r=cjgillot 2022-10-15 13:30:15 +00:00
rustc_mir_build Auto merge of #101832 - compiler-errors:dyn-star-plus, r=eholk 2022-10-15 07:36:38 +00:00
rustc_mir_dataflow Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk 2022-10-08 14:38:18 +02:00
rustc_mir_transform Rollup merge of #102778 - nbdd0121:mir, r=tmiasko 2022-10-08 14:38:19 +02:00
rustc_monomorphize Auto merge of #99324 - reez12g:issue-99144, r=jyn514 2022-10-06 03:01:57 +00:00
rustc_parse more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_parse_format Detect and reject out-of-range integers in format string literals 2022-10-01 01:05:01 +02:00
rustc_passes Rollup merge of #102954 - GuillaumeGomez:cfg-hide-attr-checks, r=Manishearth 2022-10-15 15:45:32 +05:30
rustc_plugin_impl
rustc_privacy Auto merge of #101679 - compiler-errors:rpitit-default-body, r=nikomatsakis 2022-10-12 21:03:47 +00:00
rustc_query_impl Remove the describe method from the QueryDescription trait 2022-10-14 22:35:56 +02:00
rustc_query_system Remove the describe method from the QueryDescription trait 2022-10-14 22:35:56 +02:00
rustc_resolve Rollup merge of #102884 - petrochenkov:liferib, r=cjgillot 2022-10-15 15:45:31 +05:30
rustc_save_analysis ImplItemKind::TyAlias => ImplItemKind::Type 2022-10-09 07:09:57 +00:00
rustc_serialize
rustc_session Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki 2022-10-14 16:19:15 +05:30
rustc_smir
rustc_span rename rustc_allocator_nounwind to rustc_nounwind 2022-10-11 22:47:31 +02:00
rustc_symbol_mangling more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_target more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_trait_selection Auto merge of #102931 - camsteffen:inline-overlapping-impls, r=cjgillot 2022-10-16 02:05:30 +00:00
rustc_traits Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
rustc_transmute Remove TypeckResults from InferCtxt 2022-10-07 07:06:19 -05:00
rustc_ty_utils more dupe word typos 2022-10-14 12:57:56 +08:00
rustc_type_ir