Skip to content

Instantly share code, notes, and snippets.

begin_LIR
1 label () <|@
2 parthreadcontext ([i:2 (=rax)]) t=([i:1 (=rax)]) <|@
0 movegroup () <|@
3 nop () <|@
4 parameter ([x:3 (arg:0)]) <|@
5 parameter ([x:4 (arg:8)]) <|@
6 start () <|@
0 movegroup ()[arg:8 -> =rcx] <|@
7 unbox ([i:5 (=rdx)]) (=rcx) <|@
struct dtor {
x: @mut int;
drop {
// abuse access to shared mutable state to write this code
*self.x -= 1;
}
}
fn unwrap<T>(+o: option<T>) -> T {
diff --git a/src/libcore/future.rs b/src/libcore/future.rs
index c24d482..22fb9ce 100644
--- a/src/libcore/future.rs
+++ b/src/libcore/future.rs
@@ -34,6 +34,10 @@ export future_pipe;
#[doc = "The future type"]
struct Future<A> {
/*priv*/ mut state: FutureState<A>;
+
+ // FIXME(#2829) -- futures should not be copyable, because they close
Before:
```
match bv {
env_copy(val, ty, lv_owned) => {
let val1 = load_if_immediate(bcx, val, ty);
bcx = base::copy_val(bcx, INIT, bound_data, val1, ty);
}
env_copy(val, ty, lv_owned_imm) => {
bcx = base::copy_val(bcx, INIT, bound_data, val, ty);
commit 04f17634091587053ae7d7d35d2318406e8d7d0d
Author: Niko Matsakis <[email protected]>
Date: Mon Sep 10 12:25:45 2012 -0700
Combine the vtable_origins from impl + method.
Not as clean as it could be, but fixes #3314.
diff --git a/src/rustc/middle/trans/callee.rs b/src/rustc/middle/trans/callee.rs
index a92f8c9..874eb86 100644
// Adapted from
//
// https://github.com/RiverTrail/RiverTrail/blob/master/examples/mandelbrot/mandelbrot.js
//
// which in turn is adapted from a WebCL implementation available at
//
// http://www.ibiblio.org/e-notes/webcl/mandelbrot.html
var nc = 30, maxCol = nc*3, cr,cg,cb;
@nikomatsakis
nikomatsakis / gist:3718481
Created September 13, 2012 23:11
Modeling Purity as an effect system.md

Mapping from a more formal effect system to ours:

  • Let fn:E() be a function with effects E
  • Assume an effect lattice: pure -> impure -> unsafe
  • fn foo(...) declares a function with effects impure
  • pure fn foo() declares a functon with effects defined as follows: - let each argument of closure type have an effect variable: x: fn:X() - the effect of foo() is sum(X for all X) - if no closure arguments, the effect is pure
  • calling a function with type fn:X() has the effect X
use std;
use glfw3;
import glfw3::*;
fn main() {
do task::task().sched_mode(task::PlatformThread).spawn {
if (glfwInit() == 0) {
glfwTerminate();
extern mod std;
use io::WriterUtil;
use send_map::linear;
/// Represents a json value
enum Json {
Number(float),
String(~str),
Boolean(bool),
fn main() {
let (ch, po) = pipes::stream();
do task::spawn {
...
ch.send(22);
}
let r = po.recv();
assert r == 2;
}