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 module visibility check #6685

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

jjcnn
Copy link
Contributor

@jjcnn jjcnn commented Nov 1, 2024

Description

Fixes #6673.

The module visibility check has been broken for some time.

In some cases, like the one described in #6673, this has resulted in modules being mistakenly regarded as inaccessible, even though they ought to be accessible.

In other cases, private modules were mistakenly regarded as accessible. For examples see the updated tests in the PR.

The check has now been fixed, and all tests have been updated accordingly.

This bugfix can be regarded as a breaking change, because some modules that were deemed accessible before may now be deemed inaccessible and will require the addition of a pub keyword in front of the module declaration.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@jjcnn jjcnn added the breaking May cause existing user code to break. Requires a minor or major release. label Nov 1, 2024
@jjcnn jjcnn self-assigned this Nov 1, 2024
@jjcnn jjcnn requested a review from a team as a code owner November 1, 2024 13:43
Copy link

codspeed-hq bot commented Nov 1, 2024

CodSpeed Performance Report

Merging #6685 will not alter performance

Comparing jjcnn/fix_module_visibility_in_tests (3d95afb) with master (ccd8692)

Summary

✅ 22 untouched benchmarks

@jjcnn jjcnn requested a review from a team as a code owner November 1, 2024 14:04
tritao
tritao previously approved these changes Nov 1, 2024
@tritao tritao requested a review from a team November 1, 2024 21:26
@@ -824,6 +830,15 @@ impl From<Module> for Root {
}
}

/// Iterates through two module paths and returns the number of common prefixes of src and dst,
/// i.e., the number of common ancestors of the src and dst modules.
fn common_ancestor_count(src: &ModulePath, dst: &ModulePath) -> usize {
Copy link
Contributor

Choose a reason for hiding this comment

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

This works, but to be clear what I had suggested originally was to make common_ancestor_count a local function inside check_module_privacy, unless you think it's going to be useful and called by something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that I've managed to reduce it to a single line of code, I'm inclined inline it again, and not have it as a separate function.

I doubt it needs to be used elsewhere.

tritao
tritao previously approved these changes Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking May cause existing user code to break. Requires a minor or major release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visibility check for modules is broken
4 participants