auto merge of #8796 : brson/rust/cstack, r=pnkfelix

This commit is contained in:
bors 2013-09-12 21:30:47 -07:00
commit 2bdf4af012
3 changed files with 63 additions and 0 deletions

View File

@ -80,6 +80,18 @@ fn stack_check_item(v: StackCheckVisitor,
visit::walk_method_helper(&mut v, method, new_cx);
}
}
ast::item_trait(_, _, ref methods) => {
for method in methods.iter() {
match *method {
ast::provided(@ref method) => {
let safe_stack = fixed_stack_segment(method.attrs);
let new_cx = Context {safe_stack: safe_stack, ..in_cx};
visit::walk_method_helper(&mut v, method, new_cx);
}
ast::required(*) => ()
}
}
}
_ => {
visit::walk_item(&mut v, item, in_cx);
}

View File

@ -0,0 +1,24 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern {
fn rust_get_test_int() -> std::libc::intptr_t;
}
trait A {
fn foo() {
unsafe {
rust_get_test_int(); //~ ERROR invoking non-Rust fn
}
}
}
fn main() {
}

View File

@ -0,0 +1,27 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern {
fn rust_get_test_int() -> libc::intptr_t;
}
trait A {
#[fixed_stack_segment]
fn foo() {
unsafe {
rust_get_test_int();
}
}
}
fn main() {
}