]> git.lizzy.rs Git - rust.git/commitdiff
Correct passing of `generic_args` to `create_substs_for_generic_args`
authorvarkor <github@varkor.com>
Tue, 21 Jan 2020 20:46:21 +0000 (20:46 +0000)
committervarkor <github@varkor.com>
Sat, 22 Feb 2020 00:27:44 +0000 (00:27 +0000)
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/method/confirm.rs

index 5c9178ff66d155e9cfdaed25d78841a4bdce1473..a1440c3e2895cc70f9c6f4462bb2d0132aa940b9 100644 (file)
@@ -693,7 +693,14 @@ fn create_substs_for_ast_path<'a>(
             self_ty.is_some(),
             self_ty,
             // Provide the generic args, and whether types should be inferred.
-            |_| (Some(generic_args), infer_args),
+            |did| {
+                if did == def_id {
+                    (Some(generic_args), infer_args)
+                } else {
+                    // The last component of this tuple is unimportant.
+                    (None, false)
+                }
+            },
             // Provide substitutions for parameters for which (valid) arguments have been provided.
             |param, arg| match (&param.kind, arg) {
                 (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
index 17842be9a43922a567093aa6e14bf0961ee05eb8..04cbee8c94061ac77e946e285b09591759deb85a 100644 (file)
@@ -314,9 +314,14 @@ fn instantiate_method_substs(
             false,
             None,
             // Provide the generic args, and whether types should be inferred.
-            |_| {
-                // The last argument of the returned tuple here is unimportant.
-                if let Some(ref data) = seg.args { (Some(data), false) } else { (None, false) }
+            |def_id| {
+                // The last component of the returned tuple here is unimportant.
+                if def_id == pick.item.def_id {
+                    if let Some(ref data) = seg.args {
+                        return (Some(data), false);
+                    }
+                }
+                (None, false)
             },
             // Provide substitutions for parameters for which (valid) arguments have been provided.
             |param, arg| match (&param.kind, arg) {