auto merge of #8796 : brson/rust/cstack, r=pnkfelix
This commit is contained in:
commit
2bdf4af012
@ -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);
|
||||
}
|
||||
|
24
src/test/compile-fail/lint-cstack.rs
Normal file
24
src/test/compile-fail/lint-cstack.rs
Normal 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() {
|
||||
}
|
27
src/test/run-pass/lint-cstack.rs
Normal file
27
src/test/run-pass/lint-cstack.rs
Normal 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() {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user