Skip to content

fn f(self::S: S) does not parse #18

@matthiaskrgr

Description

@matthiaskrgr

The following code

// Check that `self::foo` is parsed as a general pattern and not a self argument.

struct S;

impl S {
    fn f(self::S: S) {}
    fn g(&self::S: &S) {}
    fn h(&self::S: &S) {}
    fn main() {} //~ ERROR unexpected lifetime `'a` in pattern
}

fn main() {}

Compiled successfully ( with --crate-type=lib --cap-lints=warn ):

warning: struct `S` is never constructed
 --> ./2025_12_30__22_38_26/e8bd12bd06722ea6e6a13e10b188e832a2b9654b.rs:3:8
  |
3 | struct S;
  |        ^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: associated functions `f`, `g`, `h`, and `main` are never used
 --> ./2025_12_30__22_38_26/e8bd12bd06722ea6e6a13e10b188e832a2b9654b.rs:6:8
  |
5 | impl S {
  | ------ associated functions in this implementation
6 |     fn f(self::S: S) {}
  |        ^
7 |     fn g(&self::S: &S) {}
  |        ^
8 |     fn h(&self::S: &S) {}
  |        ^
9 |     fn main() {} //~ ERROR unexpected lifetime `'a` in pattern
  |        ^^^^

warning: function `main` is never used
  --> ./2025_12_30__22_38_26/e8bd12bd06722ea6e6a13e10b188e832a2b9654b.rs:12:4
   |
12 | fn main() {}
   |    ^^^^

warning: 3 warnings emitted


However rasur was found to have errors (-e 2015):

error: found `::` but expected `,`
 --> ./2025_12_30__22_38_26/e8bd12bd06722ea6e6a13e10b188e832a2b9654b.rs:6:14
  |
6 |     fn f(self::S: S) {}
  |              ^^ unexpected token

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions