Skip to content

Include type name in symbol for methods #30328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/front/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
// Pick the def data. This need not be unique, but the more
// information we encapsulate into
let def_data = match i.node {
ItemDefaultImpl(..) | ItemImpl(..) => DefPathData::Impl,
ItemDefaultImpl(..) | ItemImpl(..) => DefPathData::Impl(i.name),
ItemEnum(..) | ItemStruct(..) | ItemTrait(..) => DefPathData::Type(i.name),
ItemExternCrate(..) | ItemMod(..) => DefPathData::Mod(i.name),
ItemStatic(..) | ItemConst(..) | ItemFn(..) => DefPathData::Value(i.name),
Expand Down
7 changes: 2 additions & 5 deletions src/librustc/front/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub enum DefPathData {
Misc,

// Different kinds of items and item-like things:
Impl,
Impl(ast::Name),
Type(ast::Name),
Mod(ast::Name),
Value(ast::Name),
Expand Down Expand Up @@ -177,6 +177,7 @@ impl DefPathData {
pub fn as_interned_str(&self) -> InternedString {
use self::DefPathData::*;
match *self {
Impl(name) |
Type(name) |
Mod(name) |
Value(name) |
Expand Down Expand Up @@ -212,10 +213,6 @@ impl DefPathData {
InternedString::new("?")
}

Impl => {
InternedString::new("<impl>")
}

ClosureExpr => {
InternedString::new("<closure>")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping this could be combined with the actual type info to produce the full name.
Right now, the ast::Item name for impls is a hacky composition of the pretty-printed AST type and trait and I wish we could get rid of it.

Expand Down
9 changes: 9 additions & 0 deletions src/test/run-make/symbols-include-type-name/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-include ../tools.mk

# Check that symbol names for methods include type names, instead of <impl>.

OUT=$(TMPDIR)/lib.s

all:
$(RUSTC) --crate-type staticlib --emit asm lib.rs
grep Def $(OUT)
19 changes: 19 additions & 0 deletions src/test/run-make/symbols-include-type-name/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2015 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.

pub struct Def {
pub id: i32,
}

impl Def {
pub fn new(id: i32) -> Def {
Def { id: id }
}
}