]> git.lizzy.rs Git - rust.git/commitdiff
tbh what
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Fri, 13 Nov 2020 17:56:39 +0000 (18:56 +0100)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Fri, 13 Nov 2020 17:56:39 +0000 (18:56 +0100)
compiler/rustc_typeck/src/astconv/generics.rs

index 3bfb2d3f1b0f958173bed32d9d9bd3914d1e48c2..991aabd2fafa0b8cb49a18ef34cd1233d3173903 100644 (file)
@@ -449,47 +449,37 @@ pub(crate) fn check_generic_arg_count(
 
         let mut unexpected_spans = vec![];
 
-        let mut lifetime_count_correct = Ok(());
-        if !infer_lifetimes || arg_counts.lifetimes > param_counts.lifetimes {
-            lifetime_count_correct = check_kind_count(
-                "lifetime",
-                param_counts.lifetimes,
-                param_counts.lifetimes,
-                arg_counts.lifetimes,
-                0,
-                &mut unexpected_spans,
-                explicit_late_bound == ExplicitLateBound::Yes,
-            );
-        }
+        let lifetime_count_correct = check_kind_count(
+            "lifetime",
+            if infer_lifetimes { 0 } else { param_counts.lifetimes },
+            param_counts.lifetimes,
+            arg_counts.lifetimes,
+            0,
+            &mut unexpected_spans,
+            explicit_late_bound == ExplicitLateBound::Yes,
+        );
 
         // FIXME(const_generics:defaults)
-        let mut const_count_correct = Ok(());
-        if !infer_args || arg_counts.consts > param_counts.consts {
-            const_count_correct = check_kind_count(
-                "const",
-                param_counts.consts,
-                param_counts.consts,
-                arg_counts.consts,
-                arg_counts.lifetimes + arg_counts.types,
-                &mut unexpected_spans,
-                false,
-            );
-        }
+        let mut const_count_correct = check_kind_count(
+            "const",
+            if infer_args { 0 } else { param_counts.consts },
+            param_counts.consts,
+            arg_counts.consts,
+            arg_counts.lifetimes + arg_counts.types,
+            &mut unexpected_spans,
+            false,
+        );
 
         // Note that type errors are currently be emitted *after* const errors.
-        let mut type_count_correct = Ok(());
-        if !infer_args || arg_counts.types > param_counts.types - defaults.types - has_self as usize
-        {
-            type_count_correct = check_kind_count(
-                "type",
-                param_counts.types - defaults.types - has_self as usize,
-                param_counts.types - has_self as usize,
-                arg_counts.types,
-                arg_counts.lifetimes,
-                &mut unexpected_spans,
-                false,
-            );
-        }
+        let mut type_count_correct = check_kind_count(
+            "type",
+            if infer_args { 0 } else { param_counts.types - defaults.types - has_self as usize },
+            param_counts.types - has_self as usize,
+            arg_counts.types,
+            arg_counts.lifetimes,
+            &mut unexpected_spans,
+            false,
+        );
 
         // Emit a help message if it's possible that a type could be surrounded in braces
         if let Err((c_mismatch, Some(ref mut _const_err))) = const_count_correct {