Skip to content

Mutable reference mode for first arg to methods ignored due to self type parsing bug #3191

Closed
@msullivan

Description

@msullivan

The following code:

enum thing { thing(int) }
impl thing {
    fn baz(&x: int) { x = 5 }
}
fn main() {}

fails to compile with the error:

nubs/method-mutable-ref.rs:3:22: 3:23 error: assigning to argument
nubs/method-mutable-ref.rs:3     fn baz(&x: int) { x = 5 }

which is complete nonsense, since it is a mutable argument. This is because a bug in the parser code that handles explicit self types causes the '&' to get dropped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)A-grammarArea: The grammar of Rust

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions