Prepared std::sys for removal, and made begin_unwind simpler
- `begin_unwind` is now generic over any `T: Any + Send`. - Every value you fail with gets boxed as an `~Any`. - Because of implementation details, `&'static str` and `~str` are still handled specially behind the scenes. - Changed the big macro source string in libsyntax to a raw string literal, and enabled doc comments there.
This commit is contained in:
parent
e42e378f32
commit
54f4dcd76a
16 changed files with 187 additions and 229 deletions
|
|
@ -19,7 +19,7 @@ use rt::borrowck;
|
|||
#[cold]
|
||||
#[lang="fail_"]
|
||||
pub fn fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
|
||||
task::begin_unwind(expr, file, line);
|
||||
task::begin_unwind_raw(expr, file, line);
|
||||
}
|
||||
|
||||
#[cold]
|
||||
|
|
|
|||
|
|
@ -62,3 +62,33 @@ impl Repr<*Box<String>> for @str {}
|
|||
|
||||
// sure would be nice to have this
|
||||
// impl<T> Repr<*Vec<T>> for ~[T] {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use cast;
|
||||
|
||||
#[test]
|
||||
fn synthesize_closure() {
|
||||
unsafe {
|
||||
let x = 10;
|
||||
let f: &fn(int) -> int = |y| x + y;
|
||||
|
||||
assert_eq!(f(20), 30);
|
||||
|
||||
let original_closure: Closure = cast::transmute(f);
|
||||
|
||||
let actual_function_pointer = original_closure.code;
|
||||
let environment = original_closure.env;
|
||||
|
||||
let new_closure = Closure {
|
||||
code: actual_function_pointer,
|
||||
env: environment
|
||||
};
|
||||
|
||||
let new_f: &fn(int) -> int = cast::transmute(new_closure);
|
||||
assert_eq!(new_f(20), 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue