diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-01-21 02:21:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-21 02:21:55 +0100 |
| commit | 627e001a722d0aa1c8db0523ed26c25f775570f4 (patch) | |
| tree | 68868cfffd85d93898d439d84375012580dc7655 /src/libsyntax | |
| parent | ebc70e2e9ecdd0920c5e78f53ed694f1c050c5ed (diff) | |
| parent | 2ab6cefccfe3c5f2c97bf8bcab080a26089257e2 (diff) | |
| download | rust-627e001a722d0aa1c8db0523ed26c25f775570f4.tar.gz rust-627e001a722d0aa1c8db0523ed26c25f775570f4.zip | |
Rollup merge of #57768 - estebank:type-args-sugg, r=zackmdavis
Continue parsing after parent type args and suggest using angle brackets ``` error[E0214]: parenthesized parameters may only be used with a trait --> $DIR/E0214.rs:2:15 | LL | let v: Vec(&str) = vec!["foo"]; | ^^^^^^ | | | only traits may use parentheses | help: use angle brackets instead: `<&str>` ``` r? @zackmdavis
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f411e40e160..405cf612543 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -192,6 +192,16 @@ pub struct ParenthesisedArgs { pub output: Option<P<Ty>>, } +impl ParenthesisedArgs { + pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs { + AngleBracketedArgs { + span: self.span, + args: self.inputs.iter().cloned().map(|input| GenericArg::Type(input)).collect(), + bindings: vec![], + } + } +} + // hack to ensure that we don't try to access the private parts of `NodeId` in this module mod node_id_inner { use rustc_data_structures::indexed_vec::Idx; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7e15b231276..e09b7a9dd7b 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2176,11 +2176,11 @@ impl<'a> Parser<'a> { style != PathStyle::Mod && self.check(&token::ModSep) && self.look_ahead(1, |t| is_args_start(t)) { // Generic arguments are found - `<`, `(`, `::<` or `::(`. - let lo = self.span; if self.eat(&token::ModSep) && style == PathStyle::Type && enable_warning { self.diagnostic().struct_span_warn(self.prev_span, "unnecessary path disambiguator") .span_label(self.prev_span, "try removing `::`").emit(); } + let lo = self.span; let args = if self.eat_lt() { // `<'a, T, A = U>` |
