Skip to content
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: Allow unknown guidance when try to coerce unsized #16219

Closed
wants to merge 1 commit into from

Conversation

Austaras
Copy link
Contributor

A temporary workaround for #15984 and #11847.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 31, 2023
crates/hir-ty/src/infer/coerce.rs Show resolved Hide resolved
crates/hir-ty/src/infer/coerce.rs Show resolved Hide resolved
@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2024
@flodiebold
Copy link
Member

I think it'd be good to compare the results of analysis-stats with this change on a few code bases (at least RA itself).

@Veykril
Copy link
Member

Veykril commented Jan 3, 2024

Probably something other than r-a (or in addition to r-a), since r-a doesn't tend to exert the type system in a lot of ways.

@Austaras
Copy link
Contributor Author

Austaras commented Jan 3, 2024

I think it'd be good to compare the results of analysis-stats with this change on a few code bases (at least RA itself).

Is there any guide how to do that?

@Veykril
Copy link
Member

Veykril commented Jan 3, 2024

rust-analyzer analysis-stats project-to-analyze-path / cargo run --release -p rust-analyzer -- analysis-stats project-to-analyze-path

@Austaras
Copy link
Contributor Author

Austaras commented Jan 4, 2024

I tested this PR again master branch for several repos

r-a

// master
Body lowering:       3.40s, 36ginstr, 311mb                                                                                                                                       
  exprs: 683668, ??ty: 35 (0%), ?ty: 111 (0%), !ty: 3                                                                                                                             
  pats: 160801, ??ty: 4 (0%), ?ty: 4 (0%), !ty: 0

// coerce
Body lowering:       3.30s, 36ginstr, 311mb                                                                                                                                       
  exprs: 683693, ??ty: 35 (0%), ?ty: 703 (0%), !ty: 3                                                                                                                             
  pats: 160826, ??ty: 4 (0%), ?ty: 6 (0%), !ty: 0

hyper

// master
Body lowering:       877.68ms, 10ginstr, 66mb                                                       
  exprs: 60549, ??ty: 3554 (5%), ?ty: 2920 (4%), !ty: 1                                             
  pats: 9081, ??ty: 973 (10%), ?ty: 912 (10%), !ty: 6

// coerce
Body lowering:       873.75ms, 10ginstr, 66mb                                                       
  exprs: 60549, ??ty: 3554 (5%), ?ty: 2924 (4%), !ty: 1                                             
  pats: 9081, ??ty: 975 (10%), ?ty: 912 (10%), !ty: 6

rust

// master
Body lowering:       14.90s, 158ginstr, 1303mb                                                                                                                                                                                      
  exprs: 3438690, ??ty: 137025 (3%), ?ty: 134094 (3%), !ty: 3565                                                                                                                                                                    
  pats: 620050, ??ty: 42969 (6%), ?ty: 35569 (5%), !ty: 896

// coerce
Body lowering:       14.39s, 158ginstr, 1303mb                                                                                                                                                                                      
  exprs: 3438690, ??ty: 137038 (3%), ?ty: 134518 (3%), !ty: 3547                                                                                                                                                                    
  pats: 620050, ??ty: 43178 (6%), ?ty: 35569 (5%), !ty: 896

I also run against webrender and huggingface/candle, but the results are identical.

Are the numbers good or bad?

@Veykril
Copy link
Member

Veykril commented Jan 4, 2024

??ty means type contains {unknown}/{error}
?ty means type is unknown
!ty means type mismatch

The r-a case looks weird given ?ty, which base-line rust-analyzer did you use? the one before this PR or another?

Overall it seems to increase the contained unknowns a bit in some projects (regresses).

@Austaras
Copy link
Contributor Author

Austaras commented Jan 4, 2024

I built 95e047 as base to test against.

@Veykril
Copy link
Member

Veykril commented Jan 4, 2024

I can't find that commit. Anyways, the changes on rust-analyzer itself seem rather bad.

@Austaras
Copy link
Contributor Author

Austaras commented Jan 5, 2024

Fine. Maybe this is not the right way to go.

@Austaras Austaras closed this Jan 5, 2024
@Austaras Austaras deleted the coerce branch January 5, 2024 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants