Skip to content

Commit

Permalink
build(ribir): 🎡 update the version of Rust to "nightly-2023-09-14"
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Adoo committed Sep 18, 2023
1 parent e6134e2 commit 6c1f1c3
Show file tree
Hide file tree
Showing 26 changed files with 86 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2023-02-01
toolchain: nightly-2023-09-14
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: format style check
Expand Down
2 changes: 1 addition & 1 deletion core/src/context/app_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl<F> LocalFuture<F>
where
F: Future,
{
fn local_waker(&self, cx: &mut std::task::Context<'_>) -> Waker {
fn local_waker(&self, cx: &std::task::Context<'_>) -> Waker {
type RawLocalWaker = (std::task::Waker, Box<dyn RuntimeWaker + Send>);
fn clone(this: *const ()) -> RawWaker {
let waker = this as *const RawLocalWaker;
Expand Down
4 changes: 3 additions & 1 deletion core/src/context/build_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ impl<'a> BuildCtx<'a> {
pub(crate) fn themes(&self) -> &Vec<Sc<Theme>> {
self.themes.get_or_init(|| {
let mut themes = vec![];
let Some(p) = self.ctx_from else { return themes };
let Some(p) = self.ctx_from else {
return themes;
};

let arena = &self.tree.borrow().arena;
p.ancestors(arena).any(|p| {
Expand Down
8 changes: 6 additions & 2 deletions core/src/events/focus_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ impl FocusManager {
}

pub(crate) fn remove_focus_node(&mut self, wid: WidgetId, focus_type: FocusType) {
let Some(id) = self.node_ids.get(&wid).cloned() else { return; };
let Some(id) = self.node_ids.get(&wid).cloned() else {
return;
};

let node = self.arena[id].get_mut();
node.remove_focus(focus_type);
Expand All @@ -159,7 +161,9 @@ impl FocusManager {
}

pub fn refresh(&mut self) {
let Some(focusing) = self.request_focusing.take() else { return };
let Some(focusing) = self.request_focusing.take() else {
return;
};
if focusing.is_none() {
self.focusing = None;
return;
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(decl_macro, once_cell)]
#![feature(decl_macro)]
#![cfg_attr(test, feature(mutex_unpoison, test))]

#[macro_use]
Expand Down
10 changes: 5 additions & 5 deletions core/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ mod tests {
// 1. 3 item enter
let mut wnd = TestWindow::new(w);
wnd.draw_frame();
let expect_vec = vec!['1', '2', '3'];
let expect_vec = ['1', '2', '3'];
assert_eq!((*enter_list.state_ref()).len(), 3);
assert!(
(*enter_list.state_ref())
Expand All @@ -770,7 +770,7 @@ mod tests {
wnd.on_wnd_resize_event(ZERO_SIZE);
wnd.draw_frame();

let expect_vec = vec!['4'];
let expect_vec = ['4'];
assert_eq!((*enter_list.state_ref()).len(), 1);
assert!(
(*enter_list.state_ref())
Expand All @@ -784,15 +784,15 @@ mod tests {
c_v.write()[1].1 = 'b';
wnd.draw_frame();

let expect_vec = vec![];
let expect_vec = [];
assert_eq!((*enter_list.state_ref()).len(), 0);
assert!(
(*enter_list.state_ref())
.iter()
.all(|item| expect_vec.contains(item))
);

let expect_vec = vec!['b'];
let expect_vec = ['b'];
assert_eq!((*update_list.state_ref()).len(), 1);
assert!(
(*update_list.state_ref())
Expand Down Expand Up @@ -821,7 +821,7 @@ mod tests {

assert_eq!((*enter_list.state_ref()).len(), 0);

let expect_vec = vec!['a'];
let expect_vec = ['a'];
assert_eq!((*update_list.state_ref()).len(), 1);
assert!(
(*update_list.state_ref())
Expand Down
4 changes: 3 additions & 1 deletion core/src/widget_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ impl WidgetTree {
/// node has really computing the layout.
pub(crate) fn layout(&mut self, win_size: Size) {
loop {
let Some(mut needs_layout) = self.layout_list() else {break;};
let Some(mut needs_layout) = self.layout_list() else {
break;
};
while let Some(wid) = needs_layout.pop() {
if wid.is_dropped(&self.arena) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion core/src/widget_tree/layout_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl LayoutStore {
/// return a mutable reference of the layout info of `id`, if it's not exist
/// insert a default value before return
pub(crate) fn layout_info_or_default(&mut self, id: WidgetId) -> &mut LayoutInfo {
self.data.entry(id).or_insert_with(LayoutInfo::default)
self.data.entry(id).or_default()
}

pub(crate) fn map_to_parent(&self, id: WidgetId, pos: Point, arena: &TreeArena) -> Point {
Expand Down
8 changes: 6 additions & 2 deletions core/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ impl Window {
return false;
}
let tree = self.widget_tree.borrow();
let Some(p) = wid.parent(&tree.arena) else { return false };
let Some(p) = wid.parent(&tree.arena) else {
return false;
};
let in_another = p.ancestors(&tree.arena).any(|p| {
regen.get(&p).map_or(false, |to| {
to.map_or(true, |to| wid.ancestor_of(to, &tree.arena))
Expand Down Expand Up @@ -343,7 +345,9 @@ impl Window {
/// what you are doing.
fn emit_events(&self) {
loop {
let Some(e) = self.delay_emitter.borrow_mut().pop_front() else{ break};
let Some(e) = self.delay_emitter.borrow_mut().pop_front() else {
break;
};

match e {
DelayEvent::Mounted(id) => {
Expand Down
4 changes: 3 additions & 1 deletion gpu/src/gpu_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ where
let mut commands = commands.into_iter();
let output_size = output.size();
loop {
let Some(cmd) = commands.next() else { break; };
let Some(cmd) = commands.next() else {
break;
};
self.draw_command(cmd, output_size);
}
self.expand_indices_range();
Expand Down
14 changes: 9 additions & 5 deletions gpu/src/gpu_backend/textures_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ where
break;
}

let (tex_id, rg,Some(clip_rect)) = &draw_indices[idx] else { break; };
let (tex_id, rg, Some(clip_rect)) = &draw_indices[idx] else {
break;
};
let texture = id_to_texture_mut!(self, *tex_id);
gpu_impl.draw_alpha_triangles_with_scissor(rg, texture, *clip_rect);
idx += 1;
Expand All @@ -307,7 +309,9 @@ where
if idx >= draw_indices.len() {
break;
}
let (tex_id,rg, None) = &draw_indices[idx] else { unreachable!(); };
let (tex_id, rg, None) = &draw_indices[idx] else {
unreachable!();
};
let next = draw_indices[idx..]
.iter()
.position(|(next, _, _)| tex_id != next);
Expand Down Expand Up @@ -361,14 +365,14 @@ pub(crate) fn valid_cache_item(size: &DeviceSize) -> bool { size.lower_than(ATLA

fn extend_buffer<V>(dist: &mut VertexBuffers<V>, from: VertexBuffers<V>) {
if dist.vertices.is_empty() {
dist.vertices.extend(from.vertices.into_iter());
dist.indices.extend(from.indices.into_iter());
dist.vertices.extend(from.vertices);
dist.indices.extend(from.indices);
} else {
let offset = dist.vertices.len() as u32;
dist
.indices
.extend(from.indices.into_iter().map(|i| offset + i));
dist.vertices.extend(from.vertices.into_iter());
dist.vertices.extend(from.vertices);
}
}

Expand Down
12 changes: 6 additions & 6 deletions gpu/src/wgpu_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,31 @@ impl GPUBackendImpl for WgpuImpl {
fn load_alpha_vertices(&mut self, buffers: &VertexBuffers<f32>) {
self
.draw_alpha_triangles_pass
.load_alpha_vertices(buffers, &self.device, &mut self.queue);
.load_alpha_vertices(buffers, &self.device, &self.queue);
}

fn load_color_vertices(&mut self, buffers: &VertexBuffers<ColorAttr>) {
self
.draw_color_triangles_pass
.load_triangles_vertices(buffers, &self.device, &mut self.queue);
.load_triangles_vertices(buffers, &self.device, &self.queue);
}

fn load_img_vertices(&mut self, buffers: &VertexBuffers<u32>) {
self
.draw_img_triangles_pass
.load_triangles_vertices(buffers, &self.device, &mut self.queue);
.load_triangles_vertices(buffers, &self.device, &self.queue);
}

fn load_img_primitives(&mut self, primitives: &[ImgPrimitive]) {
self
.draw_img_triangles_pass
.load_img_primitives(&self.device, &mut self.queue, primitives);
.load_img_primitives(&self.device, &self.queue, primitives);
}

fn load_mask_layers(&mut self, layers: &[crate::MaskLayer]) {
self
.mask_layers_storage
.write_buffer(&self.device, &mut self.queue, layers);
.write_buffer(&self.device, &self.queue, layers);
}

fn draw_alpha_triangles(&mut self, indices: &Range<u32>, texture: &mut Self::Texture) {
Expand Down Expand Up @@ -567,7 +567,7 @@ impl WgpuImpl {
self.command_buffers.push(encoder.finish());
}
if !self.command_buffers.is_empty() {
self.draw_tex_pass.submit(&mut self.queue);
self.draw_tex_pass.submit(&self.queue);
self.queue.submit(self.command_buffers.drain(..));
} else {
self.draw_tex_pass.clear();
Expand Down
2 changes: 1 addition & 1 deletion gpu/src/wgpu_impl/buffer_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<T: AsBytes> BufferPool<T> {
})
}

pub fn submit_buffer(&mut self, queue: &mut wgpu::Queue) {
pub fn submit_buffer(&mut self, queue: &wgpu::Queue) {
if !self.data.is_empty() {
queue.write_buffer(&self.buffer, 0, self.data.as_bytes());
self.data.clear();
Expand Down
4 changes: 2 additions & 2 deletions gpu/src/wgpu_impl/draw_alpha_triangles_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ impl DrawAlphaTrianglesPass {
&mut self,
buffers: &VertexBuffers<f32>,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
) {
self.vertices_buffer.write_buffer(buffers, device, queue);
}

pub fn draw_alpha_triangles(
&mut self,
indices: &Range<u32>,
texture: &mut WgpuTexture,
texture: &WgpuTexture,
scissor: Option<DeviceRect>,
encoder: &mut wgpu::CommandEncoder,
device: &wgpu::Device,
Expand Down
4 changes: 2 additions & 2 deletions gpu/src/wgpu_impl/draw_color_triangles_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ impl DrawColorTrianglesPass {
&mut self,
buffers: &VertexBuffers<ColorAttr>,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
) {
self.vertices_buffer.write_buffer(buffers, device, queue);
}

#[allow(clippy::too_many_arguments)]
pub fn draw_triangles(
&mut self,
texture: &mut WgpuTexture,
texture: &WgpuTexture,
indices: Range<u32>,
clear: Option<Color>,
device: &wgpu::Device,
Expand Down
6 changes: 3 additions & 3 deletions gpu/src/wgpu_impl/draw_img_triangles_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ impl DrawImgTrianglesPass {
&mut self,
buffers: &VertexBuffers<u32>,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
) {
self.vertices_buffer.write_buffer(buffers, device, queue);
}

pub fn load_img_primitives(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
primitives: &[ImgPrimitive],
) {
self.prims_storage.write_buffer(device, queue, primitives);
Expand All @@ -59,7 +59,7 @@ impl DrawImgTrianglesPass {
#[allow(clippy::too_many_arguments)]
pub fn draw_triangles(
&mut self,
texture: &mut WgpuTexture,
texture: &WgpuTexture,
indices: Range<u32>,
clear: Option<Color>,
device: &wgpu::Device,
Expand Down
2 changes: 1 addition & 1 deletion gpu/src/wgpu_impl/draw_texture_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl DrawTexturePass {
}
}

pub fn submit(&mut self, queue: &mut wgpu::Queue) { self.vertices_pool.submit_buffer(queue); }
pub fn submit(&mut self, queue: &wgpu::Queue) { self.vertices_pool.submit_buffer(queue); }

pub fn clear(&mut self) { self.vertices_pool.clear() }
}
Expand Down
2 changes: 1 addition & 1 deletion gpu/src/wgpu_impl/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<T: AsBytes> Storage<T> {
Self { layout, buffer, bind, _phantom }
}

pub fn write_buffer(&mut self, device: &wgpu::Device, queue: &mut wgpu::Queue, data: &[T]) {
pub fn write_buffer(&mut self, device: &wgpu::Device, queue: &wgpu::Queue, data: &[T]) {
let buffer_size = (std::mem::size_of_val(data)) as wgpu::BufferAddress;
if self.buffer.size() < buffer_size {
(self.buffer, self.bind) = Self::new_bind(device, &self.layout, buffer_size);
Expand Down
2 changes: 1 addition & 1 deletion gpu/src/wgpu_impl/vertex_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<T: AsBytes> VerticesBuffer<T> {
&mut self,
data: &ribir_painter::VertexBuffers<T>,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
) {
let vertices_data = data.vertices.as_bytes();
let indices_data = data.indices.as_bytes();
Expand Down
4 changes: 3 additions & 1 deletion macros/src/child_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ fn option_type_extract(ty: &syn::Type) -> Option<&syn::Type> {
seg.ident == ident && seg.arguments.is_empty()
}

let syn::Type::Path(ref path) = ty else { return None };
let syn::Type::Path(ref path) = ty else {
return None;
};
let mut iter = path.path.segments.iter().rev();
iter
.next()
Expand Down
8 changes: 5 additions & 3 deletions macros/src/symbol_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ mod tokens_pre_process {

fn in_macro(tokens: &[TokenTree]) -> bool {
let [.., TokenTree::Ident(_), TokenTree::Punct(p)] = tokens else {
return false;
};
return false;
};
p.as_char() == '!'
}
}
Expand Down Expand Up @@ -280,7 +280,9 @@ impl Fold for DollarRefsCtx {

// fold if write on state.
let write_mac = is_state_write_method(&i).then(|| {
let Expr::Macro(m) = &mut *i.receiver else { return None };
let Expr::Macro(m) = &mut *i.receiver else {
return None;
};
parse_dollar_macro(&m.mac).map(|d| (d.name, &mut m.mac))
});
if let Some(Some((name, mac))) = write_mac {
Expand Down
4 changes: 3 additions & 1 deletion ribir/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ impl App {
match event {
Event::WindowEvent { event, window_id } => {
let wnd_id = new_id(window_id);
let Some(wnd) = AppCtx::get_window(wnd_id) else { return; };
let Some(wnd) = AppCtx::get_window(wnd_id) else {
return;
};
match event {
WindowEvent::CloseRequested => {
AppCtx::remove_wnd(wnd_id);
Expand Down
Loading

0 comments on commit 6c1f1c3

Please sign in to comment.