Skip to content

Symbol names for monomorphized trait impls are not stable across crates #32948

Description

@Kha

In the spirit of #32554:

crate A:

pub trait Foo {
    fn foo<T>();
}

pub struct Bar;

impl Foo for Bar {
    fn foo<T>() { }
}

pub fn bar() {
    Bar::foo::<Bar>();
}

crate B:

extern crate A;
use A::*;

fn bar2() {
    Bar::foo::<Bar>();
}

A.ll:

define internal void @"_ZN27_$LT$Bar$u20$as$u20$Foo$GT$3foo17hde2cfe0cb82f67ddE"() unnamed_addr #0 !dbg !12 {

B.ll:

define internal void @"_ZN33_$LT$A..Bar$u20$as$u20$A..Foo$GT$3foo17he9b727db8600b5deE"() unnamed_addr #0 !dbg !13 {

IOW, A uses the encoding of <Bar as Foo>::foo, while B uses <A::Bar as A::Foo>::foo. The issue seems to be that while symbol names correctly use ctxt::absolute_item_path_str, that function indirectly calls ctxt::item_path_str via e.g. TraitRef's Display implementation.

cc @nikomatsakis @michaelwoerister

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions