diff --git a/src/doc/grammar.md b/src/doc/grammar.md index 8e803aff4d6..3fbf9f06d99 100644 --- a/src/doc/grammar.md +++ b/src/doc/grammar.md @@ -761,8 +761,6 @@ closure_type := [ 'unsafe' ] [ '<' lifetime-list '>' ] '|' arg-list '|' [ ':' bound-list ] [ '->' type ] lifetime-list := lifetime | lifetime ',' lifetime-list arg-list := ident ':' type | ident ':' type ',' arg-list -bound-list := bound | bound '+' bound-list -bound := path | lifetime ``` ### Never type @@ -780,6 +778,15 @@ never_type : "!" ; **FIXME:** grammar? +### Type parameter bounds + +```antlr +bound := ty_bound | lt_bound +lt_bound := lifetime +ty_bound := [?] [ for ] simple_path +bound-list := bound | bound '+' bound-list '+' ? +``` + ### Self types **FIXME:** grammar? diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 3b928ea93c7..ab4ac6f1b91 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4066,7 +4066,7 @@ impl<'a> Parser<'a> { }).emit(); } - // Parse bounds of a type parameter `BOUND + BOUND + BOUND` without trailing `+`. + // Parse bounds of a type parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`. // BOUND = TY_BOUND | LT_BOUND // LT_BOUND = LIFETIME (e.g. `'a`) // TY_BOUND = [?] [for] SIMPLE_PATH (e.g. `?for<'a: 'b> m::Trait<'a>`) @@ -4107,7 +4107,7 @@ impl<'a> Parser<'a> { self.parse_ty_param_bounds_common(true) } - // Parse bounds of a type parameter `BOUND + BOUND + BOUND` without trailing `+`. + // Parse bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`. // BOUND = LT_BOUND (e.g. `'a`) fn parse_lt_param_bounds(&mut self) -> Vec { let mut lifetimes = Vec::new();