rust/compiler
Michael Goulet 7e5528fa55
Rollup merge of #125795 - lucasscharenbroch:undescore-prefix-suggestion, r=compiler-errors
Improve renaming suggestion for names with leading underscores

Fixes #125650

Before:
```
error[E0425]: cannot find value `p` in this scope
 --> test.rs:2:13
  |
2 |     let _ = p;
  |             ^
  |
help: a local variable with a similar name exists, consider renaming `_p` into `p`
  |
1 | fn a(p: i32) {
  |      ~
```

After:
```
error[E0425]: cannot find value `p` in this scope
 --> test.rs:2:13
  |
1 | fn a(_p: i32) {
  |      -- `_p` defined here
2 |     let _ = p;
  |             ^
  |
help: the leading underscore in `_p` marks it as unused, consider renaming it to `p`
  |
1 | fn a(p: i32) {
  |      ~
```

This change doesn't exactly conform to what was proposed in the issue:

1. I've kept the suggested code instead of solely replacing it with the label
2. I've removed the "...similar name exists..." message instead of relocating to the usage span
3. You could argue that it still isn't completely clear that the change is referring to the definition (not the usage), but I'm not sure how to do this without playing down the fact that the error was caused by the usage of an undefined name.
2024-06-04 08:52:13 -04:00
..
rustc Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=... 2024-05-02 19:48:29 +02:00
rustc_abi don't inhibit random field reordering on repr(packed(1)) 2024-05-21 19:22:04 +02:00
rustc_arena rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
rustc_ast Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
rustc_ast_ir Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
rustc_ast_lowering Rollup merge of #125790 - WaffleLapkin:no-tail-recomputation-in-lower-stmts, r=lcnr 2024-05-31 08:50:24 +02:00
rustc_ast_passes Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
rustc_ast_pretty Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
rustc_attr Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
rustc_baked_icu_data Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_borrowck Rollup merge of #125667 - oli-obk:taintify, r=TaKO8Ki 2024-06-04 08:52:12 -04:00
rustc_builtin_macros Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkov 2024-05-23 07:41:18 +02:00
rustc_codegen_cranelift Auto merge of #122597 - pacak:master, r=bjorn3 2024-06-04 00:05:56 +00:00
rustc_codegen_gcc Uplift TypeRelation and Relate 2024-06-01 12:50:58 -04:00
rustc_codegen_llvm Rollup merge of #125311 - calebzulawski:repr-packed-simd-intrinsics, r=workingjubilee 2024-06-02 05:06:47 -07:00
rustc_codegen_ssa Rollup merge of #125750 - compiler-errors:expect, r=lcnr 2024-06-04 08:25:48 +01:00
rustc_const_eval Opt-in diagnostics reporting to avoid doing extra work in the new solver 2024-06-03 09:27:52 -04:00
rustc_data_structures Apply x clippy --fix and x fmt 2024-05-30 09:51:27 +08:00
rustc_driver Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_driver_impl Handle no values cfg with --print=check-cfg 2024-06-02 11:49:28 +02:00
rustc_error_codes Rename HIR TypeBinding to AssocItemConstraint and related cleanup 2024-05-30 22:52:33 +02:00
rustc_error_messages Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote 2024-05-27 08:44:12 +00:00
rustc_errors Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote 2024-05-27 08:44:12 +00:00
rustc_expand Rollup merge of #125530 - SparrowLii:expand2, r=petrochenkov 2024-05-27 13:10:35 +02:00
rustc_feature Rollup merge of #124486 - beetrees:vectorcall-tracking-issue, r=ehuss 2024-06-04 08:25:46 +01:00
rustc_fluent_macro Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_fs_util Stabilize std::path::absolute 2024-04-24 14:35:02 +00:00
rustc_graphviz Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_hir Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk 2024-05-31 10:12:24 +00:00
rustc_hir_analysis Rollup merge of #125667 - oli-obk:taintify, r=TaKO8Ki 2024-06-04 08:52:12 -04:00
rustc_hir_pretty Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
rustc_hir_typeck Rollup merge of #125750 - compiler-errors:expect, r=lcnr 2024-06-04 08:25:48 +01:00
rustc_incremental Run rustfmt on files that need it. 2024-05-24 15:17:21 +10:00
rustc_index Simplify static_assert_sizes. 2024-04-18 15:36:25 +10:00
rustc_index_macros rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
rustc_infer Align Term methods with GenericArg methods 2024-06-03 20:36:27 -04:00
rustc_interface check_is_object_safe -> is_object_safe 2024-06-03 09:49:30 -04:00
rustc_lexer Improved the compiler code with clippy 2024-04-24 09:41:44 +02:00
rustc_lint Rollup merge of #125750 - compiler-errors:expect, r=lcnr 2024-06-04 08:25:48 +01:00
rustc_lint_defs Make WHERE_CLAUSES_OBJECT_SAFETY a regular object safety violation 2024-06-03 09:49:04 -04:00
rustc_llvm thinlto: only build summary file if needed 2024-05-23 14:58:30 -04:00
rustc_log remove tracing tree indent lines 2024-05-30 15:26:48 +02:00
rustc_macros Nits and formatting 2024-06-03 10:02:08 -04:00
rustc_metadata Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk 2024-05-31 10:12:24 +00:00
rustc_middle Rollup merge of #125750 - compiler-errors:expect, r=lcnr 2024-06-04 08:25:48 +01:00
rustc_mir_build Rollup merge of #125756 - Zalathar:branch-on-bool, r=oli-obk 2024-05-31 17:05:24 +02:00
rustc_mir_dataflow Remove #[macro_use] extern crate tracing from rustc_mir_dataflow. 2024-05-23 18:02:40 +10:00
rustc_mir_transform Auto merge of #122597 - pacak:master, r=bjorn3 2024-06-04 00:05:56 +00:00
rustc_monomorphize Don't eagerly monomorphize drop for types that are impossible to instantiate 2024-05-24 21:53:39 -04:00
rustc_next_trait_solver Uplift binder 2024-05-21 17:00:45 -04:00
rustc_parse Avoid checking the edition as much as possible 2024-06-02 09:42:21 +02:00
rustc_parse_format Apply x clippy --fix and x fmt 2024-05-30 09:51:27 +08:00
rustc_passes Opt-in diagnostics reporting to avoid doing extra work in the new solver 2024-06-03 09:27:52 -04:00
rustc_pattern_analysis remove tracing tree indent lines 2024-05-30 15:26:48 +02:00
rustc_privacy Make body_owned_by return the body directly. 2024-05-29 10:04:08 +00:00
rustc_query_impl Remove extern crate rustc_middle from rustc_query_impl. 2024-05-13 08:20:18 +10:00
rustc_query_system Add a footer in FileEncoder and check for it in MemDecoder 2024-05-21 20:12:29 -04:00
rustc_resolve Rollup merge of #125795 - lucasscharenbroch:undescore-prefix-suggestion, r=compiler-errors 2024-06-04 08:52:13 -04:00
rustc_sanitizers check_is_object_safe -> is_object_safe 2024-06-03 09:49:30 -04:00
rustc_serialize Apply x clippy --fix and x fmt 2024-05-30 09:51:27 +08:00
rustc_session coverage: Add CLI support for -Zcoverage-options=condition 2024-05-30 15:38:46 +10:00
rustc_smir Add an intrinsic for ptr::metadata 2024-05-28 09:28:51 -07:00
rustc_span Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk 2024-05-31 10:12:24 +00:00
rustc_symbol_mangling Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
rustc_target Rollup merge of #117671 - kjetilkjeka:nvptx_c_abi_avoid_direct, r=davidtwco 2024-05-28 18:04:31 +02:00
rustc_trait_selection Rollup merge of #125717 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors 2024-06-04 08:52:12 -04:00
rustc_traits Align Term methods with GenericArg methods 2024-06-03 20:36:27 -04:00
rustc_transmute Align: add bytes_usize and bits_usize 2024-05-01 15:57:33 +02:00
rustc_ty_utils Uplift TypeRelation and Relate 2024-06-01 12:50:58 -04:00
rustc_type_ir Uplift TypeRelation and Relate 2024-06-01 12:50:58 -04:00
rustc_type_ir_macros Uplift TraitPredicate 2024-05-11 18:20:00 -04:00
stable_mir Apply x clippy --fix and x fmt 2024-05-30 09:51:27 +08:00