Skip to content

Commit 6beb003

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

File tree

11 files changed

+45
-370
lines changed

11 files changed

+45
-370
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: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@
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>(&'a self) -> Result<Borrowed<'a, T, Self::Allocator>, AllocErr>;
3127
}
3228

3329
/// A borrowed handle on a heap allocation with a specified lifetime.
@@ -46,13 +42,11 @@ pub struct Borrowed<'alloc, T, A>
4642
where
4743
A: Alloc + 'alloc,
4844
{
49-
5045
/// The allocated value this `Borrowed` handle owns.
5146
value: ptr::NonNull<T>,
5247

5348
/// A reference to the allocator that provided us with T.
5449
allocator: &'alloc ::spin::Mutex<A>,
55-
5650
}
5751

5852
// ===== impl Lend =====
@@ -64,18 +58,15 @@ where
6458
type Allocator = A;
6559

6660
/// Borrow an allocation for a `T` from this lender.
67-
fn borrow<'a, T>(&'a self)
68-
-> Result<Borrowed<'a, T, Self::Allocator>, AllocErr> {
61+
fn borrow<'a, T>(&'a self) -> Result<Borrowed<'a, T, Self::Allocator>, AllocErr> {
6962
let value = self.lock().alloc_one::<T>();
7063
value.map(|value| Borrowed {
7164
value,
7265
allocator: self,
7366
})
7467
}
75-
7668
}
7769

78-
7970
// ===== impl Borrowed =====
8071

8172
impl<'alloc, T, A> ops::Deref for Borrowed<'alloc, T, A>
@@ -85,7 +76,7 @@ where
8576
type Target = T;
8677

8778
#[inline]
88-
fn deref(&self) -> &Self::Target {
79+
fn deref(&self) -> &Self::Target {
8980
unsafe { self.value.as_ref() }
9081
}
9182
}
@@ -95,7 +86,7 @@ where
9586
A: Alloc + 'alloc,
9687
{
9788
#[inline]
98-
fn deref_mut(&mut self) -> &mut Self::Target {
89+
fn deref_mut(&mut self) -> &mut Self::Target {
9990
unsafe { self.value.as_mut() }
10091
}
10192
}
@@ -106,16 +97,13 @@ where
10697
{
10798
fn drop(&mut self) {
10899
let address = self.value.as_ptr();
109-
let layout = unsafe {
110-
Layout::for_value(self.value.as_ref())
111-
};
100+
let layout = unsafe { Layout::for_value(self.value.as_ref()) };
112101
// ensure we drop the object _before_ deallocating it, so that
113102
// the object's `Drop` gets run first.
114103
mem::drop(address);
115104
unsafe {
116105
// lock the allocator and deallocate the object.
117-
self.allocator.lock()
118-
.dealloc(address as *mut _, layout)
106+
self.allocator.lock().dealloc(address as *mut _, layout)
119107
}
120108
}
121109
}

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: 3 additions & 11 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
@@ -63,7 +63,6 @@ pub trait Cursor {
6363
self.move_back();
6464
self.get()
6565
}
66-
6766
}
6867

6968
/// A cursor that can mutate the parent data structure.
@@ -100,7 +99,6 @@ pub trait CursorMut<'a, T: 'a>: Cursor<Item = &'a mut T> {
10099
/// Insert the given item after the cursor's position.
101100
// TODO: ops::Place impl?
102101
fn insert_after(&mut self, item: T);
103-
104102
}
105103

106104
/// Conversion into a `Cursor``.
@@ -111,36 +109,32 @@ pub trait CursorMut<'a, T: 'a>: Cursor<Item = &'a mut T> {
111109
///
112110
/// ...yes, it's just `IntoIterator` for `Cursor`s.
113111
pub trait IntoCursor {
114-
115112
/// The type of the elements "under" the cursor.
116113
type Item;
117114

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

121118
/// Create a cursor from a value.
122119
fn into_iter(self) -> Self::IntoCursor;
123-
124120
}
125121

126122
// ===== impl Cursor =====
127123

128-
impl<I> Iterator for Cursor<Item = I>{
124+
impl<I> Iterator for Cursor<Item = I> {
129125
type Item = I;
130126

131127
#[inline]
132128
fn next(&mut self) -> Option<Self::Item> {
133129
self.next_item()
134130
}
135-
136131
}
137132

138133
impl<I> DoubleEndedIterator for Cursor<Item = I> {
139134
#[inline]
140135
fn next_back(&mut self) -> Option<Self::Item> {
141136
self.prev_item()
142137
}
143-
144138
}
145139

146140
// ===== impl IntoCursor =====
@@ -157,5 +151,3 @@ impl<I> DoubleEndedIterator for Cursor<Item = I> {
157151
// }
158152
//
159153
// }
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)