rust/compiler
Matthias Krüger c3f74bcb39
Rollup merge of #138589 - zachs18:block-label-not-supported-here-loop-body-help, r=petrochenkov
If a label is placed on the block of a loop instead of the header, suggest moving it to the header.

Fixes #138585

If a label is placed on the block of a loop instead of the header, suggest to the user moving it to the loop header instead of ~~suggesting to remove it~~ emitting a tool-only suggestion to remove it.

```rs
fn main() {
    loop 'a: { return; }
}
```

```diff
 error: block label not supported here
  --> src/main.rs:2:10
   |
 2 |     loop 'a: { return; }
   |          ^^^ not supported here
+  |
+help: if you meant to label the loop, move this label before the loop
+  |
+2 -     loop 'a: { return; }
+2 +     'a: loop { return; }
+  |
```

Questions for reviewer:

* The "desired output" in the linked issue had the main diagnostic be "misplaced loop label". Should the main diagnostic message the changed instead of leaving it as "block label not supported here"?
* Should this be `Applicability::MachineApplicable`?
2025-03-19 16:52:56 +01:00
..
rustc Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_abi Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
rustc_arena Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_ast Revert "Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu" 2025-03-18 13:28:56 +01:00
rustc_ast_ir Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
rustc_ast_lowering Auto merge of #138630 - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgr 2025-03-18 05:58:46 +00:00
rustc_ast_passes Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_ast_pretty Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_attr_data_structures Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_attr_parsing Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_baked_icu_data Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_borrowck Rollup merge of #138384 - nnethercote:hir-ItemKind-idents, r=fmease 2025-03-17 22:49:04 +01:00
rustc_builtin_macros Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_codegen_cranelift Remove implicit #[no_mangle] for #[rustc_std_internal_symbol] 2025-03-17 14:08:09 +00:00
rustc_codegen_gcc Remove implicit #[no_mangle] for #[rustc_std_internal_symbol] 2025-03-17 14:08:09 +00:00
rustc_codegen_llvm Rollup merge of #138674 - oli-obk:llvm-cleanups, r=compiler-errors 2025-03-19 08:17:19 +01:00
rustc_codegen_ssa Auto merge of #138630 - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgr 2025-03-18 05:58:46 +00:00
rustc_const_eval Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
rustc_data_structures Auto merge of #137011 - LuuuXXX:promote-ohos-with-host-tools, r=Amanieu 2025-03-16 18:42:18 +00:00
rustc_driver Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_driver_impl Auto merge of #138566 - yotamofek:pr/strip-prefix, r=nnethercote 2025-03-17 07:34:25 +00:00
rustc_error_codes Clarify "owned data" in E0515.md 2025-03-14 19:28:59 +01:00
rustc_error_messages Rollup merge of #138404 - bjorn3:sysroot_handling_cleanup, r=petrochenkov,jieyouxu 2025-03-13 11:28:35 +01:00
rustc_errors Do not suggest using -Zmacro-backtrace for builtin macros 2025-03-14 19:50:03 +00:00
rustc_expand Use strip_{prefix|suffix} instead of {starts|ends}_with+indexing 2025-03-17 07:06:10 +00:00
rustc_feature Stabilize asm_goto 2025-03-17 11:12:10 +00:00
rustc_fluent_macro Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_fs_util Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_graphviz Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_hashes Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hir Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
rustc_hir_analysis Remove existing AFIDT implementation 2025-03-18 17:35:26 +00:00
rustc_hir_pretty Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
rustc_hir_typeck Rollup merge of #138001 - meithecatte:privately-uninhabited, r=Nadrieril 2025-03-19 16:52:54 +01:00
rustc_incremental Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_index Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
rustc_index_macros Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_infer Fold visit into ty 2025-03-15 06:34:36 +00:00
rustc_interface Rollup merge of #138404 - bjorn3:sysroot_handling_cleanup, r=petrochenkov,jieyouxu 2025-03-13 11:28:35 +01:00
rustc_lexer Revert "Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu" 2025-03-18 13:28:56 +01:00
rustc_lint Rollup merge of #138001 - meithecatte:privately-uninhabited, r=Nadrieril 2025-03-19 16:52:54 +01:00
rustc_lint_defs Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_llvm Auto merge of #137011 - LuuuXXX:promote-ohos-with-host-tools, r=Amanieu 2025-03-16 18:42:18 +00:00
rustc_log Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_macros Move codec module back into middle 2025-03-15 06:42:48 +00:00
rustc_metadata Rollup merge of #138384 - nnethercote:hir-ItemKind-idents, r=fmease 2025-03-17 22:49:04 +01:00
rustc_middle Rollup merge of #138001 - meithecatte:privately-uninhabited, r=Nadrieril 2025-03-19 16:52:54 +01:00
rustc_mir_build Rollup merge of #138001 - meithecatte:privately-uninhabited, r=Nadrieril 2025-03-19 16:52:54 +01:00
rustc_mir_dataflow Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_mir_transform Rollup merge of #138670 - compiler-errors:remove-afidt, r=oli-obk 2025-03-19 08:17:18 +01:00
rustc_monomorphize Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_next_trait_solver Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
rustc_parse Revert "Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu" 2025-03-18 13:28:56 +01:00
rustc_parse_format Revert "Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu" 2025-03-18 13:28:56 +01:00
rustc_passes Auto merge of #138630 - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgr 2025-03-18 05:58:46 +00:00
rustc_pattern_analysis Rollup merge of #138001 - meithecatte:privately-uninhabited, r=Nadrieril 2025-03-19 16:52:54 +01:00
rustc_privacy Auto merge of #138630 - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgr 2025-03-18 05:58:46 +00:00
rustc_query_impl Auto merge of #137011 - LuuuXXX:promote-ohos-with-host-tools, r=Amanieu 2025-03-16 18:42:18 +00:00
rustc_query_system Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 17:59:08 +01:00
rustc_resolve resolve: Avoid some unstable iteration 2025-03-14 18:34:08 +03:00
rustc_sanitizers Squash fold into ty 2025-03-15 06:34:36 +00:00
rustc_serialize Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
rustc_session modify config.toml->bootstrap.toml for new upstream changes 2025-03-17 21:12:23 +05:30
rustc_smir Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_span Do not suggest using -Zmacro-backtrace for builtin macros 2025-03-14 19:50:03 +00:00
rustc_symbol_mangling Remove implicit #[no_mangle] for #[rustc_std_internal_symbol] 2025-03-17 14:08:09 +00:00
rustc_target Rollup merge of #138608 - heiher:issue-116344, r=RalfJung 2025-03-17 22:49:07 +01:00
rustc_trait_selection Remove existing AFIDT implementation 2025-03-18 17:35:26 +00:00
rustc_traits Rollup merge of #138394 - lcnr:yeet-variant, r=compiler-errors 2025-03-12 10:19:32 -07:00
rustc_transmute Add #[cfg(test)] for Transition in dfa 2025-03-18 07:17:16 +00:00
rustc_ty_utils Remove existing AFIDT implementation 2025-03-18 17:35:26 +00:00
rustc_type_ir Suppress must_use in compiler and tools 2025-03-16 17:47:57 +00:00
rustc_type_ir_macros Fold visit into ty 2025-03-15 06:34:36 +00:00
stable_mir Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00