Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor type & bounds parsing thoroughly #67148

Merged
merged 28 commits into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f3ef4a4
extract parse_ty_tuple_or_parens
Centril Dec 8, 2019
c67c30d
refactor parse_ty_tuple_or_parens
Centril Dec 8, 2019
3838b60
parse_ptr -> parse_ty_ptr & refactor
Centril Dec 8, 2019
211560d
extract parse_array_or_slice_ty
Centril Dec 8, 2019
e08886d
extract parse_typeof_ty
Centril Dec 8, 2019
edb7b96
extract parse_impl_ty
Centril Dec 8, 2019
b7071f2
extract parse_dyn_ty
Centril Dec 8, 2019
85d3ed9
extract parse_path_start_ty
Centril Dec 8, 2019
6f1f6a6
extract error_illegal_c_variadic_ty
Centril Dec 8, 2019
3b1fab8
parse_ty_common: .fatal -> .struct_span_err
Centril Dec 8, 2019
3f499a9
parser/ty.rs: minor formatting tweaks
Centril Dec 8, 2019
b484fae
extract error_opt_out_lifetime
Centril Dec 8, 2019
a11252a
extract recover_paren_lifetime
Centril Dec 8, 2019
e61cb44
parse_generic_bounds_common: dedent
Centril Dec 8, 2019
fd89104
extract can_begin_bound
Centril Dec 8, 2019
8a9a992
extract parse_generic_bound
Centril Dec 8, 2019
18e5b2f
functionalize parse_generic_bound
Centril Dec 8, 2019
1cfeb56
parse_generic_bound: leave a FIXME
Centril Dec 8, 2019
50e00c7
extract parse_generic_ty_bound
Centril Dec 8, 2019
4b073a1
extract parse_generic_lt_bound
Centril Dec 8, 2019
f215ca9
simplify negative bound diagnostic
Centril Dec 8, 2019
4625ba4
simplify 'let question = ...;'
Centril Dec 8, 2019
b5f00be
parse_generic_bounds: account for negative lifetime bounds
Centril Dec 8, 2019
f221b39
extract error_negative_bounds
Centril Dec 8, 2019
d010560
document parse_late_bound_lifetime_defs
Centril Dec 8, 2019
d6f37c6
parse_ty_bare_fn: improve docs
Centril Dec 8, 2019
52fa020
unwrap -> expect
Centril Dec 21, 2019
db4818f
span_suggestion_hidden -> tool_only_span_suggestion
Centril Dec 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/librustc_parse/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ impl<'a> Parser<'a> {
self.parse_expr_res(Restrictions::empty(), None)
}

pub(super) fn parse_anon_const_expr(&mut self) -> PResult<'a, AnonConst> {
self.parse_expr().map(|value| AnonConst { id: DUMMY_NODE_ID, value })
}

fn parse_expr_catch_underscore(&mut self) -> PResult<'a, P<Expr>> {
match self.parse_expr() {
Ok(expr) => Ok(expr),
Expand All @@ -109,7 +113,7 @@ impl<'a> Parser<'a> {
}
}

/// Parses a sequence of expressions bounded by parentheses.
/// Parses a sequence of expressions delimited by parentheses.
fn parse_paren_expr_seq(&mut self) -> PResult<'a, Vec<P<Expr>>> {
self.parse_paren_comma_seq(|p| {
p.parse_expr_catch_underscore()
Expand Down Expand Up @@ -955,10 +959,7 @@ impl<'a> Parser<'a> {
let first_expr = self.parse_expr()?;
if self.eat(&token::Semi) {
// Repeating array syntax: `[ 0; 512 ]`
let count = AnonConst {
id: DUMMY_NODE_ID,
value: self.parse_expr()?,
};
let count = self.parse_anon_const_expr()?;
self.expect(close)?;
ExprKind::Repeat(first_expr, count)
} else if self.eat(&token::Comma) {
Expand Down
7 changes: 2 additions & 5 deletions src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::maybe_whole;

use rustc_errors::{PResult, Applicability, DiagnosticBuilder, StashKey};
use rustc_error_codes::*;
use syntax::ast::{self, DUMMY_NODE_ID, Ident, AttrVec, Attribute, AttrKind, AttrStyle, AnonConst};
use syntax::ast::{self, DUMMY_NODE_ID, Ident, AttrVec, Attribute, AttrKind, AttrStyle};
use syntax::ast::{AssocItem, AssocItemKind, Item, ItemKind, UseTree, UseTreeKind};
use syntax::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness, Extern, StrLit};
use syntax::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
Expand Down Expand Up @@ -1317,10 +1317,7 @@ impl<'a> Parser<'a> {
};

let disr_expr = if self.eat(&token::Eq) {
Some(AnonConst {
id: DUMMY_NODE_ID,
value: self.parse_expr()?,
})
Some(self.parse_anon_const_expr()?)
} else {
None
};
Expand Down
Loading