Skip to content

Commit 72cf2ee

Browse files
debuginfo: Implemented trait_method branch in create_function_metadata().
1 parent a1c5c79 commit 72cf2ee

File tree

2 files changed

+61
-22
lines changed

2 files changed

+61
-22
lines changed

src/librustc/middle/trans/debuginfo.rs

+34-22
Original file line numberDiff line numberDiff line change
@@ -280,30 +280,42 @@ pub fn create_function_metadata(fcx: fn_ctxt) -> DISubprogram {
280280

281281
let fnitem = cx.tcx.items.get_copy(&fcx.id);
282282
let (ident, ret_ty, id) = match fnitem {
283-
ast_map::node_item(ref item, _) => {
284-
match item.node {
285-
ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => {
286-
(item.ident, ty, item.id)
287-
}
288-
_ => fcx.ccx.sess.span_bug(item.span,
289-
"create_function_metadata: item bound to non-function")
283+
ast_map::node_item(ref item, _) => {
284+
match item.node {
285+
ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => {
286+
(item.ident, ty, item.id)
287+
}
288+
_ => fcx.ccx.sess.span_bug(item.span,
289+
"create_function_metadata: item bound to non-function")
290+
}
290291
}
291-
}
292-
ast_map::node_method(@ast::method { decl: ast::fn_decl { output: ref ty, _ },
293-
id: id, ident: ident, _}, _, _) => {
294-
(ident, ty, id)
295-
}
296-
ast_map::node_expr(ref expr) => {
297-
match expr.node {
298-
ast::expr_fn_block(ref decl, _) => {
299-
let name = gensym_name("fn");
300-
(name, &decl.output, expr.id)
301-
}
302-
_ => fcx.ccx.sess.span_bug(expr.span,
303-
"create_function_metadata: expected an expr_fn_block here")
292+
ast_map::node_method(@ast::method { decl: ast::fn_decl { output: ref ty, _ },
293+
id: id, ident: ident, _}, _, _) => {
294+
(ident, ty, id)
304295
}
305-
}
306-
_ => fcx.ccx.sess.bug("create_function_metadata: unexpected sort of node")
296+
ast_map::node_expr(ref expr) => {
297+
match expr.node {
298+
ast::expr_fn_block(ref decl, _) => {
299+
let name = gensym_name("fn");
300+
(name, &decl.output, expr.id)
301+
}
302+
_ => fcx.ccx.sess.span_bug(expr.span,
303+
"create_function_metadata: expected an expr_fn_block here")
304+
}
305+
}
306+
ast_map::node_trait_method(
307+
@ast::provided(
308+
@ast::method {
309+
decl: ast::fn_decl { output: ref ty, _ },
310+
id: id,
311+
ident: ident,
312+
_}
313+
),
314+
_def_id,
315+
_path) => {
316+
(ident, ty, id)
317+
}
318+
_ => fcx.ccx.sess.bug("create_function_metadata: unexpected sort of node")
307319
};
308320

309321
match dbg_cx(cx).created_functions.find(&id) {

src/test/run-pass/issue-7712.rs

+27
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+
// compile-flags:-Z debug-info
12+
13+
#[allow(default_methods)];
14+
15+
pub trait TraitWithDefaultMethod {
16+
pub fn method(self) {
17+
()
18+
}
19+
}
20+
21+
struct MyStruct;
22+
23+
impl TraitWithDefaultMethod for MyStruct { }
24+
25+
fn main() {
26+
MyStruct.method();
27+
}

0 commit comments

Comments
 (0)