Skip to content

Parser does not parse ~fn() #10767

@jvns

Description

@jvns
Contributor

When I run

fn f() {
}; 
let x: ~fn() = ~f;

I get the error message

rust> fn f() {}; let x: ~fn() = ~f;
<anon>:7:18: 7:19 error: obsolete syntax: managed or owned closure
<anon>:7 fn f() {}; let x: ~fn() = ~f;
                           ^
note: managed closures have been removed and owned closures are now written `proc()`
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /build/buildd/rust-nightly-201312020805~61443dc~precise/src/libsyntax/diagnos

Activity

ben0x539

ben0x539 commented on Dec 2, 2013

@ben0x539
Contributor

So, the parser still thinks ~fn() is a heap closure but it's also the obvious way to write the type of a bare function (pointer) stored in a ~-box. let x: ~(fn()) = ~f; works right now, too. I think the error message / type-to-string logic is right and the parser ought to give. :)

emberian

emberian commented on Dec 4, 2013

@emberian
Member

I don't actually think this is an issue. ~fn() should be valid, though nonsensical, after the obsolete heap function handling is removed.

@pcwalton is this accurate?

jvns

jvns commented on Dec 4, 2013

@jvns
ContributorAuthor

Restated the issue as a parser bug.

huonw

huonw commented on Dec 4, 2013

@huonw
Member

It's probably worth keeping the obsolete syntax warning around at least until the next release to help anyone tracking the releases and not master to upgrade.

(And also those who try Rust for the first time after the media storm we cook up for each release ;) , who chance upon some old code... Getting a sane error message rather than a mismatched types one is nicer.)

alexcrichton

alexcrichton commented on Feb 10, 2014

@alexcrichton
Member

Closing ~fn() has long been gone.

alexcrichton

alexcrichton commented on Feb 10, 2014

@alexcrichton
Member

Whoops, this isn't related to that, carry on!

huonw

huonw commented on Feb 10, 2014

@huonw
Member

It's been enough time (and we've had a release), so I imagine we can remove the obsolete syntax warning now.

8 remaining items

added a commit that references this issue on Apr 6, 2014
667f82a
added a commit that references this issue on May 20, 2023
a167973
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ben0x539@alexcrichton@emberian@jvns@huonw

      Issue actions

        Parser does not parse ~fn() · Issue #10767 · rust-lang/rust