map: extract Pipelines::new assembly under the 500-line limit
- Commit
3ead4cff8781357a21a4409b001657652ecaf19a- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 20:34 UTC (4 days ago)
- Parents
aeea3e5
vulkan/pipeline/pipelines.rs (518 lines) exceeded the 500-line rustFileLength limit because Pipelines::new is one large unsafe method; the established include! split cannot cut inside it. Extract its final pure statement block -- the eighteen-way match that constructs Pipelines on success or destroys every created pipeline and then the layouts on failure -- into pub(super) unsafe fn pipelines_finish::finish, a private module sibling following pipelines_symbols/pipelines_globe. The match, its order, the success construction and the failure cleanup move verbatim; the call site only forwards the device, the four layouts and the eighteen build results it already held. No public API changes: the helper is pub(super) and no pub item in pipelines.rs changes. pipelines.rs drops 518 -> 428 lines; the new helper file is 157 lines. Verified: cargo fmt -p map_renderer -- --check clean and cargo test -p map_renderer --locked green (574 passed).
Diff
library/map/src/main/rust/src/vulkan/pipeline/mod.rs
diff --git a/library/map/src/main/rust/src/vulkan/pipeline/mod.rs b/library/map/src/main/rust/src/vulkan/pipeline/mod.rsindex c4f4b907cf..69057849a8 100644--- a/library/map/src/main/rust/src/vulkan/pipeline/mod.rs+++ b/library/map/src/main/rust/src/vulkan/pipeline/mod.rs@@ -22,6 +22,7 @@ mod attributes; mod pipelines; mod pipelines_attrs; mod pipelines_extra;+mod pipelines_finish; mod pipelines_globe; mod pipelines_moon; mod pipelines_symbols;
library/map/src/main/rust/src/vulkan/pipeline/pipelines.rs
diff --git a/library/map/src/main/rust/src/vulkan/pipeline/pipelines.rs b/library/map/src/main/rust/src/vulkan/pipeline/pipelines.rsindex 63d4657903..f1f33b3f24 100644--- a/library/map/src/main/rust/src/vulkan/pipeline/pipelines.rs+++ b/library/map/src/main/rust/src/vulkan/pipeline/pipelines.rs@@ -371,7 +371,12 @@ impl Pipelines { device.destroy_shader_module(moon_vert, None); device.destroy_shader_module(moon_frag, None); - match (+ super::pipelines_finish::finish(+ device,+ layout,+ symbol_layout,+ moon_layout,+ moon_ds_layout, fill, line, ribbon,@@ -390,102 +395,7 @@ impl Pipelines { symbol_globe, icon_globe, moon,- ) {- (- Ok(fill),- Ok(line),- Ok(ribbon),- Ok(depth),- Ok(building),- Ok(terrain),- Ok(symbol),- Ok(icon),- Ok(sprite),- Ok(puck),- Ok(mask),- Ok(scrim),- Ok(fill_globe),- Ok(line_globe),- Ok(ribbon_globe),- Ok(symbol_globe),- Ok(icon_globe),- Ok(moon),- ) => Ok(Pipelines {- layout,- symbol_layout,- moon_layout,- moon_ds_layout,- fill,- line,- ribbon,- depth,- building,- terrain,- symbol,- icon,- sprite,- puck,- mask,- scrim,- fill_globe,- line_globe,- ribbon_globe,- symbol_globe,- icon_globe,- moon,- }),- (- fill,- line,- ribbon,- depth,- building,- terrain,- symbol,- icon,- sprite,- puck,- mask,- scrim,- fill_globe,- line_globe,- ribbon_globe,- symbol_globe,- icon_globe,- moon,- ) => {- for created in [- fill,- line,- ribbon,- depth,- building,- terrain,- symbol,- icon,- sprite,- puck,- mask,- scrim,- fill_globe,- line_globe,- ribbon_globe,- symbol_globe,- icon_globe,- moon,- ]- .into_iter()- .flatten()- {- device.destroy_pipeline(created, None);- }- device.destroy_pipeline_layout(symbol_layout, None);- device.destroy_pipeline_layout(moon_layout, None);- device.destroy_descriptor_set_layout(moon_ds_layout, None);- device.destroy_pipeline_layout(layout, None);- Err("pipeline creation failed".into())- }- }+ ) } /// # Safety
library/map/src/main/rust/src/vulkan/pipeline/pipelines_finish.rs
diff --git a/library/map/src/main/rust/src/vulkan/pipeline/pipelines_finish.rs b/library/map/src/main/rust/src/vulkan/pipeline/pipelines_finish.rsnew file mode 100644index 0000000000..6c74e8a1dc--- /dev/null+++ b/library/map/src/main/rust/src/vulkan/pipeline/pipelines_finish.rs@@ -0,0 +1,157 @@+//! Final assembly of the eighteen built pipelines for [`Pipelines::new`]:+//!+//! Split from `pipelines.rs` (file-length limit). The match, the success+//! construction and the failure cleanup move verbatim, in the same order.+use ash::vk;++use super::Pipelines;++/// Combine the built pipelines into [`Pipelines`]; on any failure, destroy+/// every pipeline that was created, then the layouts, in that order.+///+/// # Safety+///+/// Same contract as [`Pipelines::new`]: the device must be valid and the+/// pipelines/layouts must not be destroyed elsewhere first.+#[allow(clippy::too_many_arguments)]+pub(super) unsafe fn finish(+ device: &ash::Device,+ layout: vk::PipelineLayout,+ symbol_layout: vk::PipelineLayout,+ moon_layout: vk::PipelineLayout,+ moon_ds_layout: vk::DescriptorSetLayout,+ fill: Result<vk::Pipeline, String>,+ line: Result<vk::Pipeline, String>,+ ribbon: Result<vk::Pipeline, String>,+ depth: Result<vk::Pipeline, String>,+ building: Result<vk::Pipeline, String>,+ terrain: Result<vk::Pipeline, String>,+ symbol: Result<vk::Pipeline, String>,+ icon: Result<vk::Pipeline, String>,+ sprite: Result<vk::Pipeline, String>,+ puck: Result<vk::Pipeline, String>,+ mask: Result<vk::Pipeline, String>,+ scrim: Result<vk::Pipeline, String>,+ fill_globe: Result<vk::Pipeline, String>,+ line_globe: Result<vk::Pipeline, String>,+ ribbon_globe: Result<vk::Pipeline, String>,+ symbol_globe: Result<vk::Pipeline, String>,+ icon_globe: Result<vk::Pipeline, String>,+ moon: Result<vk::Pipeline, String>,+) -> Result<Pipelines, String> {+ match (+ fill,+ line,+ ribbon,+ depth,+ building,+ terrain,+ symbol,+ icon,+ sprite,+ puck,+ mask,+ scrim,+ fill_globe,+ line_globe,+ ribbon_globe,+ symbol_globe,+ icon_globe,+ moon,+ ) {+ (+ Ok(fill),+ Ok(line),+ Ok(ribbon),+ Ok(depth),+ Ok(building),+ Ok(terrain),+ Ok(symbol),+ Ok(icon),+ Ok(sprite),+ Ok(puck),+ Ok(mask),+ Ok(scrim),+ Ok(fill_globe),+ Ok(line_globe),+ Ok(ribbon_globe),+ Ok(symbol_globe),+ Ok(icon_globe),+ Ok(moon),+ ) => Ok(Pipelines {+ layout,+ symbol_layout,+ moon_layout,+ moon_ds_layout,+ fill,+ line,+ ribbon,+ depth,+ building,+ terrain,+ symbol,+ icon,+ sprite,+ puck,+ mask,+ scrim,+ fill_globe,+ line_globe,+ ribbon_globe,+ symbol_globe,+ icon_globe,+ moon,+ }),+ (+ fill,+ line,+ ribbon,+ depth,+ building,+ terrain,+ symbol,+ icon,+ sprite,+ puck,+ mask,+ scrim,+ fill_globe,+ line_globe,+ ribbon_globe,+ symbol_globe,+ icon_globe,+ moon,+ ) => {+ for created in [+ fill,+ line,+ ribbon,+ depth,+ building,+ terrain,+ symbol,+ icon,+ sprite,+ puck,+ mask,+ scrim,+ fill_globe,+ line_globe,+ ribbon_globe,+ symbol_globe,+ icon_globe,+ moon,+ ]+ .into_iter()+ .flatten()+ {+ device.destroy_pipeline(created, None);+ }+ device.destroy_pipeline_layout(symbol_layout, None);+ device.destroy_pipeline_layout(moon_layout, None);+ device.destroy_descriptor_set_layout(moon_ds_layout, None);+ device.destroy_pipeline_layout(layout, None);+ Err("pipeline creation failed".into())+ }+ }+}