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 {
1039
1039
in_no_bounds_pos : FxHashMap < ast:: NodeId , NoBoundsException > ,
1040
1040
}
1041
1041
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
+ /// ```
1042
1056
enum NoBoundsException {
1057
+ /// The type must be parenthesized.
1043
1058
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.
1044
1061
OneBound ,
1045
1062
}
1046
1063
You can’t perform that action at this time.
0 commit comments