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) {
--- /dev/null
+// 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