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

ADT recursion #963

Open
wants to merge 1 commit into
base: fe-v2
Choose a base branch
from
Open

ADT recursion #963

wants to merge 1 commit into from

Conversation

g-r-a-n-t
Copy link
Member

@g-r-a-n-t g-r-a-n-t commented Nov 25, 2023

Added an accumulator that collects constituents of ADT recursions. These constituents are then combined and used to form diagnostics.

To-Do

  • OPTIONAL: Update Spec if applicable
  • Add entry to the release notes (may forgo for trivial changes)
  • Clean up commit history

@g-r-a-n-t g-r-a-n-t changed the base branch from master to fe-v2 November 25, 2023 19:30
@g-r-a-n-t g-r-a-n-t marked this pull request as draft November 25, 2023 19:36
@g-r-a-n-t g-r-a-n-t force-pushed the cycle-recovery branch 3 times, most recently from 8e08b9d to 313a6b5 Compare December 20, 2023 04:25
crates/hir-analysis/src/ty/diagnostics.rs Outdated Show resolved Hide resolved
crates/hir-analysis/src/ty/mod.rs Outdated Show resolved Hide resolved
crates/hir-analysis/src/ty/mod.rs Outdated Show resolved Hide resolved
@g-r-a-n-t g-r-a-n-t changed the title V2: WIP Recursive types single diagnostic V2: ADT Recursion Dec 20, 2023
@g-r-a-n-t g-r-a-n-t changed the title V2: ADT Recursion ADT recursion Dec 20, 2023
@g-r-a-n-t g-r-a-n-t marked this pull request as ready for review December 20, 2023 22:51
Copy link
Member

@Y-Nak Y-Nak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall.

I'm not sure if it's nice to define Accumulators to handle several recursive errors(e.g, type alias cycle, adt definition cycle, etc...). It'd be nice if we could address this problem in a more generic way instead of having many Accumulators.
But this task should be addressed after v2 is published. So I'm inclined to merge this PR when the small nits I gave are fixed.

@@ -15,7 +15,7 @@ either = "1.8"
derive_more = "0.99"
itertools = "0.10"
ena = "0.14"
indexmap = "1.6.2"
fxhash = "0.2.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary to add fxhash since rustc-hash contains FxHashMap. I used fxhash before, but rustc-hash is more actively developed(I realized that parser2 crate uses fxhash; I'll change parser2 dependency in #945).

@@ -44,6 +47,7 @@ use super::{
},
visitor::{walk_ty, TyVisitor},
};
use crate::ty::diagnostics::AdtRecursionConstituentAccumulator;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been considering the import order for a long time. This is bikeshedding, of course. But I feel grouping imports is more readable to me.

@sbillig @cburgdorf
What do you think about adding .rustfmt.toml in the project root so that we don't need to care about formatting stuff?

The below one is my .rustfmt.toml.

wrap_comments = true 
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
edition = "2021"

One downside is that this configuration requires nightly to run rustfmt.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added these rules to my .rustfmt as well

crates/hir-analysis/src/ty/diagnostics.rs Outdated Show resolved Hide resolved
@g-r-a-n-t
Copy link
Member Author

It'd be nice if we could address this problem in a more generic way instead of having many Accumulators

agreed. Ill generify this when implementing const cycle handling

@g-r-a-n-t g-r-a-n-t force-pushed the cycle-recovery branch 2 times, most recently from 9d87c1a to a8e12ab Compare February 7, 2024 04:20
@sbillig
Copy link
Collaborator

sbillig commented Feb 8, 2024

@g-r-a-n-t Micah fixed the wasm build in #984, which is now merged into fe-v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants