Skip to content

Commit b59bbed

Browse files
committed
impl {Clone, Copy} where appropriate
1 parent 3ee1498 commit b59bbed

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

src/addr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct PhysAddr(u64);
3737
/// a valid sign extension and are not null either. So automatic sign extension would have
3838
/// overwritten possibly meaningful bits. This likely indicates a bug, for example an invalid
3939
/// address calculation.
40-
#[derive(Debug)]
40+
#[derive(Debug, Clone, Copy)]
4141
pub struct VirtAddrNotValid(u64);
4242

4343
impl VirtAddr {
@@ -245,7 +245,7 @@ impl Sub<VirtAddr> for VirtAddr {
245245
/// A passed `u64` was not a valid physical address.
246246
///
247247
/// This means that bits 52 to 64 are not were not all null.
248-
#[derive(Debug)]
248+
#[derive(Debug, Clone, Copy)]
249249
pub struct PhysAddrNotValid(u64);
250250

251251
impl PhysAddr {

src/instructions/port.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl PortReadWrite for u32 {
6363
}
6464

6565
/// An I/O port.
66-
#[derive(Debug)]
66+
#[derive(Debug, Clone, PartialEq, Eq)]
6767
pub struct Port<T: PortReadWrite> {
6868
port: u16,
6969
phantom: PhantomData<T>,

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![cfg_attr(feature = "deny-warnings", deny(missing_docs))]
1111
#![cfg_attr(not(feature = "deny-warnings"), warn(missing_docs))]
1212

13+
#![deny(missing_copy_implementations)]
1314
#![deny(missing_debug_implementations)]
1415

1516
#[cfg(test)]

src/registers/control.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use structures::paging::PhysFrame;
66
use PhysAddr;
77

88
/// Various control flags modifying the basic operation of the CPU.
9-
#[derive(Debug)]
9+
#[derive(Debug, Clone, Copy)]
1010
pub struct Cr0;
1111

1212
impl Cr0 {
@@ -92,7 +92,7 @@ bitflags! {
9292
}
9393

9494
/// Contains the physical address of the level 4 page table.
95-
#[derive(Debug)]
95+
#[derive(Debug, Clone, Copy)]
9696
pub struct Cr3;
9797

9898
impl Cr3 {

src/registers/model_specific.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Functions to read and write control registers.
22
33
/// A model specific register.
4-
#[derive(Debug)]
4+
#[derive(Debug, Clone, Copy)]
55
pub struct Msr(u32);
66

77
impl Msr {
@@ -26,7 +26,7 @@ impl Msr {
2626
}
2727

2828
/// The Extended Feature Enable Register.
29-
#[derive(Debug)]
29+
#[derive(Debug, Clone, Copy)]
3030
pub struct Efer;
3131

3232
impl Efer {

src/structures/gdt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl fmt::Debug for SegmentSelector {
5050
/// switching between user and kernel mode or for loading a TSS.
5151
///
5252
/// The GDT has a fixed size of 8 entries, trying to add more entries will panic.
53-
#[derive(Debug)]
53+
#[derive(Debug, Clone, Copy)]
5454
pub struct GlobalDescriptorTable {
5555
table: [u64; 8],
5656
next_free: usize,
@@ -109,7 +109,7 @@ impl GlobalDescriptorTable {
109109
///
110110
/// Segmentation is no longer supported in 64-bit mode, so most of the descriptor
111111
/// contents are ignored.
112-
#[derive(Debug)]
112+
#[derive(Debug, Clone, Copy)]
113113
pub enum Descriptor {
114114
/// Descriptor for a code or data segment.
115115
///

src/structures/idt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use {PrivilegeLevel, VirtAddr};
3131
/// [AMD64 manual volume 2](https://support.amd.com/TechDocs/24593.pdf)
3232
/// (with slight modifications).
3333
#[allow(missing_debug_implementations)]
34+
#[derive(Clone, Copy)]
3435
#[repr(C)]
3536
pub struct InterruptDescriptorTable {
3637
/// A divide by zero exception (`#DE`) occurs when the denominator of a DIV instruction or
@@ -637,6 +638,7 @@ impl EntryOptions {
637638
}
638639

639640
/// Represents the exception stack frame pushed by the CPU on exception entry.
641+
#[derive(Clone, Copy)]
640642
#[repr(C)]
641643
pub struct ExceptionStackFrame {
642644
/// This value points to the instruction that should be executed when the interrupt

src/structures/paging/page_table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub enum FrameError {
1818
}
1919

2020
/// A 64-bit page table entry.
21+
#[allow(missing_copy_implementations)]
2122
#[derive(Clone)]
2223
#[repr(transparent)]
2324
pub struct PageTableEntry {

src/structures/paging/recursive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ pub struct RecursivePageTable<'a> {
104104
/// An error indicating that the given page table is not recursively mapped.
105105
///
106106
/// Returned from `RecursivePageTable::new`.
107-
#[derive(Debug)]
107+
#[derive(Debug, Clone, Copy)]
108108
pub struct NotRecursivelyMapped;
109109

110110
/// This error is returned from `map_to` and similar methods.
111-
#[derive(Debug)]
111+
#[derive(Debug, Clone, Copy)]
112112
pub enum MapToError {
113113
/// An additional frame was needed for the mapping process, but the frame allocator
114114
/// returned `None`.
@@ -121,7 +121,7 @@ pub enum MapToError {
121121
}
122122

123123
/// An error indicating that an `unmap` call failed.
124-
#[derive(Debug)]
124+
#[derive(Debug, Clone, Copy)]
125125
pub enum UnmapError {
126126
/// An upper level page table entry has the `HUGE_PAGE` flag set, which means that the
127127
/// given page is part of a huge page and can't be freed individually.
@@ -133,7 +133,7 @@ pub enum UnmapError {
133133
}
134134

135135
/// An error indicating that an `update_flags` call failed.
136-
#[derive(Debug)]
136+
#[derive(Debug, Clone, Copy)]
137137
pub enum FlagUpdateError {
138138
/// The given page is not mapped to a physical frame.
139139
PageNotMapped,

0 commit comments

Comments
 (0)