about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@gmail>2013-07-11 18:00:21 +0200
committerMichael Woerister <michaelwoerister@gmail>2013-07-19 07:58:28 +0200
commit72cf2ee1368d385fa13772fd70b7a9e748aaec6b (patch)
tree3e8f95315d708e16d2b2dba4a966ee89e15c1edc
parenta1c5c798c7b8d7b556144ed3ba286936fb8ba639 (diff)
downloadrust-72cf2ee1368d385fa13772fd70b7a9e748aaec6b.tar.gz
rust-72cf2ee1368d385fa13772fd70b7a9e748aaec6b.zip
debuginfo: Implemented trait_method branch in create_function_metadata().
-rw-r--r--src/librustc/middle/trans/debuginfo.rs56
-rw-r--r--src/test/run-pass/issue-7712.rs27
2 files changed, 61 insertions, 22 deletions
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs
index cb76d27b8b0..9684dbd6bf9 100644
--- a/src/librustc/middle/trans/debuginfo.rs
+++ b/src/librustc/middle/trans/debuginfo.rs
@@ -280,30 +280,42 @@ pub fn create_function_metadata(fcx: fn_ctxt) -> DISubprogram {
 
     let fnitem = cx.tcx.items.get_copy(&fcx.id);
     let (ident, ret_ty, id) = match fnitem {
-      ast_map::node_item(ref item, _) => {
-        match item.node {
-          ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => {
-            (item.ident, ty, item.id)
-          }
-          _ => fcx.ccx.sess.span_bug(item.span,
-                                     "create_function_metadata: item bound to non-function")
+        ast_map::node_item(ref item, _) => {
+            match item.node {
+                ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => {
+                    (item.ident, ty, item.id)
+                }
+                _ => fcx.ccx.sess.span_bug(item.span,
+                                           "create_function_metadata: item bound to non-function")
+            }
         }
-      }
-      ast_map::node_method(@ast::method { decl: ast::fn_decl { output: ref ty, _ },
-                           id: id, ident: ident, _}, _, _) => {
-          (ident, ty, id)
-      }
-      ast_map::node_expr(ref expr) => {
-        match expr.node {
-          ast::expr_fn_block(ref decl, _) => {
-            let name = gensym_name("fn");
-            (name, &decl.output, expr.id)
-          }
-          _ => fcx.ccx.sess.span_bug(expr.span,
-                  "create_function_metadata: expected an expr_fn_block here")
+        ast_map::node_method(@ast::method { decl: ast::fn_decl { output: ref ty, _ },
+                             id: id, ident: ident, _}, _, _) => {
+            (ident, ty, id)
         }
-      }
-      _ => fcx.ccx.sess.bug("create_function_metadata: unexpected sort of node")
+        ast_map::node_expr(ref expr) => {
+            match expr.node {
+                ast::expr_fn_block(ref decl, _) => {
+                    let name = gensym_name("fn");
+                    (name, &decl.output, expr.id)
+                }
+                _ => fcx.ccx.sess.span_bug(expr.span,
+                        "create_function_metadata: expected an expr_fn_block here")
+            }
+        }
+        ast_map::node_trait_method(
+            @ast::provided(
+                @ast::method {
+                    decl: ast::fn_decl { output: ref ty, _ },
+                    id: id,
+                    ident: ident,
+                    _}
+            ),
+            _def_id,
+            _path) => {
+            (ident, ty, id)
+        }
+        _ => fcx.ccx.sess.bug("create_function_metadata: unexpected sort of node")
     };
 
     match dbg_cx(cx).created_functions.find(&id) {
diff --git a/src/test/run-pass/issue-7712.rs b/src/test/run-pass/issue-7712.rs
new file mode 100644
index 00000000000..d4faae415d2
--- /dev/null
+++ b/src/test/run-pass/issue-7712.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.
+
+// compile-flags:-Z debug-info
+
+#[allow(default_methods)];
+
+pub trait TraitWithDefaultMethod {
+    pub fn method(self) {
+        ()
+    }
+}
+
+struct MyStruct;
+
+impl TraitWithDefaultMethod for MyStruct { }
+
+fn main() {
+    MyStruct.method();
+}
\ No newline at end of file