Skip to content

useing inherent method/const gives misleading error #148009

@clarfonthey

Description

@clarfonthey

Code

#![feature(import_trait_associated_functions)]

pub struct Test;
 
impl Test {
    pub fn method() {}
    pub const CONST: usize = 0;
}

pub use self::Test::{method, CONST};

Current output

error[E0432]: unresolved import `self::Test`
  --> src/lib.rs:10:15
   |
10 | pub use self::Test::{method, CONST};
   |               ^^^^ `Test` is a struct, not a module

For more information about this error, try `rustc --explain E0432`.

Desired output

cannot export inherent associated items, only trait associated items

(import *is* resolved, just the wrong type)

Rationale and extra context

Previously, only module items could be re-exported, so, this error made sense from that perspective. However, with #134691, this no longer makes sense and is a little misleading. With the feature enabled, it should mention that this is possible with trait associated items, but not inherent associated items.

or, alternatively, it should be implemented for inherent associated items too.

Rust Version

rustc 1.92.0-nightly (57ef8d642 2025-10-15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsF-import_trait_associated_functions`#![feature(import_trait_associated_functions)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions