Skip to content

Commit 577427e

Browse files
committed
Get rid of Block::recovered
1 parent cc2b08d commit 577427e

File tree

13 files changed

+12
-41
lines changed

13 files changed

+12
-41
lines changed

src/librustc/hir/lowering.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,7 +2719,6 @@ impl<'a> LoweringContext<'a> {
27192719
rules: self.lower_block_check_mode(&b.rules),
27202720
span: b.span,
27212721
targeted_by_break,
2722-
recovered: b.recovered,
27232722
})
27242723
}
27252724

@@ -3791,7 +3790,6 @@ impl<'a> LoweringContext<'a> {
37913790
rules: hir::DefaultBlock,
37923791
span,
37933792
targeted_by_break: false,
3794-
recovered: blk.recovered,
37953793
});
37963794
P(self.expr_block(blk, ThinVec::new()))
37973795
}
@@ -4833,7 +4831,6 @@ impl<'a> LoweringContext<'a> {
48334831
rules: hir::DefaultBlock,
48344832
span,
48354833
targeted_by_break: false,
4836-
recovered: false,
48374834
}
48384835
}
48394836

src/librustc/hir/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,6 @@ pub struct Block {
817817
/// break out of this block early.
818818
/// Used by `'label: {}` blocks and by `catch` statements.
819819
pub targeted_by_break: bool,
820-
/// If true, don't emit return value type errors as the parser had
821-
/// to recover from a parse error so this block will not have an
822-
/// appropriate type. A parse error will have been emitted so the
823-
/// compilation will never succeed if this is true.
824-
pub recovered: bool,
825820
}
826821

827822
#[derive(Clone, RustcEncodable, RustcDecodable)]

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ impl_stable_hash_for!(struct hir::Block {
420420
rules,
421421
span,
422422
targeted_by_break,
423-
recovered,
424423
});
425424

426425
impl_stable_hash_for!(struct hir::Pat {

src/librustc_driver/pretty.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,15 +751,13 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
751751

752752
fn fold_block(&mut self, b: P<ast::Block>) -> P<ast::Block> {
753753
fn stmt_to_block(rules: ast::BlockCheckMode,
754-
recovered: bool,
755754
s: Option<ast::Stmt>,
756755
sess: &Session) -> ast::Block {
757756
ast::Block {
758757
stmts: s.into_iter().collect(),
759758
rules,
760759
id: sess.next_node_id(),
761760
span: syntax_pos::DUMMY_SP,
762-
recovered,
763761
}
764762
}
765763

@@ -778,7 +776,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
778776
}
779777
}
780778

781-
let empty_block = stmt_to_block(BlockCheckMode::Default, false, None, self.sess);
779+
let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess);
782780
let loop_expr = P(ast::Expr {
783781
node: ast::ExprKind::Loop(P(empty_block), None),
784782
id: self.sess.next_node_id(),
@@ -819,7 +817,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
819817
old_blocks.push(new_block);
820818
}
821819

822-
stmt_to_block(b.rules, b.recovered, Some(loop_stmt), self.sess)
820+
stmt_to_block(b.rules, Some(loop_stmt), self.sess)
823821
} else {
824822
//push `loop {}` onto the end of our fresh block and yield that
825823
new_block.stmts.push(loop_stmt);

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4757,12 +4757,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47574757
//
47584758
// #41425 -- label the implicit `()` as being the
47594759
// "found type" here, rather than the "expected type".
4760-
//
4761-
// #44579 -- if the block was recovered during parsing,
4762-
// the type would be nonsensical and it is not worth it
4763-
// to perform the type check, so we avoid generating the
4764-
// diagnostic output.
4765-
if !self.diverges.get().always() && !blk.recovered {
4760+
if !self.diverges.get().always() {
47664761
coerce.coerce_forced_unit(self, &self.misc(blk.span), &mut |err| {
47674762
if let Some(expected_ty) = expected.only_has_type(self) {
47684763
self.consider_hint_about_removing_semicolon(blk,

src/libsyntax/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ pub struct Block {
454454
/// Distinguishes between `unsafe { ... }` and `{ ... }`
455455
pub rules: BlockCheckMode,
456456
pub span: Span,
457-
pub recovered: bool,
458457
}
459458

460459
#[derive(Clone, RustcEncodable, RustcDecodable)]

src/libsyntax/ext/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
597597
id: ast::DUMMY_NODE_ID,
598598
rules: BlockCheckMode::Default,
599599
span,
600-
recovered: false,
601600
})
602601
}
603602

src/libsyntax/fold.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,12 +902,11 @@ fn noop_fold_bounds<T: Folder>(bounds: GenericBounds, folder: &mut T)
902902
}
903903

904904
pub fn noop_fold_block<T: Folder>(b: P<Block>, folder: &mut T) -> P<Block> {
905-
b.map(|Block {id, stmts, rules, span, recovered}| Block {
905+
b.map(|Block {id, stmts, rules, span}| Block {
906906
id: folder.new_id(id),
907907
stmts: stmts.move_flat_map(|s| folder.fold_stmt(s).into_iter()),
908908
rules,
909909
span: folder.new_span(span),
910-
recovered,
911910
})
912911
}
913912

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use ast::{UseTree, UseTreeKind};
4242
use ast::{BinOpKind, UnOp};
4343
use ast::{RangeEnd, RangeSyntax};
4444
use {ast, attr};
45+
use ext::base::DummyResult;
4546
use source_map::{self, SourceMap, Spanned, respan};
4647
use syntax_pos::{self, Span, MultiSpan, BytePos, FileName};
4748
use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId};
@@ -4976,16 +4977,16 @@ impl<'a> Parser<'a> {
49764977
/// Precondition: already parsed the '{'.
49774978
fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P<Block>> {
49784979
let mut stmts = vec![];
4979-
let mut recovered = false;
4980-
49814980
while !self.eat(&token::CloseDelim(token::Brace)) {
49824981
let stmt = match self.parse_full_stmt(false) {
49834982
Err(mut err) => {
49844983
err.emit();
49854984
self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore);
4986-
self.eat(&token::CloseDelim(token::Brace));
4987-
recovered = true;
4988-
break;
4985+
Some(Stmt {
4986+
id: ast::DUMMY_NODE_ID,
4987+
node: StmtKind::Expr(DummyResult::raw_expr(self.span)),
4988+
span: self.span,
4989+
})
49894990
}
49904991
Ok(stmt) => stmt,
49914992
};
@@ -5003,7 +5004,6 @@ impl<'a> Parser<'a> {
50035004
id: ast::DUMMY_NODE_ID,
50045005
rules: s,
50055006
span: lo.to(self.prev_span),
5006-
recovered,
50075007
}))
50085008
}
50095009

src/libsyntax_ext/deriving/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,5 @@ fn call_intrinsic(cx: &ExtCtxt,
163163
id: ast::DUMMY_NODE_ID,
164164
rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated),
165165
span,
166-
recovered: false,
167166
}))
168167
}

src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P<Expr>)) {
115115
id: DUMMY_NODE_ID,
116116
rules: BlockCheckMode::Default,
117117
span: DUMMY_SP,
118-
recovered: false,
119118
});
120119
iter_exprs(depth - 1, &mut |e| g(ExprKind::If(e, block.clone(), None)));
121120
},

src/test/ui/issues/issue-10536.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ pub fn main() {
3030
// least throw a conventional error.
3131
assert!({one! two});
3232
//~^ ERROR expected `(` or `{`, found `}`
33-
//~| ERROR cannot apply unary operator `!` to type `!`
3433
}

src/test/ui/issues/issue-10536.stderr

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ LL | assert!({one! two()});
2525
= note: expected type `bool`
2626
found type `()`
2727

28-
error[E0600]: cannot apply unary operator `!` to type `!`
29-
--> $DIR/issue-10536.rs:31:5
30-
|
31-
LL | assert!({one! two});
32-
| ^^^^^^^^^^^^^^^^^^^^ cannot apply unary operator `!`
33-
34-
error: aborting due to 5 previous errors
28+
error: aborting due to 4 previous errors
3529

36-
Some errors occurred: E0308, E0600.
37-
For more information about an error, try `rustc --explain E0308`.
30+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)