Skip to content

Commit 58bf7f0

Browse files
author
Evan Cameron
committed
chore(rustfmt): replace configs for new rls-rustfmt
1 parent 2b0614a commit 58bf7f0

File tree

11 files changed

+56
-372
lines changed

11 files changed

+56
-372
lines changed

alarm_base/src/frame.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use alloc::allocator::AllocErr;
33

44
/// An allocator that provides page frames.
55
pub unsafe trait Allocator {
6-
76
/// Architecture-dependent size of a physical page.
87
const FRAME_SIZE: usize;
98

@@ -21,9 +20,8 @@ pub unsafe trait Allocator {
2120
/// # Unsafety
2221
/// This function is unsafe because undefined behaviour may result if the
2322
/// given `frame` was not originally allocated by this `Allocator`.
24-
unsafe fn dealloc(&mut self, frame: Self::Frame) -> Result<(), AllocErr>;
23+
unsafe fn dealloc(&mut self, frame: Self::Frame) -> Result<(), AllocErr>;
2524

2625
// TODO: alloc_range/dealloc_range; requires an architecture-independent
2726
// way of representing frame ranges.
28-
2927
}

alarm_base/src/lend.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@
1212
//! or, "So You've Always Wished `*mut u8` Could `impl Drop`..."
1313
use alloc::allocator::{Alloc, AllocErr, Layout};
1414
use core::{mem, ops, ptr};
15-
1615
use spin;
1716

1817
/// An allocator that can provide borrowed handles.
1918
pub trait Lend {
20-
2119
/// The type of the allocator providing the allocation.
2220
///
2321
/// This has to be an associated type rather than `Self`
2422
/// so that `Lend` can be implemented for e.g. `Mutex<A>`.
2523
type Allocator: Alloc;
2624

2725
/// Borrow an allocation for a `T` from this lender.
28-
fn borrow<'a, T>(&'a self)
29-
-> Result<Borrowed<'a, T, Self::Allocator>, AllocErr>;
30-
26+
fn borrow<'a, T>(
27+
&'a self,
28+
) -> Result<Borrowed<'a, T, Self::Allocator>, AllocErr>;
3129
}
3230

3331
/// A borrowed handle on a heap allocation with a specified lifetime.
@@ -46,13 +44,11 @@ pub struct Borrowed<'alloc, T, A>
4644
where
4745
A: Alloc + 'alloc,
4846
{
49-
5047
/// The allocated value this `Borrowed` handle owns.
5148
value: ptr::NonNull<T>,
5249

5350
/// A reference to the allocator that provided us with T.
5451
allocator: &'alloc ::spin::Mutex<A>,
55-
5652
}
5753

5854
// ===== impl Lend =====
@@ -64,18 +60,17 @@ where
6460
type Allocator = A;
6561

6662
/// Borrow an allocation for a `T` from this lender.
67-
fn borrow<'a, T>(&'a self)
68-
-> Result<Borrowed<'a, T, Self::Allocator>, AllocErr> {
63+
fn borrow<'a, T>(
64+
&'a self,
65+
) -> Result<Borrowed<'a, T, Self::Allocator>, AllocErr> {
6966
let value = self.lock().alloc_one::<T>();
7067
value.map(|value| Borrowed {
7168
value,
7269
allocator: self,
7370
})
7471
}
75-
7672
}
7773

78-
7974
// ===== impl Borrowed =====
8075

8176
impl<'alloc, T, A> ops::Deref for Borrowed<'alloc, T, A>
@@ -85,7 +80,7 @@ where
8580
type Target = T;
8681

8782
#[inline]
88-
fn deref(&self) -> &Self::Target {
83+
fn deref(&self) -> &Self::Target {
8984
unsafe { self.value.as_ref() }
9085
}
9186
}
@@ -95,7 +90,7 @@ where
9590
A: Alloc + 'alloc,
9691
{
9792
#[inline]
98-
fn deref_mut(&mut self) -> &mut Self::Target {
93+
fn deref_mut(&mut self) -> &mut Self::Target {
9994
unsafe { self.value.as_mut() }
10095
}
10196
}
@@ -106,16 +101,13 @@ where
106101
{
107102
fn drop(&mut self) {
108103
let address = self.value.as_ptr();
109-
let layout = unsafe {
110-
Layout::for_value(self.value.as_ref())
111-
};
104+
let layout = unsafe { Layout::for_value(self.value.as_ref()) };
112105
// ensure we drop the object _before_ deallocating it, so that
113106
// the object's `Drop` gets run first.
114107
mem::drop(address);
115108
unsafe {
116109
// lock the allocator and deallocate the object.
117-
self.allocator.lock()
118-
.dealloc(address as *mut _, layout)
110+
self.allocator.lock().dealloc(address as *mut _, layout)
119111
}
120112
}
121113
}

alarm_base/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// Copyright (c) 2018 Eliza Weisman
66
// Released under the terms of the MIT license. See `LICENSE` in the root
77
// directory of this repository for more information.
8-
//
8+
//
99
//! Base types for ALARM allocators
10-
//!
10+
//!
1111
#![cfg_attr(not(feature = "std"), no_std)]
1212
#![deny(missing_docs)]
1313
#![feature(alloc, allocator_api)]

intruder_alarm/src/cursor.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
//! Cursors allowing bi-directional traversal of data structures.
1111
//!
12-
use core::iter::{self, Iterator, DoubleEndedIterator};
12+
use core::iter::{self, DoubleEndedIterator, Iterator};
1313

1414
//-----------------------------------------------------------------------------
1515
// Traits
@@ -47,23 +47,25 @@ pub trait Cursor {
4747
/// Return a reference to the next element from the cursor's position.
4848
fn peek_next(&self) -> Option<Self::Item>;
4949

50-
/// Return a reference to the previous element from the cursor's position.
50+
/// Return a reference to the previous element from the cursor's
51+
/// position.
5152
fn peek_back(&self) -> Option<Self::Item>;
5253

53-
/// Advance the cursor one element and return a reference to that element.
54+
/// Advance the cursor one element and return a reference to that
55+
/// element.
5456
#[inline]
5557
fn next_item(&mut self) -> Option<Self::Item> {
5658
self.move_forward();
5759
self.get()
5860
}
5961

60-
/// Move the cursor back one element and return a reference to that element.
62+
/// Move the cursor back one element and return a reference to that
63+
/// element.
6164
#[inline]
6265
fn prev_item(&mut self) -> Option<Self::Item> {
6366
self.move_back();
6467
self.get()
6568
}
66-
6769
}
6870

6971
/// A cursor that can mutate the parent data structure.
@@ -100,7 +102,6 @@ pub trait CursorMut<'a, T: 'a>: Cursor<Item = &'a mut T> {
100102
/// Insert the given item after the cursor's position.
101103
// TODO: ops::Place impl?
102104
fn insert_after(&mut self, item: T);
103-
104105
}
105106

106107
/// Conversion into a `Cursor``.
@@ -111,36 +112,32 @@ pub trait CursorMut<'a, T: 'a>: Cursor<Item = &'a mut T> {
111112
///
112113
/// ...yes, it's just `IntoIterator` for `Cursor`s.
113114
pub trait IntoCursor {
114-
115115
/// The type of the elements "under" the cursor.
116116
type Item;
117117

118118
/// Which kind of cursor are we turning this into?
119-
type IntoCursor: Cursor<Item=Self::Item>;
119+
type IntoCursor: Cursor<Item = Self::Item>;
120120

121121
/// Create a cursor from a value.
122122
fn into_iter(self) -> Self::IntoCursor;
123-
124123
}
125124

126125
// ===== impl Cursor =====
127126

128-
impl<I> Iterator for Cursor<Item = I>{
127+
impl<I> Iterator for Cursor<Item = I> {
129128
type Item = I;
130129

131130
#[inline]
132131
fn next(&mut self) -> Option<Self::Item> {
133132
self.next_item()
134133
}
135-
136134
}
137135

138136
impl<I> DoubleEndedIterator for Cursor<Item = I> {
139137
#[inline]
140138
fn next_back(&mut self) -> Option<Self::Item> {
141139
self.prev_item()
142140
}
143-
144141
}
145142

146143
// ===== impl IntoCursor =====
@@ -157,5 +154,3 @@ impl<I> DoubleEndedIterator for Cursor<Item = I> {
157154
// }
158155
//
159156
// }
160-
161-

intruder_alarm/src/doubly/mod.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//! like the allocator implementation itself, since each list element manages
99
//! its own memory.
1010
use super::{Link, OwningRef, UnsafeRef};
11-
1211
use core::iter::{Extend, FromIterator};
1312
use core::marker::PhantomData;
1413
use core::mem;
@@ -361,7 +360,7 @@ where
361360
#[inline]
362361
pub fn push_front<I>(&mut self, item: I) -> &mut Self
363362
where
364-
I: Into<UnsafeRef<Node>>
363+
I: Into<UnsafeRef<Node>>,
365364
{
366365
self.push_front_node(item.into())
367366
}
@@ -370,22 +369,17 @@ where
370369
#[inline]
371370
pub fn push_back<I>(&mut self, item: I) -> &mut Self
372371
where
373-
I: Into<UnsafeRef<Node>>
372+
I: Into<UnsafeRef<Node>>,
374373
{
375374
self.push_back_node(item.into())
376375
}
377376
}
378377

379-
380-
#[cfg(all(
381-
feature = "alloc",
382-
not(any(feature = "std", test))
383-
))]
378+
#[cfg(all(feature = "alloc", not(any(feature = "std", test))))]
384379
use alloc::boxed::Box;
385380
#[cfg(any(feature = "std", test))]
386381
use std::boxed::Box;
387382

388-
389383
#[cfg(any(feature = "alloc", feature = "std", test))]
390384
impl<T, Node> List<T, Node, Box<Node>>
391385
where
@@ -424,7 +418,6 @@ where
424418
}
425419
}
426420

427-
428421
#[cfg(any(feature = "alloc", feature = "std", test))]
429422
impl<T, Node> Extend<T> for List<T, Node, Box<Node>>
430423
where
@@ -453,7 +446,7 @@ where
453446

454447
impl<T, Node, Ref, E> FromIterator<E> for List<T, Node, Ref>
455448
where
456-
Self: Extend<E>
449+
Self: Extend<E>,
457450
{
458451
#[inline]
459452
fn from_iter<I: IntoIterator<Item = E>>(iter: I) -> Self {

intruder_alarm/src/doubly/tests.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ mod boxed {
7474

7575
pub type NumberedList = List<usize, NumberedNode, Box<NumberedNode>>;
7676

77-
7877
mod push_node {
7978
use super::*;
8079
use std::boxed::Box;
@@ -436,19 +435,16 @@ mod boxed {
436435
}
437436
}
438437

439-
440-
441438
mod unsafe_ref {
442439
use super::*;
443440
use UnsafeRef;
444441

445442
pub type UnsafeList = List<usize, NumberedNode, UnsafeRef<NumberedNode>>;
446443

447-
448444
mod push_node {
449445
use super::*;
450-
use std::boxed::Box;
451446
use UnsafeRef;
447+
use std::boxed::Box;
452448

453449
#[test]
454450
fn not_empty_after_first_push() {
@@ -818,7 +814,7 @@ mod unsafe_ref {
818814

819815
let ext = vec![
820816
UnsafeRef::boxed(NumberedNode::from(3)),
821-
UnsafeRef::boxed(NumberedNode::from(4))
817+
UnsafeRef::boxed(NumberedNode::from(4)),
822818
];
823819
list.extend(ext);
824820

@@ -828,12 +824,13 @@ mod unsafe_ref {
828824

829825
#[test]
830826
fn test_fromiter() {
831-
let list_a = (0..10).into_iter()
827+
let list_a = (0..10)
828+
.into_iter()
832829
.map(|i| UnsafeRef::boxed(NumberedNode::from(i)));
833830
let mut nlist = UnsafeList::from_iter(list_a);
834831

835832
for i in 0..10 {
836833
assert_eq!(nlist.pop_front_node().unwrap().number, i);
837834
}
838835
}
839-
}
836+
}

0 commit comments

Comments
 (0)