New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Function argument type inference with associated type impl trait #16769
Conversation
@@ -1055,10 +1055,10 @@ impl<'a> TyLoweringContext<'a> { | |||
|
|||
fn assoc_type_bindings_from_type_bound( | |||
&'a self, | |||
bound: &'a TypeBound, | |||
bound: &'a Interned<TypeBound>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the argument type into Interned
for faster equality comparision
.with_type_param_mode(ParamLoweringMode::Variable); | ||
let ctx = if let GenericDefId::FunctionId(_) = def { | ||
TyLoweringContext::new(db, &resolver, def.into()) | ||
.with_impl_trait_mode(ImplTraitLoweringMode::Variable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl Trait
s that appear in the function arguments should be handled as generic parameters with trait implementation predicates. So, we handle impl Trait
by the same way with the type parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should just require the modes to specified in the new
constructor. Feels like an easy to cause bug by relying on a default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be better. Actually, I've been considering giving a shot for #16584 while writing this PR and that would require some changes to lower.rs
. It would be good to apply your suggestions while making that changes
.with_type_param_mode(ParamLoweringMode::Variable); | ||
let ctx = if let GenericDefId::FunctionId(_) = def { | ||
TyLoweringContext::new(db, &resolver, def.into()) | ||
.with_impl_trait_mode(ImplTraitLoweringMode::Variable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should just require the modes to specified in the new
constructor. Feels like an easy to cause bug by relying on a default.
Thanks! |
☀️ Test successful - checks-actions |
Fixes #15412