1
Fork 0
rust/compiler/rustc_hir/src
Matthias Krüger bfe032334f
Rollup merge of #126054 - veera-sivarajan:bugfix-113073-bound-on-generics-2, r=fee1-dead
`E0229`: Suggest Moving Type Constraints to Type Parameter Declaration

Fixes #113073

This PR suggests  `impl<T: Bound> Trait<T> for Foo` when finding `impl Trait<T: Bound> for Foo`. Tangentially, it also improves a handful of other error messages.

It accomplishes this in two steps:
1. Check if constrained arguments and parameter names appear in the same order and delay emitting "incorrect number of generic arguments" error because it can be confusing for the programmer to see `0 generic arguments provided` when there are `n` constrained generic arguments.

2. Inside `E0229`, suggest declaring the type parameter right after the `impl` keyword by finding the relevant impl block's span for type parameter declaration. This also handles lifetime declarations correctly.

Also, the multi part suggestion doesn't use the fluent error mechanism because translating all the errors to fluent style feels outside the scope of this PR. I will handle it in a separate PR if this gets approved.
2024-06-14 12:23:36 +02:00
..
arena.rs Remove unused arena kinds in rustc_hir and rustc_middle. 2023-11-20 15:05:26 +11:00
def.rs Add safe/unsafe to static inside extern blocks 2024-06-04 14:19:43 -03:00
def_path_hash_map.rs Do not store stable crate id in on-disk hash map. 2023-12-24 17:22:48 +00:00
definitions.rs Remove extern crate tracing from numerous crates. 2024-04-30 16:47:49 +10:00
diagnostic_items.rs Replace some instances of FxHashMap/FxHashSet with stable alternatives (mostly in rustc_hir and rustc_ast_lowering) 2023-12-18 21:03:32 +01:00
hir.rs Rollup merge of #126054 - veera-sivarajan:bugfix-113073-bound-on-generics-2, r=fee1-dead 2024-06-14 12:23:36 +02:00
hir_id.rs Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
intravisit.rs Revert "Create const block DefIds in typeck instead of ast lowering" 2024-06-07 08:33:58 +00:00
lang_items.rs LangItem-ify Coroutine trait in solvers 2024-06-13 09:34:28 -04:00
lib.rs Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
pat_util.rs Rename BindingAnnotation to BindingMode 2024-04-17 09:34:39 -04:00
stable_hash_impls.rs Revert "Cache whether a body has inline consts" 2024-06-07 08:33:58 +00:00
target.rs Change DefKind::Static to a struct variant 2024-03-12 05:53:46 +00:00
tests.rs Construct SourceMap at the same time as SessionGlobals. 2024-04-16 13:02:53 +10:00
weak_lang_items.rs Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00