Skip to content

Instantly share code, notes, and snippets.

View jyn514's full-sized avatar

jyn jyn514

View GitHub Profile
@jyn514
jyn514 / borrow-checker-faqs.md
Created March 14, 2021 05:59
tips and tricks for dealing with the borrow-checker

(I plan to publish this as a blog post once a few people have looked at it and caught the obvious typos.)

I got lots of positive feedback about the FAQ section in my Rust 2020 blog post, so I'm trying that format again for another topic that's been requested a lot: How to fix common borrow-checker issues. This isn't meant to explain how or why the borrow checker works the way it does (see The Nomicon or Two Beautiful Rust Programs for that), just how to work around some of its current limitations.

@jyn514
jyn514 / rust-hardware.md
Created October 12, 2020 04:23
Hardware that I use for compiling rust

Projects

The main projects I work on are docs.rs, saltwater cc, and the rust compiler itself.

Hardware

Normally I compile on my laptop, which is a 4 core 7th gen i5 with 8 GB memory. When I started working on rustc itself, that was unbearably slow (over 45 minutes for a stage 1 build),

@jyn514
jyn514 / E0773.md
Last active August 29, 2020 13:46

A builtin-macro was attempted to be registered twice.

Erroneous code example:

#![feature(decl_macro)]
#![feature(rustc_attrs)]

#[rustc_builtin_macro]
pub macro test($item:item) {
import sys
from collections import defaultdict, Counter
def lexer():
for line in sys.stdin:
for token in line.split():
yield token
def lookup(var, scope):
while scope.get(var):
layout title date audience excerpt
post
the-intra-doc-links-saga
2020-08-08 00:01:14 -0400
developers

N.B. This post assumes some familiarity with [the Rust programming language][rust].

error[E0433]: failed to resolve: could not find `handle` in `sys`
--> library/std/src/sys/windows/ext/process.rs:13:27
|
13 | let handle = sys::handle::Handle::new(handle as *mut _);
| ^^^^^^ could not find `handle` in `sys`
error[E0425]: cannot find function `symlink_inner` in module `sys::fs`
--> library/std/src/sys/windows/ext/fs.rs:544:14
|
544 | sys::fs::symlink_inner(src.as_ref(), dst.as_ref(), false)
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `hexponent` crate."><meta name="keywords" content="rust, rustlang, rust-lang, hexponent"><title>hexponent - Rust</title><link rel="stylesheet" type="text/css" href="/normalize-20200726-1.47.0-nightly-6c8927b0c.css"><link rel="stylesheet" type="text/css" href="/rustdoc-20200726-1.47.0-nightly-6c8927b0c.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="/light-20200726-1.47.0-nightly-6c8927b0c.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="/dark-20200726-1.47.0-nightly-6c8927b0c.css" disabled ><link rel="stylesheet" type="text/css" href="/ayu-20200726-1.47.0-nightly-6c8927b0c.css" disabled ><script src="/storage-20200726-1.47.0-nightly-6c8927b0c.js"></script><noscript><link rel="stylesheet" href="/noscript-20200726-1.47.0-nightly-6c8927b0c.cs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"><meta content="width=device-width, initial-scale=1.0" name="viewport"><meta content="rustdoc" name="generator"><meta content="API documentation for the Rust `hexponent` crate." name="description"><meta content="rust, rustlang, rust-lang, hexponent" name="keywords"><title>hexponent - Rust</title><link href="/normalize-20200726-1.47.0-nightly-6c8927b0c.css" rel="stylesheet" type="text/css"><link href="/rustdoc-20200726-1.47.0-nightly-6c8927b0c.css" id="mainThemeStyle" rel="stylesheet" type="text/css"><link href="/light-20200726-1.47.0-nightly-6c8927b0c.css" id="themeStyle" rel="stylesheet" type="text/css"><link disabled="" href="/dark-20200726-1.47.0-nightly-6c8927b0c.css" rel="stylesheet" type="text/css"><link disabled="" href="/ayu-20200726-1.47.0-nightly-6c8927b0c.css" rel="stylesheet" type="text/css"><script src="/storage-20200726-1.47.0-nightly-6c8927b0c.js"></script><noscript><link rel="stylesheet" href="/noscript-20200726
Currently the behavior is as follows (where stageN <-> stage(N-1) artifacts, except for stage0 libstd):
- `x.py build --stage 0`:
- stage0 libstd
- stage0 rustc (but without putting rustc in stage1/)
This leaves you without any rustc at all except for the beta compiler
(https://github.com/rust-lang/rust/issues/73519). This is never what you want (currently you should use either `x.py check` or `x.py build --stage 0 src/libstd` instead).
- `x.py build --stage 1`:
5 KLPhash
5 a42-__-
5 aabb-quadtree
5 abci-rs
5 abort_on_panic
5 abra
5 absal
5 abstractgraph
5 aces
5 aci_ppm