]> git.lizzy.rs Git - rust.git/commitdiff
debuginfo: Implemented trait_method branch in create_function_metadata().
authorMichael Woerister <michaelwoerister@gmail>
Thu, 11 Jul 2013 16:00:21 +0000 (18:00 +0200)
committerMichael Woerister <michaelwoerister@gmail>
Fri, 19 Jul 2013 05:58:28 +0000 (07:58 +0200)
src/librustc/middle/trans/debuginfo.rs
src/test/run-pass/issue-7712.rs [new file with mode: 0644]

index cb76d27b8b0d32e41fedc0da10db8954d430278b..9684dbd6bf97a73894b1c1d7e04a7f3fc004ad0c 100644 (file)
@@ -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 (file)
index 0000000..d4faae4
--- /dev/null
@@ -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