Skip to content

Commit 01f2a15

Browse files
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 <[email protected]>
1 parent 452cf4f commit 01f2a15

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
728728
&& let Some(trait_path_segment) = path.segments.get(0) {
729729
let num_generic_args_supplied_to_trait = trait_path_segment.args().num_generic_params();
730730

731-
if num_assoc_fn_excess_args == num_trait_generics_except_self - num_generic_args_supplied_to_trait {
731+
if num_generic_args_supplied_to_trait + num_assoc_fn_excess_args == num_trait_generics_except_self
732+
{
732733
if let Some(span) = self.gen_args.span_ext()
733734
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
734735
let sugg = vec![

0 commit comments

Comments
 (0)