Skip to content

Bad handling of path expression during monomoprhization #3915

@philberty

Description

@philberty

Summary

This bug is hidden most of the time but we get away with it in simple test cases so technically this test case "works" but only by accident.

Reproducer

I tried this code:

#[lang = "sized"]
trait Sized {}

trait Trait {
    fn do_thing();
}

struct MyType;

impl Trait for MyType {
    fn do_thing() {}
}

struct Wrapper<T: Trait> {
    value: T,
}

impl<T: Trait> Wrapper<T> {
    fn call_it() {
        T::do_thing(); // <---------- this only works by accident... 'T' isnt getting monomorphized to MyType here
    }
}

fn main() {
    let _ = Wrapper::<MyType> { value: MyType };
    Wrapper::<MyType>::call_it();
}

Does the code make use of any (1.49) nightly feature ?

  • Nightly

Godbolt link

No response

Actual behavior

The current behavior is, it doesnt monomoprhize but there is only 1 impl anyway and it defaults

Expected behavior

I expected to see the type get monomorphized in the logs properly

GCC Version

110783a

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions