Skip to content

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

Merged
merged 1 commit into from
Feb 17, 2025
Merged

pass struct fields to chalk #19122

merged 1 commit into from
Feb 17, 2025

Conversation

Austaras
Copy link
Contributor

@Austaras Austaras commented Feb 9, 2025

Closes #19003

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 9, 2025

fn test() {
let _: &Foo<[usize]> = &Foo { t: [1, 2, 3] };
//^^^^^^^^^^^^^^^^^^^^^ expected &'? Foo<[usize]>, got &'? Foo<[i32; 3]>
Copy link
Contributor Author

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

@Austaras Austaras force-pushed the master branch 4 times, most recently from 21fc062 to c2417cd Compare February 10, 2025 07:01
.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) {
Copy link
Member

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)

Copy link
Contributor Author

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

Copy link
Contributor Author

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)

Copy link
Member

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?

Copy link
Contributor Author

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.

@Veykril
Copy link
Member

Veykril commented Feb 17, 2025

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

@Veykril Veykril added this pull request to the merge queue Feb 17, 2025
Merged via the queue into rust-lang:master with commit efdfdc4 Feb 17, 2025
9 checks passed
@Veykril
Copy link
Member

Veykril commented Feb 18, 2025

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=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code passes initial check, but fails on closure-dyn type check after any operation
5 participants