-
Notifications
You must be signed in to change notification settings - Fork 1.8k
pass struct fields to chalk #19122
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
pass struct fields to chalk #19122
Conversation
|
||
fn test() { | ||
let _: &Foo<[usize]> = &Foo { t: [1, 2, 3] }; | ||
//^^^^^^^^^^^^^^^^^^^^^ expected &'? Foo<[usize]>, got &'? Foo<[i32; 3]> |
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.
This test case is effectively the same with the added one, just different kind of coerce unsized
21fc062
to
c2417cd
Compare
.collect() | ||
// HACK: provide full struct type info slows down rust-analyzer by quite a bit unfortunately, | ||
// so we trick chalk into thinking that our struct impl Unsize | ||
if let Some(ty) = bound_vars_subst.at(Interner, 0).ty(Interner) { |
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.
What is the first bound var in this context? (has been a while since I touched this here)
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.
It's the first generic of this struct
struct Foo<T, U, V>
//^ this
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.
Basically this is make chalk believe every struct with generic type is struct Foo<T>(T)
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 this could cause other issues, also wouldn't this only work out where the first supplied parameter type is actually unsizable?
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 this could cause other issues
Maybe, but since other tests passed, I guess it's fine so far
also wouldn't this only work out where the first supplied parameter type is actually unsizable?
Yes but I believe r-a and chalk already handled that. r-a
has recorded what type is sized and chalk would query r-a for that info.
Alright lets give this a test run then, if it doesn't break anything we can keep this as a best effort tradeoff until we switch to the new solver |
This is causing major regressions as I expected so we gotta roll this back https://rust-analyzer.github.io/metrics/?start=2025-02-16&end= |
Closes #19003