Skip to content

Instantly share code, notes, and snippets.

View arielb1's full-sized avatar

Ariel Ben-Yehuda arielb1

View GitHub Profile
struct stack<'a> {
next: Option<&'a stack<'a>>,
data: i32
}
fn main() -> () {
let a = stack { data: 0, next: None };
let b = stack { data: 1, next: Some(&a) };
let c = stack { data: 2, next: Some(&b) };
let mut cur = c;
@arielb1
arielb1 / gist:8960554
Last active August 29, 2015 13:56
stack example
struct stack<'a> {
next: Option<&'a stack<'a>>,
data: i32
}
fn doit(st: &stack) -> () {
if(st.data == 0) {
let mut cur = Some(st);
loop { match cur {
None => { break; }
expr: s-expr
| quote expr
| atom
s-expr: ( expr-body
expr-body: )
| expr expr-body
use std::cell::RefCell;
struct Context {
data: RefCell<i32>;
}
struct A<'a> {
context: &'a Context,
}
use std::cell::RefCell;
struct Context {
data: RefCell<i32>;
}
struct A<'a> {
context: &'a Context,
}
#0 0x00007ffff7769720 in rust_fail ()
from /tmp/tmp.Z1LMtWzUfO/servo/build/x86_64-unknown-linux-gnu/src/compiler/rust/x86_64-unknown-linux-gnu/stage2/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-3e5aeb83-0.9.so
#1 0x00007ffff76c6458 in rt::unwind::Unwinder::begin_unwind::hd890d6617f8679e9HCaO::v0.9 ()
from /tmp/tmp.Z1LMtWzUfO/servo/build/x86_64-unknown-linux-gnu/src/compiler/rust/x86_64-unknown-linux-gnu/stage2/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-3e5aeb83-0.9.so
#2 0x00007ffff291b621 in rt::unwind::begin_unwind::h5026f0b6238f5657am::v0.1 () at /tmp/tmp.Z1LMtWzUfO/servo/src/components/script/dom/bindings/utils.rs:55
#3 0x00007ffff2aa5099 in script::html::hubbub_html_parser::parse_html () at /tmp/tmp.Z1LMtWzUfO/servo/src/components/script/html/hubbub_html_parser.rs:40
#4 0x00007ffff2ab7a2e in load () at /tmp/tmp.Z1LMtWzUfO/servo/src/components/script/script_task.rs:795
#0 0x00007fffc89ac4e7 in llvm::ComputeMaskedBits(llvm::Value*, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetData const*, unsigned int) () from /usr/lib/x86_64-linux-gnu/libLLVM-3.0.so.1
#1 0x00007fffc89ab8a2 in llvm::ComputeMaskedBits(llvm::Value*, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetData const*, unsigned int) () from /usr/lib/x86_64-linux-gnu/libLLVM-3.0.so.1
#2 0x00007fffc89ac308 in llvm::ComputeMaskedBits(llvm::Value*, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetData const*, unsigned int) () from /usr/lib/x86_64-linux-gnu/libLLVM-3.0.so.1
#3 0x00007fffc91c2197 in llvm::getOrEnforceKnownAlignment(llvm::Value*, unsigned int, llvm::TargetData const*) ()
from /usr/lib/x86_64-linux-gnu/libLLVM-3.0.so.1
#4 0x00007fffc8d23b8e in ?? () from /usr/lib/x86_64-linux-gnu/libLLVM-3.0.so.1
#5 0x00007fffc8d684fb in ?? () from /usr/lib/x86_64-linux-gnu/libLLVM-3.0.so.1
#6 0x00007fffc8d688b6 in ?? () from /usr/lib/x86_64-linux-gnu/libLLVM-3.0.so.1
#7 0x00007f
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn(fn_id=syntax::ast::DefId{krate: 0u32, node: 622767u32}:mem::uninitialized, psubsts=Substs[types=[[];[];[core::raw::Slice<middle::trans::_match::Opt<'static,'static>>]], regions=erased], hash_id=middle::trans::monomorphize::MonoId{def: syntax::ast::DefId{krate: 0u32, node: 622767u32}, params: middle::subst::VecPerParamSpace<middle::ty::t>{type_limit: 0u, self_limit: 0u, content: collections::vec::Vec<middle::ty::t>{len: 1u, cap: 1u, ptr: (0x7fa612cc7a10 as *mut ())}}})
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn about to subst into unsafe fn() -> T
DEBUG:rustc::middle::trans::monomorphize: monomorphize_fn mangled to _ZN3mem13uninitialized20h8592197447129453343E
DEBUG:rustc::middle::trans::monomorphize: leaving monomorphic fn mem::uninitialized
DEBUG:rustc::middle::trans::monomorphize: leaving monomorphic fn ptr::read
DEBUG:rustc::middle::trans::monomorphize: leaving monomorphic fn mem::transmute_copy
DEBUG:rustc::middle::trans::monomorphize:
trait TypeFoldable {
fn fold_with(&self) -> Self;
}
impl<'a> TypeFoldable for &'a uint {
fn fold_with(&self) -> &'a uint { *self }
}
trait Subst {
fn subst(&self) -> Self;
trait MyItem<T> {}
impl<T> MyItem<T> for T {}
pub fn build_archive<'a, I: MyItem<&'a (|&uint|:'a)>>(files: I) {}
fn main() {
build_archive(&(|_| { }));
}