rust/compiler
Matthias Krüger b23655893e
Rollup merge of #132498 - uellenberg:typo-and-let-suggestions, r=estebank
Suggest fixing typos and let bindings at the same time

Fixes #132483

Currently, a suggestion for adding a let binding won't be shown if we suggest fixing a typo. This changes that behavior to always show both, if possible. Essentially, this turns the suggestion from
```rust
error[E0425]: cannot find value `x2` in this scope
 --> src/main.rs:4:5
  |
4 |     x2 = 2;
  |     ^^ help: a local variable with a similar name exists: `x1`

For more information about this error, try `rustc --explain E0425`.
```

to
```rust
error[E0425]: cannot find value `x2` in this scope
 --> src/main.rs:4:5
  |
4 |     x2 = 2;
  |     ^^
  |
help: a local variable with a similar name exists
  |
4 |     x1 = 2;
  |     ~~
help: you might have meant to introduce a new binding
  |
4 |     let x2 = 2;
  |     +++

For more information about this error, try `rustc --explain E0425`.
```

for the following code:
```rust
fn main() {
    let x1 = 1;
    x2 = 2;
}
```

The original behavior only shows the suggestion for a let binding if a typo suggestion wasn't already displayed. However, this falls apart in the cases like the one above where we have multiple similar variables. I don't think it makes sense to hide this suggestion if there's a similar variable, since that defeats the purpose of this suggestion in that case (it's meant to help those coming from languages like Python).
2024-11-05 20:10:50 +01:00
..
rustc
rustc_abi compiler: Lift rustc_target::spec::abi::Abi to rustc_abi::ExternAbi 2024-10-30 22:38:49 -07:00
rustc_arena move strict provenance lints to new feature gate, remove old feature gates 2024-10-21 15:22:17 +01:00
rustc_ast Do not format generic consts 2024-11-02 20:25:06 +00:00
rustc_ast_ir Add sugar for &pin (const|mut) types 2024-10-07 11:15:04 -07:00
rustc_ast_lowering Encode cross-crate opaque type origin 2024-10-31 01:35:13 +00:00
rustc_ast_passes Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
rustc_ast_pretty fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
rustc_attr remove support for extern-block const intrinsics 2024-11-04 23:27:45 +01:00
rustc_baked_icu_data
rustc_borrowck Auto merge of #132580 - compiler-errors:globs, r=Noratrieb 2024-11-05 08:30:56 +00:00
rustc_builtin_macros Auto merge of #131284 - dingxiangfei2009:rename-smart-ptr-to-coerce-referent, r=compiler-errors 2024-10-27 17:04:12 +00:00
rustc_codegen_cranelift Auto merge of #132526 - bjorn3:sync_cg_clif-2024-11-02, r=bjorn3 2024-11-03 05:03:52 +00:00
rustc_codegen_gcc Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee 2024-11-05 16:25:45 +00:00
rustc_codegen_llvm Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwco 2024-11-05 20:10:49 +01:00
rustc_codegen_ssa Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee 2024-11-05 16:25:45 +00:00
rustc_const_eval when an intrinsic has a const-stable fallback body, we can easily expose it on stable 2024-11-04 23:27:46 +01:00
rustc_data_structures Replace an FTP link in comments with an equivalent HTTPS link 2024-10-24 17:02:11 +11:00
rustc_driver
rustc_driver_impl make time format parsing compiletime 2024-11-03 15:51:39 +03:00
rustc_error_codes Reject generic self types. 2024-10-30 10:48:08 +00:00
rustc_error_messages Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustc_errors Rename target triple to target tuple in many places in the compiler 2024-11-02 21:29:59 +01:00
rustc_expand Rollup merge of #132332 - nnethercote:use-token_descr-more, r=estebank 2024-10-30 06:40:36 +01:00
rustc_feature add new rustc_const_stable_intrinsic attribute for const-stable intrinsics 2024-11-04 23:27:46 +01:00
rustc_fluent_macro use tracked_path in rustc_fluent_macro 2024-10-19 22:32:38 +08:00
rustc_fs_util Couple of changes to make it easier to compile rustc for wasm 2024-09-26 19:51:14 +00:00
rustc_graphviz Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustc_hir Rollup merge of #132423 - RalfJung:const-eval-align-offset, r=dtolnay 2024-11-03 20:08:13 -08:00
rustc_hir_analysis Auto merge of #132580 - compiler-errors:globs, r=Noratrieb 2024-11-05 08:30:56 +00:00
rustc_hir_pretty compiler: Switch to rustc_abi in hir_pretty, lint_defs, and mir_build 2024-10-30 22:38:49 -07:00
rustc_hir_typeck Auto merge of #132580 - compiler-errors:globs, r=Noratrieb 2024-11-05 08:30:56 +00:00
rustc_incremental replace manual time convertions with std ones 2024-11-03 15:51:39 +03:00
rustc_index Rollup merge of #130625 - heiseish:issue-124028-fix, r=jieyouxu 2024-10-10 12:49:18 +02:00
rustc_index_macros Remove 'apostrophes' from rustc_parse_format 2024-10-14 23:22:51 +02:00
rustc_infer ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
rustc_interface Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwco 2024-11-05 20:10:49 +01:00
rustc_lexer Reserve guarded string literals (RFC 3593) 2024-10-08 18:21:16 -06:00
rustc_lint ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
rustc_lint_defs compiler: Switch to rustc_abi in hir_pretty, lint_defs, and mir_build 2024-10-30 22:38:49 -07:00
rustc_llvm Auto merge of #132555 - matthiaskrgr:rollup-2d79661, r=matthiaskrgr 2024-11-03 13:46:47 +00:00
rustc_log Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustc_macros give a better error for tuple structs in derive(Diagnostic) 2024-10-27 21:23:28 -04:00
rustc_metadata ty::KContainer -> ty::AssocItemContainer::K 2024-11-04 04:45:52 +00:00
rustc_middle Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee 2024-11-05 16:25:45 +00:00
rustc_mir_build Auto merge of #132580 - compiler-errors:globs, r=Noratrieb 2024-11-05 08:30:56 +00:00
rustc_mir_dataflow compiler: Remove unused rustc_target from Cargo.tomls 2024-11-03 13:38:47 -08:00
rustc_mir_transform compiler: Directly use rustc_abi in mir_transform 2024-11-03 13:38:47 -08:00
rustc_monomorphize compiler: Add rustc_abi to _monomorphize 2024-11-02 20:31:47 -07:00
rustc_next_trait_solver Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
rustc_parse Revert "Avoid nested replacement ranges" from #129346. 2024-11-04 15:57:35 +11:00
rustc_parse_format Remove 'apostrophes' from rustc_parse_format 2024-10-14 23:22:51 +02:00
rustc_passes remove support for extern-block const intrinsics 2024-11-04 23:27:45 +01:00
rustc_pattern_analysis compiler: Remove unused rustc_target from Cargo.tomls 2024-11-03 13:38:47 -08:00
rustc_privacy Merge HostPolarity and BoundConstness 2024-10-30 16:23:16 +00:00
rustc_query_impl Handle rustc_query_impl cases of rustc::potential_query_instability lint 2024-10-03 12:47:08 +03:00
rustc_query_system replace manual time convertions with std ones 2024-11-03 15:51:39 +03:00
rustc_resolve Suggest fixing typos and let bindings at the same time 2024-11-02 14:40:37 -07:00
rustc_sanitizers compiler: Add rustc_abi to _sanitizers 2024-11-02 20:31:47 -07:00
rustc_serialize Fix explicit_iter_loop in rustc_serialize 2024-10-16 15:44:16 +02:00
rustc_session Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwco 2024-11-05 20:10:49 +01:00
rustc_smir ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
rustc_span add new rustc_const_stable_intrinsic attribute for const-stable intrinsics 2024-11-04 23:27:46 +01:00
rustc_symbol_mangling ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
rustc_target Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee 2024-11-05 16:25:45 +00:00
rustc_trait_selection Auto merge of #132580 - compiler-errors:globs, r=Noratrieb 2024-11-05 08:30:56 +00:00
rustc_traits TypingMode 🤔 2024-10-29 17:01:24 +01:00
rustc_transmute Rollup merge of #132255 - workingjubilee:layout-is-🏚️, r=compiler-errors 2024-10-28 10:18:50 -07:00
rustc_ty_utils ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
rustc_type_ir Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
rustc_type_ir_macros do not relate Abi and Safety 2024-10-22 23:13:04 +02:00
stable_mir Rollup merge of #132085 - celinval:update-smir-doc, r=compiler-errors 2024-10-24 23:23:55 -07:00