Skip to content

Introduce export keyword for cross-module item visibility#29542

Open
IGI-111 wants to merge 4 commits into
masterfrom
IGI-111/pub
Open

Introduce export keyword for cross-module item visibility#29542
IGI-111 wants to merge 4 commits into
masterfrom
IGI-111/pub

Conversation

@IGI-111

@IGI-111 IGI-111 commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Module-level fn, struct, const, and interface declarations now accept an export modifier, which is mandatory to make them reachable from other source files or compilation units.

Items inside a program block cannot be qualified with export since they are already implicitly public.

Accessibility rules are checked in the type checking phase.

This is a breaking change, as previously unqualified function declarations are now private by default.

export was chosen instead of pub because:

  1. it is desirable to minimize confusion with existing and future uses of public/private
  2. access rules are more analog to Javascript than Rust (no mod, relative paths)
  3. we already have an import keyword

@IGI-111 IGI-111 requested a review from mohammadfawaz June 20, 2026 05:05
@IGI-111 IGI-111 force-pushed the IGI-111/pub branch 7 times, most recently from 9c49c94 to 5e1b102 Compare June 22, 2026 06:26
Module-level `fn`, `struct`, `const`, and `interface` declarations now
accept an `export` modifier, which is mandatory to make them reachable from
other source files or compilation units.

Items inside a `program` block cannot be qualified with `export` since they
are already implicitly public.

Accessibility rules are checked in the type checking phase.

This is a breaking change, as previously unqualified function
declarations are now private by default.

`export` was chosen instead of `pub` because:
1. it is desirable to minimize confusion with existing and future uses of `public`/`private`
2. access rules are more analog to Javascript than Rust (no `mod`, relative paths)
3. we already have an `import` keyword
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.

1 participant