From debaa77e7909687acdab87b96911dcc5f8b7afbc Mon Sep 17 00:00:00 2001 From: piquel Date: Sun, 22 Nov 2026 20:04:05 +0100 Subject: [PATCH] chore(lint): items no other crate can reach are no longer pub --- Cargo.toml | 1 + apps/auth-service/src/admin/overview/mod.rs | 8 ++++---- apps/auth-service/src/admin/types/mod.rs | 2 +- apps/auth-service/src/federation/mod.rs | 2 +- apps/auth-service/src/oidc/mod.rs | 2 +- apps/auth-service/src/passkey/mod.rs | 2 +- crates/auth-sdk/src/scope.rs | 4 ++-- crates/common/src/tests.rs | 5 +++++ crates/ui/src/layout/frames.rs | 2 +- crates/ui/src/layout/mod.rs | 5 ++--- crates/ui/src/layout/signed_in.rs | 6 +++--- crates/ui/src/lib.rs | 4 ++++ tools/xtask/src/publish.rs | 4 ++-- tools/xtask/src/release.rs | 6 +++--- 14 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 16baab021..310361613 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ version = "0.1.0" [workspace.lints.rust] unsafe_code = "forbid" missing_docs = "warn" +unreachable_pub = "warn" # Every Clippy warning fails CI: `just rust lint` runs Clippy with `-D warnings`. # The groups sit at priority -1 so the single lints below can override them. diff --git a/apps/auth-service/src/admin/overview/mod.rs b/apps/auth-service/src/admin/overview/mod.rs index 456095520..37c88508f 100644 --- a/apps/auth-service/src/admin/overview/mod.rs +++ b/apps/auth-service/src/admin/overview/mod.rs @@ -31,7 +31,7 @@ impl Kinds { /// How often something happened in the last hour, against an hour's usual /// count over the last week. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -pub struct Rate { +pub(crate) struct Rate { /// In the last hour. pub last_hour: u64, /// Per hour, averaged over the week before, rounded up. @@ -58,7 +58,7 @@ impl Rate { /// What needs an administrator's attention. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Problem { +pub(crate) enum Problem { /// Alerts are open: nobody posted an update on them yet. OpenAlerts(u64), /// Far more sign-ins failed in the last hour than usually do. @@ -74,7 +74,7 @@ pub enum Problem { /// What the overview shows. #[derive(Clone, Debug)] -pub struct Overview { +pub(crate) struct Overview { /// Rejected passkey and provider authentications. pub failed_sign_ins: Rate, /// Browsers signing in. @@ -102,7 +102,7 @@ pub struct Overview { impl Overview { /// What needs attention, most pressing first. #[must_use] - pub fn problems(&self) -> Vec { + pub(crate) fn problems(&self) -> Vec { let mut problems = Vec::new(); if self.open_alerts > 0 { problems.push(Problem::OpenAlerts(self.open_alerts)); diff --git a/apps/auth-service/src/admin/types/mod.rs b/apps/auth-service/src/admin/types/mod.rs index b345505cb..1aea572ea 100644 --- a/apps/auth-service/src/admin/types/mod.rs +++ b/apps/auth-service/src/admin/types/mod.rs @@ -48,7 +48,7 @@ const DEFAULT_GRACE_PERIOD: i64 = MINUTES_PER_DAY; /// A whole number of minutes, written in its largest whole unit, e.g. `365d`. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct Minutes(i64); +pub(crate) struct Minutes(i64); impl fmt::Display for Minutes { /// Writes `0`, or the number of days, hours or minutes with its unit. diff --git a/apps/auth-service/src/federation/mod.rs b/apps/auth-service/src/federation/mod.rs index 587bfd257..b50f5d919 100644 --- a/apps/auth-service/src/federation/mod.rs +++ b/apps/auth-service/src/federation/mod.rs @@ -35,7 +35,7 @@ use url::Url; mod error; /// Pending evidence, signup attachment, linking and unlinking. mod identities; -pub use error::FederationConfigError; +pub(crate) use error::FederationConfigError; pub(crate) use error::FederationError; use error::InvalidReturnTo; pub(crate) use identities::{PendingKind, PendingView}; diff --git a/apps/auth-service/src/oidc/mod.rs b/apps/auth-service/src/oidc/mod.rs index 1ac27aae5..44f7998a5 100644 --- a/apps/auth-service/src/oidc/mod.rs +++ b/apps/auth-service/src/oidc/mod.rs @@ -22,7 +22,7 @@ pub(crate) use authorize::{ AuthorizationDecision, AuthorizationView, RecoveryQuestion, TransactionQuery, }; use error::Challenge; -pub use error::OidcConfigError; +pub(crate) use error::OidcConfigError; pub(crate) use error::{OAuthCode, OAuthError, Reject}; pub(crate) use inline::{InlineClaim, InlineResponse}; pub(crate) use logout::{LogoutQuery, LogoutView}; diff --git a/apps/auth-service/src/passkey/mod.rs b/apps/auth-service/src/passkey/mod.rs index 89c189f42..28f5e2373 100644 --- a/apps/auth-service/src/passkey/mod.rs +++ b/apps/auth-service/src/passkey/mod.rs @@ -48,7 +48,7 @@ mod settings; mod types; pub(crate) use confirmation::AdminProof; -pub use error::PasskeyConfigError; +pub(crate) use error::PasskeyConfigError; pub(crate) use error::PasskeyError; pub(crate) use recovery::VerifiedRecoveryUndo; use types::PasskeyKind; diff --git a/crates/auth-sdk/src/scope.rs b/crates/auth-sdk/src/scope.rs index 9626dc54d..8b39f141c 100644 --- a/crates/auth-sdk/src/scope.rs +++ b/crates/auth-sdk/src/scope.rs @@ -148,7 +148,7 @@ macro_rules! scopes { #[doc = ""] $(#[$scope_meta])* #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - pub enum $scope {} + pub(crate) enum $scope {} impl $crate::Scope for $scope { const NAME: &'static str = $name; @@ -166,7 +166,7 @@ macro_rules! scopes { /// Every scope this module declares. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - pub enum All {} + pub(crate) enum All {} impl $crate::__private::Declared for All { const NAMES: &'static [&'static str] = &[$($name),+]; diff --git a/crates/common/src/tests.rs b/crates/common/src/tests.rs index edd01152a..391ebebd8 100644 --- a/crates/common/src/tests.rs +++ b/crates/common/src/tests.rs @@ -1,4 +1,9 @@ //! Focused tests for exported vocabulary expansion and identifier syntax. +#![expect( + unreachable_pub, + reason = "The vocabulary macros make their items public, which a test-private enum cannot reach." +)] + use super::*; str_enum! { diff --git a/crates/ui/src/layout/frames.rs b/crates/ui/src/layout/frames.rs index 1b0b96d9d..b508c8a63 100644 --- a/crates/ui/src/layout/frames.rs +++ b/crates/ui/src/layout/frames.rs @@ -12,7 +12,7 @@ use topcoat::{ pub const SOURCE: &str = "https://github.com/sourceorigin-dev/sourceorigin"; /// Where SourceOrigin's users and developers write to. -pub const SUPPORT_ADDRESS: &str = "support@sourceorigin.dev"; +pub(crate) const SUPPORT_ADDRESS: &str = "support@sourceorigin.dev"; /// Where every page's footer links SourceOrigin's policies, which sourceorigin.dev serves. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/ui/src/layout/mod.rs b/crates/ui/src/layout/mod.rs index 55765afa2..4a586b89e 100644 --- a/crates/ui/src/layout/mod.rs +++ b/crates/ui/src/layout/mod.rs @@ -25,9 +25,7 @@ pub use html::{PreferenceChange, Preferences, Sidebar, Theme, Title, document}; pub use parts::{Pager, page_head}; pub use search::{Destination, Group, Search, SearchPage, search_results}; pub use sections::{AccountNav, Section, account, signed_out}; -pub use signed_in::{ - Crumb, NavGroup, NavItem, PasskeySignal, Shell, Shortcut, ShortcutKind, Who, shell, -}; +pub use signed_in::{Crumb, PasskeySignal, Shortcut, ShortcutKind, Who, shell}; pub(crate) use parts::{ Label, alert_notice, announcement_text, dialog, navigation, page_messages, pager, @@ -35,3 +33,4 @@ pub(crate) use parts::{ }; pub(crate) use search::{Searchable, Spot}; pub(crate) use signed_in::{AvatarSize, avatar}; +pub(crate) use signed_in::{NavGroup, NavItem, Shell}; diff --git a/crates/ui/src/layout/signed_in.rs b/crates/ui/src/layout/signed_in.rs index bdd557a0a..ca5174e6e 100644 --- a/crates/ui/src/layout/signed_in.rs +++ b/crates/ui/src/layout/signed_in.rs @@ -19,7 +19,7 @@ use topcoat::{ /// A link of the sidebar. #[derive(Clone, Copy, Debug)] -pub struct NavItem<'a> { +pub(crate) struct NavItem<'a> { /// Its icon. pub icon: Icon, /// Its label, also its title once the sidebar is collapsed to icons. @@ -36,7 +36,7 @@ pub struct NavItem<'a> { /// A group of the sidebar's links, under its label, if any. #[derive(Clone, Copy, Debug)] -pub struct NavGroup<'a> { +pub(crate) struct NavGroup<'a> { /// Its label, in the sidebar's small type. pub label: Option<&'a str>, /// Its links. @@ -196,7 +196,7 @@ impl Shortcut<'_> { /// The frame of a signed-in page: what every part of the shell shows. #[derive(Clone, Copy, Debug)] -pub struct Shell<'a> { +pub(crate) struct Shell<'a> { /// Where the brand links. pub home: &'a str, /// The part of SourceOrigin the page belongs to, after the brand. diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index 3d1e86326..bdfe5b562 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -33,6 +33,10 @@ //! # Ok(()) //! # } //! ``` +#![expect( + unreachable_pub, + reason = "`#[component]` makes a public props struct beside each public component, which the crate never exports" +)] /// The admin dashboard, and auth's page handing administrators off to it. mod admin; diff --git a/tools/xtask/src/publish.rs b/tools/xtask/src/publish.rs index 4fd081f25..b90916486 100644 --- a/tools/xtask/src/publish.rs +++ b/tools/xtask/src/publish.rs @@ -11,7 +11,7 @@ use std::process::Command; const LICENSE: &str = "Apache-2.0"; /// A publish of the SDKs at their current versions. -pub struct Publish<'a> { +pub(crate) struct Publish<'a> { pub workspace: &'a Workspace, /// Packages and builds everything without uploading, even versions already /// published, so it checks the packages whatever the registries hold. @@ -25,7 +25,7 @@ impl Publish<'_> { /// with `cargo publish --workspace`, which publishes them in dependency order /// and builds each from its package, then the npm package with `npm publish`, /// whose `prepack` script builds it. - pub fn run(&self) -> Result<()> { + pub(crate) fn run(&self) -> Result<()> { self.check()?; self.crates()?; self.npm() diff --git a/tools/xtask/src/release.rs b/tools/xtask/src/release.rs index f84ad1458..59ee84871 100644 --- a/tools/xtask/src/release.rs +++ b/tools/xtask/src/release.rs @@ -6,7 +6,7 @@ use anyhow::{Context, Result, bail, ensure}; use std::{fmt::Write as _, fs}; /// A release of the workspace version, from `HEAD`. -pub struct Release<'a> { +pub(crate) struct Release<'a> { workspace: &'a Workspace, /// The workspace version, such as `0.2.0`. version: String, @@ -16,7 +16,7 @@ pub struct Release<'a> { } impl<'a> Release<'a> { - pub fn new(workspace: &'a Workspace, dry_run: bool) -> Result { + pub(crate) fn new(workspace: &'a Workspace, dry_run: bool) -> Result { Ok(Self { workspace, version: workspace.version()?.to_owned(), @@ -29,7 +29,7 @@ impl<'a> Release<'a> { /// release notes, publishes the SDKs, tags `HEAD` `v`, pushes the /// tag, creates its GitHub release, and closes its minor version's /// milestone, such as `v0.2`. - pub fn run(&self) -> Result<()> { + pub(crate) fn run(&self) -> Result<()> { self.check()?; let previous = self.previous()?; let previous = previous.as_deref();