Uh oh!
There was an error while loading. Please reload this page.
Do not emit type errors on recovered blocks - #46732
Conversation
rust-highfive
commented
Dec 14, 2017
(rust_highfive has picked a reviewer for you, use r? to override) |
ce52a2d to
d2d3f94Comparepetrochenkov
commented
Dec 14, 2017
The case reported in #44579 is 100% reasonable recovery. (Also, the "unmatched visibility" wording was really weird and unhelpful (unmatched with what?), it's really nice that it's changed to "missing |
petrochenkov
commented
Dec 14, 2017
Output on nightly, the first error is much more visible now: |
estebank
commented
Dec 14, 2017
@petrochenkov the first error is more prominent now in this case, but any syntax error will cause the type error to happen. Consider the following case instead: pubstructFoo{text:String}pubfnparse() -> Foo{fnFoo{ text:"".to_string()}}The second error won't happen once the syntax error is fixed, but the compiler can't know that, and it is still the most vertically prominent error in the output. I feel that masking the type error when we know the block had a parse error (that we made an effort to continue after) is a better default. |
c6ceea9 to
d99aef8Comparebors
commented
Dec 15, 2017
☔ The latest upstream changes (presumably #46641) made this pull request unmergeable. Please resolve the merge conflicts. |
0d5a2f8 to
736e9b8Comparepetrochenkov
commented
Dec 15, 2017
If some piece of code look so similar to a legal statement that we recover it as a legal statement (e.g. an item statement in case of pubfnparse() -> Foo{ <not_poisoned>
let args:Vec<String> = env::args().collect();let text = args[1].clone();pubFoo{ <poisoned> text </poisoned> }
</not_poisoned> }In the example with pubfnparse() -> Foo{ <poisoned>
fn
Foo{text:"".to_string()}
</poisoned> }I need to make some experiments. |
d5c526f to
0d5b144CompareThere was a problem hiding this comment.
This seems to be a change independent from adding the recovered flag to blocks?
From what I see in the test diffs I'd keep this recovery in place.
There was a problem hiding this comment.
The recovery happens in the callee already, and using parse_stmt_ swallows errors that we do want to see in parse_block_tail.
There was a problem hiding this comment.
Could you add the example with fn (#46732 (comment)) as a test too?
petrochenkov
commented
Dec 16, 2017
r=me with comments addressed I still want to look at the statement recovery more carefully, but not right now (probably replace the |
9e392e2 to
351f06aCompareestebank
commented
Dec 18, 2017
@bors r=petrochencov |
bors
commented
Dec 18, 2017
📌 Commit 351f06a has been approved by |
bors
commented
Dec 18, 2017
Do not emit type errors on recovered blocks When a parse error occurs on a block, the parser will recover and create a block with the statements collected until that point. Now a flag stating that a recovery has been performed in this block is propagated so that the type checker knows that the type of the block (which will be identified as `()`) shouldn't be checked against the expectation to reduce the amount of irrelevant diagnostic errors shown to the user. Fix#44579.
bors
commented
Dec 18, 2017
💔 Test failed - status-appveyor |
petrochenkov
commented
Dec 18, 2017
rustfmt and rls are marked as "Broken" in https://github.com/rust-lang/rust/blob/master/src/tools/toolstate.toml, a pull request to rustfmt can be sent asyncroniously. |
estebank
commented
Dec 18, 2017
Already marked as broken, looks like the failure was due to sscache. @bors r=petrochenkov |
bors
commented
Dec 18, 2017
📌 Commit 351f06a has been approved by |
bors
commented
Dec 19, 2017
⌛ Testing commit 351f06a with merge a6c1141a37b6b16e467ca070daf55948e9068045... |
bors
commented
Dec 19, 2017
💔 Test failed - status-travis |
kennytm
commented
Dec 19, 2017
RLS and rustfmt are still broken. |
When a parse error occurs on a block, the parser will recover and create a block with the statements collected until that point. Now a flag stating that a recovery has been performed in this block is propagated so that the type checker knows that the type of the block (which will be identified as `()`) shouldn't be checked against the expectation to reduce the amount of irrelevant diagnostic errors shown to the user.
351f06a to
d90d5d1Compareestebank
commented
Dec 21, 2017
@bors try |
bors
commented
Dec 21, 2017
Do not emit type errors on recovered blocks When a parse error occurs on a block, the parser will recover and create a block with the statements collected until that point. Now a flag stating that a recovery has been performed in this block is propagated so that the type checker knows that the type of the block (which will be identified as `()`) shouldn't be checked against the expectation to reduce the amount of irrelevant diagnostic errors shown to the user. Fix#44579.
bors
commented
Dec 22, 2017
☀️ Test successful - status-travis |
estebank
commented
Dec 22, 2017
@bors r=petrochenkov |
bors
commented
Dec 22, 2017
📌 Commit d90d5d1 has been approved by |
Do not emit type errors on recovered blocks When a parse error occurs on a block, the parser will recover and create a block with the statements collected until that point. Now a flag stating that a recovery has been performed in this block is propagated so that the type checker knows that the type of the block (which will be identified as `()`) shouldn't be checked against the expectation to reduce the amount of irrelevant diagnostic errors shown to the user. Fix#44579.
bors
commented
Dec 22, 2017
bors
commented
Dec 22, 2017
☀️ Test successful - status-appveyor, status-travis |
bluss
commented
Jan 1, 2018
Awesome! Thanks a lot for this |
When a parse error occurs on a block, the parser will recover and create
a block with the statements collected until that point. Now a flag
stating that a recovery has been performed in this block is propagated
so that the type checker knows that the type of the block (which will be
identified as
()) shouldn't be checked against the expectation toreduce the amount of irrelevant diagnostic errors shown to the user.
Fix#44579.