Skip to content

syntax: Trait object types permit extra parentheses on the first bound #39318

Closed
@petrochenkov

Description

@petrochenkov
// Accepted while it should not.
type A = Box<(Trait1) + Trait2 + 'lifetime>;

// Correct syntax.
type A = Box<Trait1 + Trait2 + 'lifetime>;

The syntax for object types is the same as for other bounds - Bound + Bound + Bound + .... and parentheses are not a part of bound syntax.

This is a stable-stable regression, introduced in Rust 1.6 by #29870.
cc #39169 #39179

Current status

  • Refactor parsing of trait object types #40043 - (Bound) + Bound + .... is still parsed , but with a warning. This is a "hardcoded" warning and not a lint, lints cannot be reported from libsyntax.
  • PR ? turns this syntax into a hard error

Metadata

Metadata

Assignees

Labels

A-parserArea: The lexing & parsing of Rust source code to an ASTI-needs-decisionIssue: In need of a decision.P-mediumMedium priorityT-langRelevant to the language team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions