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

[move-compiler] New DiagnosticReporter for collecting diags #20123

Merged
merged 14 commits into from
Nov 1, 2024

Conversation

tnowacki
Copy link
Contributor

Description

Test plan

  • ran tests

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

@tnowacki tnowacki requested a review from cgswords October 31, 2024 17:34
Copy link

vercel bot commented Oct 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 31, 2024 5:35pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 5:35pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 5:35pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 5:35pm

Comment on lines +66 to +72
#[derive(PartialEq, Eq, Clone, Debug)]
enum WarningFiltersScope_ {
/// Unsafe and should be used only for internal purposes, such as ide annotations
Empty,
Static(&'static WarningFilters),
Node(Arc<WarningFiltersScopeNode>),
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched FiltersScope to a linked list, mostly here to better demonstrate that the initial creation of a DiagnosticReproter has to copy/borrow--no clones.

}

impl DefnContext<'_, '_> {
pub(super) fn add_diag(&self, diag: Diagnostic) {
self.env.add_diag(&self.warning_filters_scope, diag);
self.reporter.add_diag(diag);
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 kept all of the various delegates I added in #20065, since it will make future refactors maybe a bit easier?
I can remove them if there are strong opinions

Comment on lines +49 to +53
flags: &'env Flags,
known_filter_names: &'env BTreeMap<DiagnosticsID, (FilterPrefix, FilterName)>,
diags: &'env RwLock<Diagnostics>,
ide_information: &'env RwLock<IDEInfo>,
warning_filters_scope: WarningFiltersScope,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies for the re-ordering here messing with the diff.

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 grabbed individual fields from CompilationEnv instead of just having a &'env CompilationEnv because I hope it will help ensure a better separation of abstractions for two reasons:

  1. It should hopefully prevent feature creep that might occur if there was a direct reference to the env.
  2. I hope this forces us to correctly construct a DiagnosticReporter. If new just took &'env CompilationEnv, it would very easy to create them incorrectly.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense to me, and it also frees us from needing the whole environment just for reporting. Maybe we can even get some reuse this way.

@@ -1,2916 +0,0 @@
// Copyright (c) The Move Contributors
Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops, embarrassing that this got left in

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 happens :) I only found it because of regex

Copy link
Contributor

@cgswords cgswords left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉

This is awesome, I love the changes.

@tnowacki tnowacki merged commit 669cf6d into MystenLabs:main Nov 1, 2024
48 checks passed
@tnowacki tnowacki deleted the reporter branch November 1, 2024 17:53
lxfind pushed a commit that referenced this pull request Nov 5, 2024
## Description 

- Followup to #20065
- Better encapsulates warning filter scopes with diagnostic reporting

## Test plan 

- ran tests

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
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.

2 participants