diff options
| author | Mahmoud Mazouz <mazouz.mahmoud@outlook.com> | 2022-11-19 18:53:36 +0100 |
|---|---|---|
| committer | Mahmoud Mazouz <mazouz.mahmoud@outlook.com> | 2022-11-19 18:53:36 +0100 |
| commit | 01f2a1542006631d6644ac767926e3bd3324f3c0 (patch) | |
| tree | 75ea4bc21157c4ef207f4bae0559cf06c9184aa2 /compiler/rustc_hir_analysis/src/structured_errors | |
| parent | 452cf4f7109f58433ac38be7d3da527408571054 (diff) | |
| download | rust-01f2a1542006631d6644ac767926e3bd3324f3c0.tar.gz rust-01f2a1542006631d6644ac767926e3bd3324f3c0.zip | |
Fix substraction with overflow in `wrong_number_of_generic_args.rs`
Rarranging the substration and equality check into an addition and an equality check is sufficient. Algebra is cool, isn't it? Co-authored-by: Michael Goulet <michael@errs.io>
Diffstat (limited to 'compiler/rustc_hir_analysis/src/structured_errors')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs index 4359124646d..9c77387c238 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs @@ -728,7 +728,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { && let Some(trait_path_segment) = path.segments.get(0) { let num_generic_args_supplied_to_trait = trait_path_segment.args().num_generic_params(); - if num_assoc_fn_excess_args == num_trait_generics_except_self - num_generic_args_supplied_to_trait { + if num_generic_args_supplied_to_trait + num_assoc_fn_excess_args == num_trait_generics_except_self + { if let Some(span) = self.gen_args.span_ext() && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { let sugg = vec