Skip to content

Inherent associated functions and constants defined on function pointer types won't be found #108270

Closed as not planned
@fmease

Description

@fmease

Since only core & std are allowed to define functions and constants on function pointer types (like fn() or for<'a> fn(&'a ()) -> bool) and since they maybe never will, this issue is of low priority. For other primitive types like !, (), bool etc., inherent associated functions and constants are correctly resolved.

#![feature(rustc_attrs)]
#![rustc_coherence_is_core]

impl fn() {
    const X: () = ();
}

fn user() {
    <fn()>::X; //~ ERROR no associated item named `X` found for fn pointer `fn()` in the current scope
}

Note that the perma-unstable attribute #![rustc_coherence_is_core] is used in the reproducer which doesn't come with any language or stability guarantees. However, this issue is not about it but about the fact that core which uses this attribute internally and std (which can use #[rustc_allow_incoherent_impl]) would not be able to properly define associated items on those types. For the same reason, I'm not labeling this as requires-nightly.

@rustbot label T-compiler A-resolve A-associated-items

Metadata

Metadata

Assignees

Labels

A-associated-itemsArea: Associated items (types, constants & functions)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.F-rustc_attrsInternal rustc attributes gated on the `#[rustc_attrs]` feature gate.T-compilerRelevant to the compiler 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