Skip to content

crates are considered for fn() -> type name resolution if they have generic parameters #139095

Open
@jyn514

Description

@jyn514

I tried this code:

extern crate libc as usize;
extern crate libc as Option;
#[usize::inner] //~ ERROR could not find `inner` in `usize`
fn foo() {}
fn bar() -> usize { 0 } // OK
fn baz() -> Option<T> { 0 } //~ ERROR type arguments not allowed on crate

I expected to see this happen: usize and Option should both consistently resolve to the crate, or they should consistently resolve to the builtin type.

Instead, this happened: In return position, usize resolves to the builtin type and Option resolves to the crate.
In attribute position, usize resolves to the crate (which seems reasonable, because associated macros aren't a thing.)

Meta

rustc --version --verbose: 1.87.0-nightly (2025-03-28 920d95eaf23d7eb6b415)

@rustbot label A-resolve

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions