Skip to content

Commit

Permalink
Use consisntent style of size_of in query type erasure
Browse files Browse the repository at this point in the history
All other impls replace type generics with `()` (or a type implementing the necessery traits)
and lifetimes with `'static`, do the same for those impls.
  • Loading branch information
WaffleLapkin committed Oct 3, 2023
1 parent 61361bb commit b3d5025
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/query/erase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::mir;
use crate::query::CyclePlaceholder;
use crate::traits;
use crate::ty::{self, Ty};
use std::mem::{size_of, MaybeUninit};
use std::intrinsics::transmute_unchecked;
use std::mem::{size_of, MaybeUninit};

#[derive(Copy, Clone)]
pub struct Erased<T: Copy> {
Expand Down Expand Up @@ -46,15 +46,15 @@ pub fn restore<T: EraseType>(value: Erase<T>) -> T {
}

impl<T> EraseType for &'_ T {
type Result = [u8; size_of::<*const ()>()];
type Result = [u8; size_of::<&'static ()>()];
}

impl<T> EraseType for &'_ [T] {
type Result = [u8; size_of::<*const [()]>()];
type Result = [u8; size_of::<&'static [()]>()];
}

impl<T> EraseType for &'_ ty::List<T> {
type Result = [u8; size_of::<*const ()>()];
type Result = [u8; size_of::<&'static ty::List<()>>()];
}

impl<I: rustc_index::Idx, T> EraseType for &'_ rustc_index::IndexSlice<I, T> {
Expand Down

0 comments on commit b3d5025

Please sign in to comment.