Skip to content

Run Doctest inside trait implementations in modules fails for some types #8248

Open
@kangalio

Description

@kangalio

When you have a trait implementation for a type inside a module (i.e. not crate root), for some types the Run Doctest lens at the top of doctests for trait methods fails to run any test.

It seems that affected types are primitive types (str, u32, char...) and types with non-alphanumerical characters in them (&T, (T, T), [T; N]...).

Curiously enough, the issue only seems to encounter within modules; when the trait implementation is moved to the crate root, Run Doctest does its job just fine regardless of the type used (as far as I could tell).

Example:

mod hi {
    pub trait Trait {
        fn foo();
    }
    
    impl Trait for char {
        /// ```rust
        /// assert_eq!(1 + 1, 2);
        /// ```
        fn foo() {}
    }
}

Screenshot_20210330_015905

The issue seems to be that the type name is, for some reason, dropped from the path passed to --package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-idegeneral IDE featuresC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions