Skip to content

where clauses in --pretty printer mishandle >1 lifetime bound #34527

Closed
@pnkfelix

Description

@pnkfelix

Consider the following:

fn f1<'a, 'b, 'c>(_x: &'a u32, _y: &'b u32, _z: &'c u32) where 'c: 'a + 'b { }

fn f2<'a, 'b, 'c: 'a + 'b>(_x: &'a u32, _y: &'b u32, _z:&'c u32) { }

fn f3<'a, 'b, T: 'a + 'b>(_x: &'a u32, _y: &'b u32, _z: T) { }

fn f4<'a, 'b, T>(_x: &'a u32, _y: &'b u32, _z: T) where T: 'a + 'b { }

struct S1<'a, 'b, 'c: 'a + 'b>(&'a u32, &'b u32, &'c u32);

struct S2<'a, 'b, T: 'a + 'b>(&'a u32, &'b u32, T);

struct S3<'a, 'b, T>(&'a u32, &'b u32, T) where T: 'a + 'b;

fn main() { }

struct S4<'a, 'b, 'c>(&'a u32, &'b u32, &'c u32) where 'c: 'a + 'b;

If I feed the above to rustc --pretty -Z unstable-options, it prints out (note the first and last lines in particular):

fn f1<'a, 'b, 'c>(_x: &'a u32, _y: &'b u32, _z: &'c u32) where 'c:'a'b: { }

fn f2<'a, 'b, 'c:'a+'b>(_x: &'a u32, _y: &'b u32, _z: &'c u32) { }

fn f3<'a, 'b, T: 'a + 'b>(_x: &'a u32, _y: &'b u32, _z: T) { }

fn f4<'a, 'b, T>(_x: &'a u32, _y: &'b u32, _z: T) where T: 'a + 'b { }

struct S1<'a, 'b, 'c:'a+'b>(&'a u32, &'b u32, &'c u32);

struct S2<'a, 'b, T: 'a + 'b>(&'a u32, &'b u32, T);

struct S3<'a, 'b, T>(&'a u32, &'b u32, T) where T: 'a + 'b;

fn main() { }

struct S4<'a, 'b, 'c>(&'a u32, &'b u32, &'c u32) where 'c:'a'b:;

In the first and last lines, we are printing out 'c: 'a'b:, when we should be printing 'c: 'a + 'b.

So we are:

  1. Missing an infix +, and
  2. Adding an erroneous : to the end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions