diff options
| author | bors <bors@rust-lang.org> | 2016-03-28 20:50:42 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-03-28 20:50:42 -0700 |
| commit | a11129701c873d96fe0816e4c8b55510efebe96e (patch) | |
| tree | c1461e5f0660b146394122ef80a5ada344646d85 /src/test/parse-fail | |
| parent | cad964a62655110753d73527df7ad808a235fc84 (diff) | |
| parent | 221d0fbad0b201ef9264d3c9a30cd8c143ed51b2 (diff) | |
| download | rust-a11129701c873d96fe0816e4c8b55510efebe96e.tar.gz rust-a11129701c873d96fe0816e4c8b55510efebe96e.zip | |
Auto merge of #32479 - eddyb:eof-not-even-twice, r=nikomatsakis
Prevent bumping the parser past the EOF. Makes `Parser::bump` after EOF into an ICE, forcing callers to avoid repeated EOF bumps. This ICE is intended to break infinite loops where EOF wasn't stopping the loop. For example, the handling of EOF in `parse_trait_items`' recovery loop fixes #32446. But even without this specific fix, the ICE is triggered, which helps diagnosis and UX. This is a `[breaking-change]` for plugins authors who eagerly eat multiple EOFs. See https://github.com/docopt/docopt.rs/pull/171 for such an example and the necessary fix.
Diffstat (limited to 'src/test/parse-fail')
| -rw-r--r-- | src/test/parse-fail/issue-32446.rs | 16 | ||||
| -rw-r--r-- | src/test/parse-fail/pat-lt-bracket-6.rs | 2 | ||||
| -rw-r--r-- | src/test/parse-fail/pat-lt-bracket-7.rs | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/test/parse-fail/issue-32446.rs b/src/test/parse-fail/issue-32446.rs new file mode 100644 index 00000000000..90b9a4aae8b --- /dev/null +++ b/src/test/parse-fail/issue-32446.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() {} + +// This used to end up in an infite loop trying to bump past EOF. +trait T { ... } //~ ERROR diff --git a/src/test/parse-fail/pat-lt-bracket-6.rs b/src/test/parse-fail/pat-lt-bracket-6.rs index bc27aedb627..5ed8f6dee8c 100644 --- a/src/test/parse-fail/pat-lt-bracket-6.rs +++ b/src/test/parse-fail/pat-lt-bracket-6.rs @@ -10,5 +10,5 @@ fn main() { let Test(&desc[..]) = x; //~ error: expected one of `,` or `@`, found `[` - //~^ ERROR expected one of `:`, `;`, or `=`, found `..` + //~^ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` } diff --git a/src/test/parse-fail/pat-lt-bracket-7.rs b/src/test/parse-fail/pat-lt-bracket-7.rs index 3e9478da44d..00681e61497 100644 --- a/src/test/parse-fail/pat-lt-bracket-7.rs +++ b/src/test/parse-fail/pat-lt-bracket-7.rs @@ -10,5 +10,5 @@ fn main() { for thing(x[]) in foo {} //~ error: expected one of `,` or `@`, found `[` - //~^ ERROR: expected `in`, found `]` + //~^ ERROR expected one of `@` or `in`, found `[` } |
