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

Rollup of 7 pull requests #63028

Closed
wants to merge 48 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
44bf6b6
tests: Add minimal reproduction of #61963.
davidtwco Jul 20, 2019
5d11755
Add 'ast::PatKind::Rest'.
Centril Jul 6, 2019
9d6684c
Introduce 'ast::Pat::is_rest(&self) -> bool'.
Centril Jul 9, 2019
aa945e3
Adjust 'ast::PatKind::{TupleStruct,Tuple,Slice}'.
Centril Jul 9, 2019
786797d
Adjust feature gating of subslice patterns accordingly.
Centril Jul 9, 2019
02ef849
Adjust pretty printing accordingly.
Centril Jul 9, 2019
4dcc713
Adjust and document 'Pat::to_ty' accordingly.
Centril Jul 9, 2019
634ebd5
Adjust lowering of Tuple/TupleStruct patterns.
Centril Jul 9, 2019
5c002ac
Adjust lowering of Slice patterns.
Centril Jul 9, 2019
33421de
Cleanup parse_seq_* methods + record trailing separators.
Centril Jul 9, 2019
de3ae62
Add more parse_*_seq methods for code reuse.
Centril Jul 9, 2019
77d8752
Cleanup using the new parse_*_seq methods.
Centril Jul 9, 2019
6bfba39
Adjust parsing of Slice, Tuple, TupleStruct patterns.
Centril Jul 9, 2019
cde05d3
Recover on '..X' / '..=X' / '...X' range patterns.
Centril Jul 9, 2019
036c683
Recover on 'X..' / 'X..=' / 'X...' range patterns.
Centril Jul 9, 2019
557c81b
Update tests wrt. recovery of range patterns.
Centril Jul 9, 2019
61eab52
And also --bless those recovery tests.
Centril Jul 9, 2019
179de7c
Test parsing and recovery of all sorts of range patterns.
Centril Jul 9, 2019
98d6269
Use new 'p @ ..' syntax in tests.
Centril Jul 7, 2019
7fef614
--bless tests due to new subslice syntax.
Centril Jul 7, 2019
9e084f2
Intersection patterns 'p1 @ p2' are not supported.
Centril Jul 8, 2019
8a481ef
Account for better recovery in two cases.
Centril Jul 9, 2019
7cd4144
(pat, ..,) is now syntactically legal.
Centril Jul 8, 2019
2e6e6a9
Win some lose some; Unfortunately we lost recovery in one case.
Centril Jul 8, 2019
bc88063
Update unstable book wrt. subslice patterns.
Centril Jul 10, 2019
7a7146c
Adjust documentation in HAIR.
Centril Jul 10, 2019
1922656
Get out of bootstrapping pickle.
Centril Jul 10, 2019
165951b
--bless tests after rebase.
Centril Jul 10, 2019
3d8c561
Update error_codes.rs with new subslice syntax.
Centril Jul 10, 2019
efdbb87
Use AstP more in lowering.
Centril Jul 11, 2019
2d4c4c9
Address comments in lowering + parsing.
Centril Jul 24, 2019
0569970
Address comments re. off-topic errors.
Centril Jul 24, 2019
6748878
Add exceptions for ExprKind::Err/TyKind::Error.
Centril Jul 24, 2019
9cde1db
And --bless tests accordingly for those exceptions.
Centril Jul 24, 2019
4242206
Re-enable assertions in PPC dist builder
mati865 Jul 19, 2019
c7a599e
bump crossbeam-epoch dependency
RalfJung Jul 25, 2019
eb4fbda
Simplify save-analysis JSON dumper interface
Mark-Simulacrum Jul 25, 2019
68c0ba2
Rename JsonDumper to Dumper
Mark-Simulacrum Jul 25, 2019
8eaf17b
Introduce built-in macros through libcore
petrochenkov Jun 20, 2019
d7b2110
add repr(transparent) to IoSliceMut where missing
nivkner Jul 26, 2019
cae8680
lowering: Omit bare trait lint on macro call sites
davidtwco Jul 26, 2019
c5c5534
Rollup merge of #62086 - petrochenkov:builtout, r=eddyb
Centril Jul 26, 2019
63ec331
Rollup merge of #62550 - Centril:rest-patterns, r=petrochenkov
Centril Jul 26, 2019
2fa3e20
Rollup merge of #62949 - mati865:patch-1, r=alexcrichton
Centril Jul 26, 2019
8654523
Rollup merge of #62974 - RalfJung:crossbeam, r=alexcrichton
Centril Jul 26, 2019
d213e2f
Rollup merge of #62979 - Mark-Simulacrum:json-dumper-pretty, r=Xanewok
Centril Jul 26, 2019
70f0c91
Rollup merge of #63013 - nivkner:ffi-safe-slice, r=sfackler
Centril Jul 26, 2019
17396c9
Rollup merge of #63014 - davidtwco:rustfix-incorrect-dyn-suggestion, …
Centril Jul 26, 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
Prev Previous commit
Next Next commit
Address comments in lowering + parsing.
Centril committed Jul 24, 2019
commit 2d4c4c98851ae6c050a24c1c77f4d572b1db1144
20 changes: 10 additions & 10 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
@@ -4186,7 +4186,7 @@ impl<'a> LoweringContext<'a> {
ParamMode::Optional,
ImplTraitContext::disallowed(),
);
let (pats, ddpos) = self.lower_pat_tuple(&*pats, "tuple struct");
let (pats, ddpos) = self.lower_pat_tuple(pats, "tuple struct");
hir::PatKind::TupleStruct(qpath, pats, ddpos)
}
PatKind::Path(ref qself, ref path) => {
@@ -4225,7 +4225,7 @@ impl<'a> LoweringContext<'a> {
hir::PatKind::Struct(qpath, fs, etc)
}
PatKind::Tuple(ref pats) => {
let (pats, ddpos) = self.lower_pat_tuple(&*pats, "tuple");
let (pats, ddpos) = self.lower_pat_tuple(pats, "tuple");
hir::PatKind::Tuple(pats, ddpos)
}
PatKind::Box(ref inner) => hir::PatKind::Box(self.lower_pat(inner)),
@@ -4246,7 +4246,7 @@ impl<'a> LoweringContext<'a> {
PatKind::Mac(_) => panic!("Shouldn't exist here"),
};

self.pat_bound(p, node)
self.pat_with_node_id_of(p, node)
}

fn lower_pat_tuple(
@@ -4292,14 +4292,14 @@ impl<'a> LoweringContext<'a> {
match pat.node {
PatKind::Rest => {
prev_rest_span = Some(pat.span);
slice = Some(self.pat_bound_wild(pat));
slice = Some(self.pat_wild_with_node_id_of(pat));
break;
},
PatKind::Ident(ref bm, ident, Some(ref sub)) if sub.is_rest() => {
prev_rest_span = Some(sub.span);
let lower_sub = |this: &mut Self| Some(this.pat_bound_wild(sub));
let lower_sub = |this: &mut Self| Some(this.pat_wild_with_node_id_of(sub));
let node = self.lower_pat_ident(pat, bm, ident, lower_sub);
slice = Some(self.pat_bound(pat, node));
slice = Some(self.pat_with_node_id_of(pat, node));
break;
},
_ => {}
@@ -4315,7 +4315,7 @@ impl<'a> LoweringContext<'a> {
PatKind::Rest => Some(pat.span),
PatKind::Ident(.., Some(ref sub)) if sub.is_rest() => {
// The `HirValidator` is merciless; add a `_` pattern to avoid ICEs.
after.push(self.pat_bound_wild(pat));
after.push(self.pat_wild_with_node_id_of(pat));
Some(sub.span)
},
_ => None,
@@ -4363,12 +4363,12 @@ impl<'a> LoweringContext<'a> {
}
}

fn pat_bound_wild(&mut self, p: &Pat) -> P<hir::Pat> {
self.pat_bound(p, hir::PatKind::Wild)
fn pat_wild_with_node_id_of(&mut self, p: &Pat) -> P<hir::Pat> {
self.pat_with_node_id_of(p, hir::PatKind::Wild)
}

/// Construct a `Pat` with the `HirId` of `p.id` lowered.
fn pat_bound(&mut self, p: &Pat, node: hir::PatKind) -> P<hir::Pat> {
fn pat_with_node_id_of(&mut self, p: &Pat, node: hir::PatKind) -> P<hir::Pat> {
P(hir::Pat {
hir_id: self.lower_node_id(p.id),
node,
11 changes: 7 additions & 4 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
@@ -3747,8 +3747,9 @@ impl<'a> Parser<'a> {
})
}

/// Parse a parentesized comma separated sequence of patterns until `delim` is reached.
fn parse_recover_pat_list(&mut self) -> PResult<'a, ()> {
/// Parse and throw away a parentesized comma separated
/// sequence of patterns until `)` is reached.
fn skip_pat_list(&mut self) -> PResult<'a, ()> {
while !self.check(&token::CloseDelim(token::Paren)) {
self.parse_pat(None)?;
if !self.eat(&token::Comma) {
@@ -3771,7 +3772,7 @@ impl<'a> Parser<'a> {
// later.
let comma_span = self.token.span;
self.bump();
if let Err(mut err) = self.parse_recover_pat_list() {
if let Err(mut err) = self.skip_pat_list() {
// We didn't expect this to work anyway; we just wanted
// to advance to the end of the comma-sequence so we know
// the span to suggest parenthesizing
@@ -3876,9 +3877,11 @@ impl<'a> Parser<'a> {
pat = PatKind::Ref(subpat, mutbl);
}
token::OpenDelim(token::Paren) => {
// Parse `(pat, pat, pat, ...)` as tuple pattern.
// Parse a tuple or parenthesis pattern.
let (fields, trailing_comma) = self.parse_paren_comma_seq(|p| p.parse_pat(None))?;

// Here, `(pat,)` is a tuple pattern.
// For backward compatibility, `(..)` is a tuple pattern as well.
pat = if fields.len() == 1 && !(trailing_comma || fields[0].is_rest()) {
PatKind::Paren(fields.into_iter().nth(0).unwrap())
} else {