Skip to content

Confusing diagnostic for stray lifetime in type #133413

Closed
@Dylan-DPC

Description

@Dylan-DPC

Code

struct Bar;
pub struct Foo<'a>('a, Bar);

Current output

error: lifetime in trait object type must be followed by `+`
 --> src/lib.rs:2:20
  |
2 | pub struct Foo<'a>('a, Bar);
  |                    ^^

error[E0224]: at least one trait is required for an object type
 --> src/lib.rs:2:20
  |
2 | pub struct Foo<'a>('a, Bar);
  |                    ^^

Rationale and extra context

Playground link

Rust Version

Tested on playground so latest stable and nightly at the time of writing (1.82.0 stable)

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions