Skip to content

Feature-gating on closures is broken #97073

@JohnTitor

Description

@JohnTitor
Member

If we try to apply #[track_caller] on closures, like:

    pub fn expect_non_local<OtherId>(self) -> Res<OtherId> {
        self.map_id(
            #[track_caller]
            |_| panic!("unexpected `Res::Local`"),
        )
    }

This needs an #![feature(closure_track_caller)], which is normal, but it also needs the feature attributes on the crates that have a caller of that method.

See #96894 (comment) and #96894 (comment) for more details.

TL;DR: In the above PR's situation, that method belongs to rustc_hir but we also have to add the feature attributes to rustc_resolve and librustdoc.

I expected to see this happen: compiles fine with one feature attribute

Instead, this happened: compilation error

Activity

added
C-bugCategory: This is a bug.
A-closuresArea: Closures (`|…| { … }`)
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)C-bugCategory: This is a bug.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

        Participants

        @JohnTitor

        Issue actions

          Feature-gating on closures is broken · Issue #97073 · rust-lang/rust