Skip to content

Inconsistency in whether methods of shadowed traits are usable #31379

Closed
@jseyfried

Description

@jseyfried

This compiles:

mod foo {
    trait IntoIterator {}    
    fn f() { Some(0).into_iter(); }
}

but this doesn't:

trait T {}
mod bar {
    use T as IntoIterator;
    fn f() { Some(0).into_iter(); }
}

More generally, a shadowed trait's methods are usable if it is shadowed by an item, but not if it is shadowed by an import.

Should methods from shadowed traits be usable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)P-mediumMedium priorityT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions