Skip to content

Commit 2bdf4af

Browse files
committed
auto merge of #8796 : brson/rust/cstack, r=pnkfelix
2 parents c7657b7 + 0c89183 commit 2bdf4af

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

src/librustc/middle/stack_check.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ fn stack_check_item(v: StackCheckVisitor,
8080
visit::walk_method_helper(&mut v, method, new_cx);
8181
}
8282
}
83+
ast::item_trait(_, _, ref methods) => {
84+
for method in methods.iter() {
85+
match *method {
86+
ast::provided(@ref method) => {
87+
let safe_stack = fixed_stack_segment(method.attrs);
88+
let new_cx = Context {safe_stack: safe_stack, ..in_cx};
89+
visit::walk_method_helper(&mut v, method, new_cx);
90+
}
91+
ast::required(*) => ()
92+
}
93+
}
94+
}
8395
_ => {
8496
visit::walk_item(&mut v, item, in_cx);
8597
}

src/test/compile-fail/lint-cstack.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern {
12+
fn rust_get_test_int() -> std::libc::intptr_t;
13+
}
14+
15+
trait A {
16+
fn foo() {
17+
unsafe {
18+
rust_get_test_int(); //~ ERROR invoking non-Rust fn
19+
}
20+
}
21+
}
22+
23+
fn main() {
24+
}

src/test/run-pass/lint-cstack.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::libc;
12+
13+
extern {
14+
fn rust_get_test_int() -> libc::intptr_t;
15+
}
16+
17+
trait A {
18+
#[fixed_stack_segment]
19+
fn foo() {
20+
unsafe {
21+
rust_get_test_int();
22+
}
23+
}
24+
}
25+
26+
fn main() {
27+
}

0 commit comments

Comments
 (0)