Skip to content

Commit 9488446

Browse files
committed
Fix type-style qualified paths and parenthesized style type paths.
1 parent 3091989 commit 9488446

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/paths.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,17 @@ Vec::<u8>::with_capacity(1024);
6262

6363
> **<sup>Syntax</sup>**\
6464
> _QualifiedPathInExpression_ :\
65-
> &nbsp;&nbsp; `<` [_Type_] (`as` _TypePath_)? `>` (`::` _PathExprSegment_)<sup>\*</sup>
65+
> &nbsp;&nbsp; _QualifiedPathType_ (`::` _PathExprSegment_)<sup>\*</sup>
66+
>
67+
> _QualifiedPathType_ :\
68+
> &nbsp;&nbsp; `<` [_Type_] (`as` _TypePath_)? `>`
69+
>
70+
> _QualifiedPathInType_ :\
71+
> &nbsp;&nbsp; _QualifiedPathType_ (`::` _TypePathSegment_)<sup>\*</sup>
6672
67-
Fully qualified paths allow for disambiguating the path for [trait implementations] and for
68-
specifying [canonical paths](#canonical-paths).
73+
Fully qualified paths allow for disambiguating the path for [trait implementations] and
74+
for specifying [canonical paths](#canonical-paths). When used in a type specification, it
75+
supports using the type syntax specified below.
6976

7077
```rust
7178
struct S;
@@ -92,17 +99,24 @@ S::f(); // Calls the inherent impl.
9299
> &nbsp;&nbsp; `::`<sup>?</sup> _TypePathSegment_ (`::` _TypePathSegment_)<sup>\*</sup>
93100
>
94101
> _TypePathSegment_ :\
95-
> &nbsp;&nbsp; _PathIdentSegment_ (`::`<sup>?</sup> [_Generics_])<sup>?</sup>
102+
> &nbsp;&nbsp; _PathIdentSegment_ (`::`<sup>?</sup> ([_Generics_] | _TypePathFn_)<sup>?</sup>
103+
>
104+
> _TypePathFn_ :\
105+
> `(` _TypePathFnInputs_<sup>?</sup> `)` (`->` [_Type_])<sup>?</sup>
106+
>
107+
> _TypePathFnInputs_ :\
108+
> [_Type_] (`,` [_Type_])<sup>\*</sup> `,`<sup>?</sup>
96109
97110
Type paths are used within type definitions, trait bounds, type parameter bounds,
98-
and qualified paths in expressions.
111+
and qualified paths.
99112

100113
Although the `::` token is allowed before the generics parameters, it is not required
101114
because there is no ambiguity like there is in _PathInExpression_.
102115

103116
```rust,ignore
104117
impl ops::Index<ops::Range<usize>> for S { /*...*/ }
105118
fn i() -> impl Iterator<Item = op::Example<'a>> { /*...*/ }
119+
type G = std::boxed::Box<std::ops::FnOnce(isize) -> isize>;
106120
```
107121

108122
## Path qualifiers

0 commit comments

Comments
 (0)