This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{ | |
collections::HashSet, | |
marker::PhantomData, | |
rc::{Rc, Weak}, | |
}; | |
use ghost_cell::{GhostCell, GhostToken}; | |
pub trait GhostCellContainer { | |
type Open<'brand>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Riffing on a recently-discovered unsoundness in rustc due to the type system not having a | |
//! termination checker: https://github.com/rust-lang/rust/issues/135011. | |
//! Based on https://github.com/rust-lang/rust/issues/135011#issuecomment-2577585549. | |
//! | |
//! The core of the issue is that the type system does not enforce termination of its terms. We | |
//! can use a classic trick to construct a non-terminating associated type that works as a | |
//! proof of a trait bound of our choice. We use this to prove any two types equal. | |
/// Type-level equality. Using two separate traits for clarity. | |
trait IdA { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Destructuring assignment | |
fn fibonacci(n: u64) -> u64 { | |
let mut a = 1; | |
let mut b = 1; | |
for _ in 0..n { | |
(a, b) = (a + b, a); | |
} | |
b | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(allocator_api)] | |
#![feature(slice_ptr_get)] | |
#![feature(strict_provenance)] | |
use core::{alloc::Layout, ptr::NonNull, sync::atomic::AtomicUsize}; | |
use std::alloc::{AllocError, Allocator}; | |
use std::marker::PhantomData; | |
/// Allocator backed by a provided buffer. Once the buffer is full, all subsequent allocations fail. | |
pub struct BufferAllocator<'a> { | |
/// The backing buffer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I wrote https://github.com/Nadrieril/type-walker to replace this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(arbitrary_self_types)] | |
#![allow(dead_code)] | |
macro_rules! assert_priority { | |
(prefer method on $expected:ident given: $($rest:tt)*) => { | |
{ | |
// Define one wrapper per entry, with any `foo` methods specified. | |
assert_priority!(@define_ptrs, $($rest)*); | |
// This is the `P<Q<...>>` type we want to play with. | |
type Combined = assert_priority!(@combined_type, $($rest)*); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Wrapper around `x.py`. Assumes it's being run from the root of the rustc repo. | |
RUSTC_REPO="$(realpath "$PWD")" | |
RUSTC_PERF_REPO="$RUSTC_REPO/../rustc-perf" | |
X_PY="$RUSTC_REPO/x.py" | |
RUSTC="$RUSTC_REPO/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" | |
RUSTFMT="$RUSTC_REPO/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" | |
cd $RUSTC_REPO || exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I used this shell.nix to build LineageOS 13.0 for my maguro (Samsung Galaxy Nexus GSM) phone | |
# The build instructions for normal Linuxes are here: https://wiki.lineageos.org/devices/maguro/build | |
# For NixOS, follow those instructions but skip anything related to installing packages | |
# Detailed instructions: | |
# cd into an empty directory of your choice | |
# copy this file there | |
# in nix-shell: | |
# $ repo init -u https://github.com/LineageOS/android.git -b cm-13.0 | |
# $ repo sync | |
# $ source build/envsetup.sh |