File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1039,8 +1039,25 @@ pub(crate) struct UnusedParens {
10391039 in_no_bounds_pos : FxHashMap < ast:: NodeId , NoBoundsException > ,
10401040}
10411041
1042+ /// Whether parentheses may be omitted from a type without resulting in ambiguity.
1043+ ///
1044+ /// ```
1045+ /// type Example = Box<dyn Fn() -> &'static (dyn Trait) + Send>
1046+ /// ```
1047+ ///
1048+ /// Here, `&'static (dyn Trait) + Send` is a `TypeNoBounds`. As such, it may not directly
1049+ /// contain `ImplTraitType` or `TraitObjectType` which is why `(dyn Trait)` is parenthesized.
1050+ /// However, an exception is made for `ImplTraitTypeOneBound` and `TraitObjectTypeOneBound`.
1051+ /// The following is accepted because there is no `+`.
1052+ ///
1053+ /// ```
1054+ /// type Example = Box<dyn Fn() -> &'static dyn Trait>
1055+ /// ```
10421056enum NoBoundsException {
1057+ /// The type must be parenthesized.
10431058 None ,
1059+ /// The type is the last bound of the containing type expression. If it has exactly one bound,
1060+ /// parentheses around the type are unnecessary.
10441061 OneBound ,
10451062}
10461063
You can’t perform that action at this time.
0 commit comments