1
Fork 0

Use ptr::Alignment for extra coolness points

This commit is contained in:
Maybe Waffle 2023-04-14 12:29:10 +00:00
parent 36f5918bf1
commit 014c6f208e
8 changed files with 27 additions and 29 deletions

View file

@ -59,6 +59,7 @@
#![feature(result_option_inspect)]
#![feature(const_option)]
#![feature(trait_alias)]
#![feature(ptr_alignment_type)]
#![recursion_limit = "512"]
#![allow(rustc::potential_query_instability)]

View file

@ -1,5 +1,5 @@
use crate::arena::Arena;
use rustc_data_structures::aligned::Aligned;
use rustc_data_structures::aligned::{align_of, Aligned};
use rustc_serialize::{Encodable, Encoder};
use std::alloc::Layout;
use std::cmp::Ordering;
@ -203,13 +203,13 @@ unsafe impl<T: Sync> Sync for List<T> {}
// Layouts of `Equivalent<T>` and `List<T>` are the same, modulo opaque tail,
// thus aligns of `Equivalent<T>` and `List<T>` must be the same.
unsafe impl<T> Aligned for List<T> {
const ALIGN: usize = {
const ALIGN: ptr::Alignment = {
#[repr(C)]
struct Equivalent<T> {
_len: usize,
_data: [T; 0],
}
mem::align_of::<Equivalent<T>>()
align_of::<Equivalent<T>>()
};
}

View file

@ -1626,7 +1626,8 @@ struct ParamTag {
}
unsafe impl rustc_data_structures::tagged_ptr::Tag for ParamTag {
const BITS: usize = 2;
const BITS: u32 = 2;
#[inline]
fn into_usize(self) -> usize {
match self {
@ -1636,6 +1637,7 @@ unsafe impl rustc_data_structures::tagged_ptr::Tag for ParamTag {
Self { reveal: traits::Reveal::All, constness: hir::Constness::Const } => 3,
}
}
#[inline]
unsafe fn from_usize(ptr: usize) -> Self {
match ptr {