Skip to content

Weird parse error when writing a lifetime-bounded trait object in the wrong order #17487

Closed
@arielb1

Description

@arielb1

The following code

trait Tr {}
struct S<'a>(&'a 'static+Tr);

gives the following weird error

<anon>:2:18: 2:25 error: expected type, found token LIFETIME(ast::Ident{name: ast::Name(3u32), ctxt: 0u32})
<anon>:2 struct S<'a>(&'a 'static+Tr);

If you write the bounds in the reverse order

trait Tr {}
struct S<'a>(&'a Tr+'static);

It works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions