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
REF: Don't insert default type parameters by Implement Member actions #6896
Conversation
@mchernyavsky could you resolve merge conflicts? |
5e6a1c6
to
b62cb22
Compare
@Undin Done. |
I wonder if |
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.
The current implementation doesn't work with type aliases. For example, for the following code:
mod bar {
use std::collections::hash_map::RandomState;
pub(crate) type HashMap<T, K = i32, S = RandomState> = std::collections::HashMap<T, K, S>;
}
trait Foo {
fn foo() -> bar::HashMap<String>;
}
impl Foo for i32 {
}
Implement memebers
produces
use crate::bar::HashMap;
mod bar {
use std::collections::hash_map::RandomState;
pub(crate) type HashMap<T, K = i32, S = RandomState> = std::collections::HashMap<T, K, S>;
}
trait Foo {
fn foo() -> bar::HashMap<String>;
}
impl Foo for i32 {
fn foo() -> HashMap<String, i32, RandomState> {
unimplemented!()
}
}
although I expect
use crate::bar::HashMap;
mod bar {
use std::collections::hash_map::RandomState;
pub(crate) type HashMap<T, K = i32, S = RandomState> = std::collections::HashMap<T, K, S>;
}
trait Foo {
fn foo() -> bar::HashMap<String>;
}
impl Foo for i32 {
fn foo() -> HashMap<String> {
unimplemented!()
}
}
@@ -23,9 +23,10 @@ object RsImportHelper { | |||
context: RsElement, | |||
elements: Collection<RsElement>, | |||
subst: Substitution = emptySubstitution, | |||
useAliases: Boolean = false | |||
useAliases: Boolean = false, | |||
skipUnchangedDefaultTypeArguments: Boolean = false |
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.
Agree with @Kobzol about default value
Let's make it true
by default.
Also, it would be great to add test(s) for each feature where importTypeReferencesFromElements
is used to check that we don't import something unexpected. For example, change signature also use it
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.
BTW do we know cases when skipUnchangedDefaultTypeArguments
is actually needed?
If no, maybe it's better just not to add this argument at all and change import logic for all cases?
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.
Note, I don't insist to make this investigation in this PR, i.e. we can investigate all other cases separately and decide if we need this param and which default value should be used or even we can drop it at all
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.
Maybe it make sense to change skipUnchangedDefaultTypeArguments
to true
for Ty.renderInsertionSafe
, but not for Ty.render
? And remove this parameter for importTypeReferencesFromElements
/ getTypeReferencesInfoFromTys
?
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.
Probably. But it requires checking each feature that uses importing that may complicate this PR. But it's up to you
b62cb22
to
2e3ae97
Compare
@Undin Fixed. |
@mchernyavsky tests fail |
2e3ae97
to
08442a1
Compare
@Undin fixed. |
08442a1
to
b3d81b3
Compare
b3d81b3
to
2ee1214
Compare
@Undin Rebased on master. |
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.
👍
bors r+
This PR was included in a batch that successfully built, but then failed to merge into master (it was a non-fast-forward update). It will be automatically retried. |
Build succeeded: |
Fixes #6186
Depends on #6948.
changelog: Don't insert default type parameters by
Implement Member
actions