From a50737051abdc943f96c6e89a732fd00e58248e8 Mon Sep 17 00:00:00 2001 From: alexey zabelin Date: Wed, 12 Apr 2017 20:46:44 -0400 Subject: [PATCH 1/3] Fix old docs #41158 --- src/doc/grammar.md | 8 ++++++++ src/libsyntax/parse/parser.rs | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/doc/grammar.md b/src/doc/grammar.md index 8e803aff4d6fe..239afd41f023a 100644 --- a/src/doc/grammar.md +++ b/src/doc/grammar.md @@ -780,6 +780,14 @@ never_type : "!" ; **FIXME:** grammar? +### Type parameter bounds + +```antlr +bound := ty_bound | lt_bound +lt_bound := lifetime +ty_bound := [?] [ for ] simple_path +``` + ### Self types **FIXME:** grammar? diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 3b928ea93c78a..5cacb0da9e5d9 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`. // 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 type parameter `BOUND + BOUND + BOUND`. // BOUND = LT_BOUND (e.g. `'a`) fn parse_lt_param_bounds(&mut self) -> Vec { let mut lifetimes = Vec::new(); From 14eac29753efd5a5e8ded83a2c8ae8e44e914320 Mon Sep 17 00:00:00 2001 From: alexey zabelin Date: Thu, 13 Apr 2017 09:53:22 -0400 Subject: [PATCH 2/3] Address the PR review --- src/doc/grammar.md | 3 +-- src/libsyntax/parse/parser.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/doc/grammar.md b/src/doc/grammar.md index 239afd41f023a..3fbf9f06d99f6 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 @@ -786,6 +784,7 @@ never_type : "!" ; bound := ty_bound | lt_bound lt_bound := lifetime ty_bound := [?] [ for ] simple_path +bound-list := bound | bound '+' bound-list '+' ? ``` ### Self types diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 5cacb0da9e5d9..0fddbca72cdc1 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`. + // Parse bounds of a lifetime 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`. + // 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(); From 08a955af68ae350dabb7b66b4981f4503ba74aa3 Mon Sep 17 00:00:00 2001 From: alexey zabelin Date: Mon, 17 Apr 2017 10:48:23 -0400 Subject: [PATCH 3/3] Adjust description --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0fddbca72cdc1..ab4ac6f1b91ee 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 lifetime parameter `BOUND + BOUND + BOUND`, possibly with 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>`)