about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/stack_check.rs12
-rw-r--r--src/test/compile-fail/lint-cstack.rs24
-rw-r--r--src/test/run-pass/lint-cstack.rs27
3 files changed, 63 insertions, 0 deletions
diff --git a/src/librustc/middle/stack_check.rs b/src/librustc/middle/stack_check.rs
index 569c6dfde0c..7ab6cfcdf7b 100644
--- a/src/librustc/middle/stack_check.rs
+++ b/src/librustc/middle/stack_check.rs
@@ -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);
         }
diff --git a/src/test/compile-fail/lint-cstack.rs b/src/test/compile-fail/lint-cstack.rs
new file mode 100644
index 00000000000..11fe02eaef5
--- /dev/null
+++ b/src/test/compile-fail/lint-cstack.rs
@@ -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() {
+}
diff --git a/src/test/run-pass/lint-cstack.rs b/src/test/run-pass/lint-cstack.rs
new file mode 100644
index 00000000000..b9e61b47e22
--- /dev/null
+++ b/src/test/run-pass/lint-cstack.rs
@@ -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() {
+}