diff --git a/ahci/Cargo.toml b/ahci/Cargo.toml index 8504588c1..61c8ef5d3 100644 --- a/ahci/Cargo.toml +++ b/ahci/Cargo.toml @@ -11,8 +11,11 @@ kfs-libutils = { path = "../libutils" } spin = "0.4" log = "0.4.6" bitfield = "0.13.1" -static_assertions = "0.3.1" [dependencies.lazy_static] features = ["spin_no_std"] version = "1.3.0" + +[dependencies.static_assertions] +version = "0.3.1" +features = ["nightly"] diff --git a/ahci/src/hba.rs b/ahci/src/hba.rs index 747cc6fe4..769d61b17 100644 --- a/ahci/src/hba.rs +++ b/ahci/src/hba.rs @@ -1026,7 +1026,7 @@ pub struct CmdHeaderArray { pub slots: [CmdHeader; 32] } -assert_eq_size!(size_CmdHeaderArray; CmdHeaderArray, [u8; 1024]); +assert_eq_size!(CmdHeaderArray, [u8; 1024]); unsafe impl ZeroInitialized for CmdHeaderArray {} @@ -1068,7 +1068,7 @@ pub struct CmdTable { // 248 entries fills the rest of the page. } -assert_eq_size!(size_CmdTable; CmdTable, [u8; 4096]); +assert_eq_size!(CmdTable, [u8; 4096]); unsafe impl ZeroInitialized for CmdTable {} @@ -1084,7 +1084,7 @@ union Cfis { // ... } -assert_eq_size!(size_Cfis; Cfis, [u8; 64]); +assert_eq_size!(Cfis, [u8; 64]); /// Physical Region Descriptor Table entry. /// @@ -1189,7 +1189,7 @@ pub struct ReceivedFis { _rsv3: [u8; 0x60], } -assert_eq_size!(size_ReceivedFis; ReceivedFis, [u8; 0x100]); +assert_eq_size!(ReceivedFis, [u8; 0x100]); unsafe impl ZeroInitialized for ReceivedFis {} diff --git a/ahci/src/main.rs b/ahci/src/main.rs index 083b3faab..578e71792 100644 --- a/ahci/src/main.rs +++ b/ahci/src/main.rs @@ -39,7 +39,7 @@ //! simultaneously. Unfortunately we can't take advantage of that until we manage to //! make command-completion interrupts work. -#![feature(alloc, maybe_uninit, box_syntax, untagged_unions, const_vec_new)] +#![feature(alloc, maybe_uninit, box_syntax, untagged_unions, const_vec_new, underscore_const_names)] #![no_std] // rustc warnings diff --git a/bootstrap/Cargo.toml b/bootstrap/Cargo.toml index 40bb1cb6a..70db96643 100644 --- a/bootstrap/Cargo.toml +++ b/bootstrap/Cargo.toml @@ -15,7 +15,6 @@ bit_field = "0.9.0" bitflags = "1.0" multiboot2 = { git = "https://github.com/roblabla/multiboot2-elf64" } spin = "0.5.0" -static_assertions = "*" xmas-elf = "0.6.2" [dependencies.smallvec] @@ -29,3 +28,7 @@ version = "0.4.10" [dependencies.lazy_static] features = ["spin_no_std"] version = "1.3.0" + +[dependencies.static_assertions] +version = "0.3.1" +features = ["nightly"] diff --git a/bootstrap/src/main.rs b/bootstrap/src/main.rs index 6efde37c3..c752abfb3 100644 --- a/bootstrap/src/main.rs +++ b/bootstrap/src/main.rs @@ -22,7 +22,7 @@ //! fancy logging interfaces that the kernel has. //! -#![feature(lang_items, start, asm, global_asm, compiler_builtins_lib, naked_functions, core_intrinsics, const_fn, abi_x86_interrupt)] +#![feature(lang_items, start, asm, global_asm, compiler_builtins_lib, naked_functions, core_intrinsics, const_fn, abi_x86_interrupt, underscore_const_names)] #![no_std] #![cfg_attr(target_os = "none", no_main)] diff --git a/bootstrap/src/paging/mod.rs b/bootstrap/src/paging/mod.rs index cf6b091a6..32c26783a 100644 --- a/bootstrap/src/paging/mod.rs +++ b/bootstrap/src/paging/mod.rs @@ -167,16 +167,14 @@ impl VirtualSpaceLand for UserLand { // Assertions to check that Kernel/User pages falls on distinct page tables // and also that they do not overlap -fn __land_assertions() { - const_assert!(KernelLand::start_addr().0 < KernelLand::end_addr().0); - const_assert!(UserLand::start_addr().0 < UserLand::end_addr().0); - // TODO: Const FN sucks! Check that the kernelland and userland don't overlap. - //const_assert!(::core::cmp::max(KernelLand::start_addr(), UserLand::start_addr()) >= - // ::core::cmp::min(KernelLand::end_addr(), UserLand::end_addr())); - - const_assert!(KernelLand::start_addr().0 % (ENTRY_COUNT * PAGE_SIZE) == 0); - const_assert!(UserLand::start_addr().0 % (ENTRY_COUNT * PAGE_SIZE) == 0); -} +const_assert!(KernelLand::start_addr().0 < KernelLand::end_addr().0); +const_assert!(UserLand::start_addr().0 < UserLand::end_addr().0); +// TODO: Const FN sucks! Check that the kernelland and userland don't overlap. +//const_assert!(::core::cmp::max(KernelLand::start_addr(), UserLand::start_addr()) >= +// ::core::cmp::min(KernelLand::end_addr(), UserLand::end_addr())); + +const_assert!(KernelLand::start_addr().0 % (ENTRY_COUNT * PAGE_SIZE) == 0); +const_assert!(UserLand::start_addr().0 % (ENTRY_COUNT * PAGE_SIZE) == 0); /// Creates a mapping in the page tables with the given flags. /// Allocates the pointed page and chooses the virtual address. diff --git a/bootstrap/src/paging/table.rs b/bootstrap/src/paging/table.rs index ba30fa8b3..330bb2e4a 100644 --- a/bootstrap/src/paging/table.rs +++ b/bootstrap/src/paging/table.rs @@ -24,12 +24,9 @@ pub struct PageTable { /// A page directory pub struct PageDirectory(PageTable); -// Assertions -fn __assertions() { - const_assert!(::core::mem::size_of::() >= MEMORY_FRAME_SIZE); - const_assert!(::core::mem::size_of::() >= MEMORY_FRAME_SIZE); - const_assert!(::core::mem::size_of::() == ::core::mem::size_of::()); -} +const_assert!(::core::mem::size_of::() >= MEMORY_FRAME_SIZE); +const_assert!(::core::mem::size_of::() >= MEMORY_FRAME_SIZE); +const_assert!(::core::mem::size_of::() == ::core::mem::size_of::()); /// When paging is on, accessing this address loops back to the directory itself thanks to /// recursive mapping on directory's last entry diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 50ecf96ad..c46f47677 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -24,7 +24,6 @@ bit_field = "0.9.0" bitflags = "1.0" multiboot2 = { git = "https://github.com/roblabla/multiboot2-elf64" } spin = "0.5" -static_assertions = "0.3.1" linked_list_allocator = "0.6.2" log = "0.4.6" xmas-elf = "0.6.2" @@ -48,3 +47,7 @@ version = "0.1.8" [dependencies.lazy_static] features = ["spin_no_std"] version = "1.3.0" + +[dependencies.static_assertions] +version = "0.3.1" +features = ["nightly"] diff --git a/kernel/src/i386/mod.rs b/kernel/src/i386/mod.rs index aa072304c..d98cb028f 100644 --- a/kernel/src/i386/mod.rs +++ b/kernel/src/i386/mod.rs @@ -342,7 +342,7 @@ impl Default for TssStruct { } } -const_assert_eq!(tss_struct_size; ::core::mem::size_of::(), 0x68); +const_assert_eq!(::core::mem::size_of::(), 0x68); impl TssStruct { /// Creates a new TssStruct. diff --git a/kernel/src/i386/structures/idt.rs b/kernel/src/i386/structures/idt.rs index 567dc5678..1d0379699 100644 --- a/kernel/src/i386/structures/idt.rs +++ b/kernel/src/i386/structures/idt.rs @@ -392,7 +392,7 @@ impl fmt::Debug for Idt { } } -const_assert_eq!(const_assert_idt; mem::size_of::(), 256 * 8); +const_assert_eq!(mem::size_of::(), 256 * 8); impl Idt { @@ -544,7 +544,7 @@ impl fmt::Debug for IdtEntry { } } -const_assert_eq!(const_assert_idtentry; mem::size_of::>(), 8); +const_assert_eq!(mem::size_of::>(), 8); /// A handler function for an interrupt or an exception without error code. pub type HandlerFunc = extern "x86-interrupt" fn(&mut ExceptionStackFrame); diff --git a/kernel/src/main.rs b/kernel/src/main.rs index 1164e6f93..f645a4109 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -6,7 +6,7 @@ //! Currently doesn't do much, besides booting and printing Hello World on the //! screen. But hey, that's a start. -#![feature(lang_items, start, asm, global_asm, compiler_builtins_lib, naked_functions, core_intrinsics, const_fn, abi_x86_interrupt, allocator_api, alloc, box_syntax, no_more_cas, const_vec_new, range_contains, step_trait, thread_local, nll)] +#![feature(lang_items, start, asm, global_asm, compiler_builtins_lib, naked_functions, core_intrinsics, const_fn, abi_x86_interrupt, allocator_api, alloc, box_syntax, no_more_cas, const_vec_new, range_contains, step_trait, thread_local, nll, underscore_const_names)] #![no_std] #![cfg_attr(target_os = "none", no_main)] #![recursion_limit = "1024"] diff --git a/kernel/src/paging/lands.rs b/kernel/src/paging/lands.rs index e3f25cf2b..669049820 100644 --- a/kernel/src/paging/lands.rs +++ b/kernel/src/paging/lands.rs @@ -110,15 +110,12 @@ impl VirtualSpaceLand for RecursiveTablesLand { /// Assertions to check that Kernel/User pages falls on distinct page tables /// and also that they do not overlap. -fn __land_assertions() { - const_assert!(KernelLand::START.0 < KernelLand::END.0); - const_assert!(UserLand::START.0 < UserLand::END.0); - const_assert!(RecursiveTablesLand::START.0 < RecursiveTablesLand::END.0); - // TODO: Const FN sucks! Check that the kernelland and userland don't overlap. - //const_assert!(::core::cmp::max(KernelLand::start_addr(), UserLand::start_addr()) >= - // ::core::cmp::min(KernelLand::end_addr(), UserLand::end_addr())); - - const_assert!(KernelLand::START.0 % (ENTRY_COUNT * PAGE_SIZE) == 0); - const_assert!(UserLand::START.0 % (ENTRY_COUNT * PAGE_SIZE) == 0); -} - +const_assert!(KernelLand::START.0 < KernelLand::END.0); +const_assert!(UserLand::START.0 < UserLand::END.0); +const_assert!(RecursiveTablesLand::START.0 < RecursiveTablesLand::END.0); +// TODO: Const FN sucks! Check that the kernelland and userland don't overlap. +//const_assert!(::core::cmp::max(KernelLand::start_addr(), UserLand::start_addr()) >= +// ::core::cmp::min(KernelLand::end_addr(), UserLand::end_addr())); + +const_assert!(KernelLand::START.0 % (ENTRY_COUNT * PAGE_SIZE) == 0); +const_assert!(UserLand::START.0 % (ENTRY_COUNT * PAGE_SIZE) == 0);