Skip to content

Commit 35248cf

Browse files
committed
Fixed issue with partial trait matches for automatic trait implementation inference
1 parent bbf1e8b commit 35248cf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Diff for: src/resolve/expr/call/mod.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@ pub fn call_callee(
9595
continue;
9696
};
9797

98-
// NOTE: PERFORMANCE: TODO: This could probably be optimized
98+
// TODO: PERFORMANCE: Optimize this and remove unnecessary cloning.
99+
// We should really change `match_type` and friends to produce a type match solution
100+
// instead of modifying the poly catalog.
99101
let from_env = caller.impl_params.params.iter().filter(|(_, param_trait)| {
100-
if catalog
102+
let mut catalog_plus_match = catalog.clone();
103+
104+
if catalog_plus_match
101105
.match_types(ctx, &expected_trait.args, &param_trait.args)
102106
.is_err()
103107
{
@@ -108,7 +112,12 @@ pub fn call_callee(
108112
.resolver()
109113
.resolve_trait(expected_trait)
110114
.map_or(false, |expected_trait| {
111-
param_trait.trait_ref == expected_trait.trait_ref
115+
if param_trait.trait_ref == expected_trait.trait_ref {
116+
catalog = catalog_plus_match;
117+
true
118+
} else {
119+
false
120+
}
112121
})
113122
});
114123

0 commit comments

Comments
 (0)