Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSome fixes for error recovery in the compiler #32435
Conversation
nrc
added some commits
Mar 18, 2016
rust-highfive
assigned
nikomatsakis
Mar 22, 2016
This comment has been minimized.
This comment has been minimized.
|
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
Travis failed.
|
nrc
force-pushed the
nrc:fix-err-recover
branch
from
bf10f4e
to
167ef75
Mar 23, 2016
nrc
added
beta-nominated
T-compiler
labels
Mar 24, 2016
nrc
force-pushed the
nrc:fix-err-recover
branch
from
167ef75
to
180d6b5
Mar 24, 2016
nikomatsakis
reviewed
Mar 24, 2016
| // Expand to cover the entire delimited token tree | ||
| let span = Span { hi: close_span.hi, ..pre_span }; | ||
|
|
||
| match self.token { |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 24, 2016
Contributor
is this code specific to macros? if so, I don't see any tests below that would exercise it.
nikomatsakis
reviewed
Mar 24, 2016
| // Test that we do some basic error correcton in the tokeniser. | ||
|
|
||
| fn main() { | ||
| foo(bar(; //~ NOTE: unclosed delimiter |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 24, 2016
Contributor
I am a bit surprised to see so many errors here. I feel like after the ; we should "reset" and not consider the } to be an error.
nikomatsakis
reviewed
Mar 24, 2016
| @@ -14,4 +14,4 @@ fn main() { | |||
| foo! ( | |||
| bar, "baz", 1, 2.0 | |||
| } //~ ERROR incorrect close delimiter | |||
| } | |||
| } //~ ERROR unexpected close delimiter: `}` | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
reviewed
Mar 24, 2016
| if let Some(&(_, sp)) = self.open_braces.last() { | ||
| err.span_note(sp, "unclosed delimiter"); | ||
| }; | ||
| err.emit(); |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 24, 2016
Contributor
I feel like once we emit one unclosed delimeter error, we should try to avoid reporting any further ones, since all further delimeters are pretty suspect.
nikomatsakis
reviewed
Mar 24, 2016
| // E.g., we try to recover from: | ||
| // fn foo() { | ||
| // bar(baz( | ||
| // } // Incorrect delimiter but matches the earlier `{` |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 24, 2016
Contributor
should this example be bar!(baz(? like, will parse_token_tree be invoked outside of a macro invocation?
This comment has been minimized.
This comment has been minimized.
|
@eddyb tells me that we parse all things as token trees first -- I didn't realize that! Disregard my comments, will re-review. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Oops, totally ran that with the wrong branch. The output is:
|
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Seems good to me. :) |
nrc commentedMar 22, 2016
No description provided.