Skip to content

Instantly share code, notes, and snippets.

View luqmana's full-sized avatar

Luqman Aden luqmana

View GitHub Profile
laden@corn-syrup [06:23:13] [/scratch/laden/rust/build] [issue-3678-wrappers-be-gone-2]
-> % RUST_LOG=rustc=1,rustc::middle::trans::foreign x86_64-unknown-linux-gnu/stage2/bin/rustc --cfg stage2 -O --cfg debug -Z no-debug-borrows --target=arm-linux-androideabi --android-cross-path=/scratch/laden/android-dev/standalone -D warnings --out-dir x86_64-unknown-linux-gnu/stage2/lib/rustc/arm-linux-androideabi/lib /scratch/laden/rust/src/libstd/std.rs
foo.rs:10:6: 10:7 warning: unused variable: `x` [-W unused-variable (default)]
foo.rs:10 fn mm(x: &TestNode) {}
^
rust: ~"add_clean([block 7fcfe42937b0], **{i64, *tydesc, *i8, *i8, {*{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}}, *{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}}, *{i64, *tydesc, *i8, *i8, {i64, i64, [{*{i64, *tydesc, *i8, *i8, {*{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}}, *{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}}, *{i64, *tydesc, *i8, *i8, {i64, i64, [{*{i64, *tydesc, *i8, *i8, {*{i64, *tydesc, *i8, *i8, {i64, i64, [i8 x 0]}},
-> % gdb --args x86_64-unknown-linux-gnu/stage2/bin/rustc --cfg stage2 -O --cfg debug -Z no-debug-borrows --target=arm-linux-androideabi --android-cross-path=/scratch/laden/android-dev/standalone -D warnings --out-dir x86_64-unknown-linux-gnu/stage2/lib/rustc/arm-linux-androideabi/lib /scratch/laden/rust/src/libstd/std.rs GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /export/scratch/laden/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc...(no debugging symbols found)...done.
@luqmana
luqmana / hashmap-macro.rs
Last active December 21, 2015 00:28
A macro to easily create and populate hash maps.
#![feature(macro_rules)]
extern crate collections;
use collections::HashMap;
// A macro to easily create and populate hash maps
macro_rules! hashmap(
{ $($key:expr => $value:expr),+ } => {
{
use std::cell::Cell;
use std::rt::io::net::tcp::TcpListener;
use std::rt::io::net::ip::Ipv4;
use std::rt::io::{Listener, Writer};
fn main() {
let mut listener = TcpListener::bind(Ipv4(0, 0, 0, 0, 6767))
.expect("Unable to bind to 0.0.0.0:6767");
loop {
fn main() {
let b = test_nd_dr(8, 3);
assert_eq!(b, 2);
}
fn test_nd_dr(n: i8, d: i8) -> i8 {
let separate_div_rem = (n / d, n % d);
let combined_div_rem = n.div_rem(&d);
let (_, b) = separate_div_rem;
fn find_fn(ccx: @mut CrateContext, fn_id: ast::node_id) -> Option<codemap::span> {
match ccx.tcx.def_map.find(&fn_id) {
Some(&ast::def_fn(def_id, _)) => {
if ast_util::is_local(def_id) {
match ccx.tcx.items.find(&def_id.node) {
Some(&ast_map::node_item(item, _)) => {
match item.node {
ast::item_fn(*) => Some(item.span),
_ => None
; ModuleID = 'rust.rc'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%tydesc = type { i64, i64, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)* }
%enum.ValidUsage = type { i64, i64, [0 x i8] }
%enum.Action = type { i64, void (%enum.ValidUsage*, { i64, %tydesc*, i8*, i8*, i8 }*, { { i64, i64, [0 x i8] }**, i64 }*)*, [16 x i8] }
%str_slice = type { i8*, i64 }
%enum.UsageSource = type { i64, %str_slice, [0 x i8] }
%"enum.std::libc::types::common::c95::c_void[#1]" = type {}
struct Parent;
impl Parent {
fn new_child<'a>(&'a self) -> Child<'a> {
Child {
parent: self
}
}
}
struct Point {
x: int,
y: int
}
trait Positioned {
fn x(&self)-> int;
fn y(&self)-> int;
fn setX(&mut self, int);
fn setY(&mut self, int);
@luqmana
luqmana / rqsrt.rs
Last active December 16, 2015 15:39
fn libc_rsqrt(f: &f32) -> f32 {
1.0/f32::sqrt(*f)
}
fn llvm_rsqrt(f: &f32) -> f32 {
1.0/core::unstable::intrinsics::sqrtf32(*f)
}
fn asm_rsqrt(f: &f32) -> f32 {
let mut b = &0.0f32;
unsafe {
asm!("rsqrtss ($0), %xmm0\n\t\