Skip to content

Commit 7337ea4

Browse files
refactor(spv-out): subvert-replace "recycle" in trait Recyclable to "reclaim"
This avoids `rustc` errors new to Rust 1.93. These errors are because `Recyclable::recycle` triggers the `unstable_name_collisions` lint on use, detecting a collision with the unstable `vec_recycle` Nightly feature.
1 parent b8e9f7a commit 7337ea4

5 files changed

Lines changed: 59 additions & 59 deletions

File tree

naga/src/back/spv/f16_polyfill.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ impl F16IoPolyfill {
9696
}
9797
}
9898

99-
impl crate::back::spv::recyclable::Recyclable for F16IoPolyfill {
100-
fn recycle(mut self) -> Self {
101-
self.io_var_to_f32_type = self.io_var_to_f32_type.recycle();
99+
impl crate::back::spv::reclaimable::Reclaimable for F16IoPolyfill {
100+
fn reclaim(mut self) -> Self {
101+
self.io_var_to_f32_type = self.io_var_to_f32_type.reclaim();
102102
self
103103
}
104104
}

naga/src/back/spv/layout.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ impl PhysicalLayout {
3939
}
4040
}
4141

42-
impl super::recyclable::Recyclable for PhysicalLayout {
43-
fn recycle(self) -> Self {
42+
impl super::reclaimable::Reclaimable for PhysicalLayout {
43+
fn reclaim(self) -> Self {
4444
PhysicalLayout {
4545
magic_number: self.magic_number,
4646
version: self.version,
@@ -67,20 +67,20 @@ impl LogicalLayout {
6767
}
6868
}
6969

70-
impl super::recyclable::Recyclable for LogicalLayout {
71-
fn recycle(self) -> Self {
70+
impl super::reclaimable::Reclaimable for LogicalLayout {
71+
fn reclaim(self) -> Self {
7272
Self {
73-
capabilities: self.capabilities.recycle(),
74-
extensions: self.extensions.recycle(),
75-
ext_inst_imports: self.ext_inst_imports.recycle(),
76-
memory_model: self.memory_model.recycle(),
77-
entry_points: self.entry_points.recycle(),
78-
execution_modes: self.execution_modes.recycle(),
79-
debugs: self.debugs.recycle(),
80-
annotations: self.annotations.recycle(),
81-
declarations: self.declarations.recycle(),
82-
function_declarations: self.function_declarations.recycle(),
83-
function_definitions: self.function_definitions.recycle(),
73+
capabilities: self.capabilities.reclaim(),
74+
extensions: self.extensions.reclaim(),
75+
ext_inst_imports: self.ext_inst_imports.reclaim(),
76+
memory_model: self.memory_model.reclaim(),
77+
entry_points: self.entry_points.reclaim(),
78+
execution_modes: self.execution_modes.reclaim(),
79+
debugs: self.debugs.reclaim(),
80+
annotations: self.annotations.reclaim(),
81+
declarations: self.declarations.reclaim(),
82+
function_declarations: self.function_declarations.reclaim(),
83+
function_definitions: self.function_definitions.reclaim(),
8484
}
8585
}
8686
}

naga/src/back/spv/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod instructions;
105105
mod layout;
106106
mod mesh_shader;
107107
mod ray;
108-
mod recyclable;
108+
mod reclaimable;
109109
mod selection;
110110
mod subgroup;
111111
mod writer;
@@ -655,10 +655,10 @@ impl ops::IndexMut<Handle<crate::Expression>> for CachedExpressions {
655655
id
656656
}
657657
}
658-
impl recyclable::Recyclable for CachedExpressions {
659-
fn recycle(self) -> Self {
658+
impl reclaimable::Reclaimable for CachedExpressions {
659+
fn reclaim(self) -> Self {
660660
CachedExpressions {
661-
ids: self.ids.recycle(),
661+
ids: self.ids.reclaim(),
662662
}
663663
}
664664
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,54 @@ use alloc::vec::Vec;
2222
/// that a field is missing from the literal. This trait's `recycle` method
2323
/// takes `self` by value, and returns `Self` by value, encouraging the use of
2424
/// struct literal expressions in its implementation.
25-
pub trait Recyclable {
25+
pub trait Reclaimable {
2626
/// Clear `self`, retaining its current memory allocations.
2727
///
2828
/// Shrink the buffer if it's currently much larger than was actually used.
2929
/// This prevents a module with exceptionally large allocations from causing
3030
/// the `Writer` to retain more memory than it needs indefinitely.
31-
fn recycle(self) -> Self;
31+
fn reclaim(self) -> Self;
3232
}
3333

3434
// Stock values for various collections.
3535

36-
impl<T> Recyclable for Vec<T> {
37-
fn recycle(mut self) -> Self {
36+
impl<T> Reclaimable for Vec<T> {
37+
fn reclaim(mut self) -> Self {
3838
self.clear();
3939
self
4040
}
4141
}
4242

43-
impl<K, V, S: Clone> Recyclable for hashbrown::HashMap<K, V, S> {
44-
fn recycle(mut self) -> Self {
43+
impl<K, V, S: Clone> Reclaimable for hashbrown::HashMap<K, V, S> {
44+
fn reclaim(mut self) -> Self {
4545
self.clear();
4646
self
4747
}
4848
}
4949

50-
impl<K, S: Clone> Recyclable for hashbrown::HashSet<K, S> {
51-
fn recycle(mut self) -> Self {
50+
impl<K, S: Clone> Reclaimable for hashbrown::HashSet<K, S> {
51+
fn reclaim(mut self) -> Self {
5252
self.clear();
5353
self
5454
}
5555
}
5656

57-
impl<K, S: Clone> Recyclable for indexmap::IndexSet<K, S> {
58-
fn recycle(mut self) -> Self {
57+
impl<K, S: Clone> Reclaimable for indexmap::IndexSet<K, S> {
58+
fn reclaim(mut self) -> Self {
5959
self.clear();
6060
self
6161
}
6262
}
6363

64-
impl<K: Ord, V> Recyclable for alloc::collections::BTreeMap<K, V> {
65-
fn recycle(mut self) -> Self {
64+
impl<K: Ord, V> Reclaimable for alloc::collections::BTreeMap<K, V> {
65+
fn reclaim(mut self) -> Self {
6666
self.clear();
6767
self
6868
}
6969
}
7070

71-
impl<K, V> Recyclable for crate::arena::HandleVec<K, V> {
72-
fn recycle(mut self) -> Self {
71+
impl<K, V> Reclaimable for crate::arena::HandleVec<K, V> {
72+
fn reclaim(mut self) -> Self {
7373
self.clear();
7474
self
7575
}

naga/src/back/spv/writer.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ impl Writer {
142142

143143
/// Reset `Writer` to its initial state, retaining any allocations.
144144
///
145-
/// Why not just implement `Recyclable` for `Writer`? By design,
146-
/// `Recyclable::recycle` requires ownership of the value, not just
145+
/// Why not just implement `Reclaimable` for `Writer`? By design,
146+
/// `Reclaimable::reclaim` requires ownership of the value, not just
147147
/// `&mut`; see the trait documentation. But we need to use this method
148148
/// from functions like `Writer::write`, which only have `&mut Writer`.
149149
/// Workarounds include unsafe code (`core::ptr::read`, then `write`, ugh)
150150
/// or something like a `Default` impl that returns an oddly-initialized
151151
/// `Writer`, which is worse.
152152
fn reset(&mut self) {
153-
use super::recyclable::Recyclable;
153+
use super::reclaimable::Reclaimable;
154154
use core::mem::take;
155155

156156
let mut id_gen = IdGenerator::default();
@@ -176,26 +176,26 @@ impl Writer {
176176
void_type,
177177
gl450_ext_inst_id,
178178

179-
// Recycled:
180-
capabilities_used: take(&mut self.capabilities_used).recycle(),
181-
extensions_used: take(&mut self.extensions_used).recycle(),
182-
physical_layout: self.physical_layout.clone().recycle(),
183-
logical_layout: take(&mut self.logical_layout).recycle(),
184-
debug_strings: take(&mut self.debug_strings).recycle(),
185-
debugs: take(&mut self.debugs).recycle(),
186-
annotations: take(&mut self.annotations).recycle(),
187-
lookup_type: take(&mut self.lookup_type).recycle(),
188-
lookup_function: take(&mut self.lookup_function).recycle(),
189-
lookup_function_type: take(&mut self.lookup_function_type).recycle(),
190-
wrapped_functions: take(&mut self.wrapped_functions).recycle(),
191-
constant_ids: take(&mut self.constant_ids).recycle(),
192-
cached_constants: take(&mut self.cached_constants).recycle(),
193-
global_variables: take(&mut self.global_variables).recycle(),
194-
std140_compat_uniform_types: take(&mut self.std140_compat_uniform_types).recycle(),
195-
saved_cached: take(&mut self.saved_cached).recycle(),
196-
temp_list: take(&mut self.temp_list).recycle(),
197-
ray_query_functions: take(&mut self.ray_query_functions).recycle(),
198-
io_f16_polyfills: take(&mut self.io_f16_polyfills).recycle(),
179+
// Reclaimed:
180+
capabilities_used: take(&mut self.capabilities_used).reclaim(),
181+
extensions_used: take(&mut self.extensions_used).reclaim(),
182+
physical_layout: self.physical_layout.clone().reclaim(),
183+
logical_layout: take(&mut self.logical_layout).reclaim(),
184+
debug_strings: take(&mut self.debug_strings).reclaim(),
185+
debugs: take(&mut self.debugs).reclaim(),
186+
annotations: take(&mut self.annotations).reclaim(),
187+
lookup_type: take(&mut self.lookup_type).reclaim(),
188+
lookup_function: take(&mut self.lookup_function).reclaim(),
189+
lookup_function_type: take(&mut self.lookup_function_type).reclaim(),
190+
wrapped_functions: take(&mut self.wrapped_functions).reclaim(),
191+
constant_ids: take(&mut self.constant_ids).reclaim(),
192+
cached_constants: take(&mut self.cached_constants).reclaim(),
193+
global_variables: take(&mut self.global_variables).reclaim(),
194+
std140_compat_uniform_types: take(&mut self.std140_compat_uniform_types).reclaim(),
195+
saved_cached: take(&mut self.saved_cached).reclaim(),
196+
temp_list: take(&mut self.temp_list).reclaim(),
197+
ray_query_functions: take(&mut self.ray_query_functions).reclaim(),
198+
io_f16_polyfills: take(&mut self.io_f16_polyfills).reclaim(),
199199
debug_printf: None,
200200
};
201201

0 commit comments

Comments
 (0)