Skip to content

Commit 4ac5925

Browse files
committed
Get rid of Block::recovered
1 parent fff01cc commit 4ac5925

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
@@ -2709,7 +2709,6 @@ impl<'a> LoweringContext<'a> {
27092709
rules: self.lower_block_check_mode(&b.rules),
27102710
span: b.span,
27112711
targeted_by_break,
2712-
recovered: b.recovered,
27132712
})
27142713
}
27152714

@@ -3781,7 +3780,6 @@ impl<'a> LoweringContext<'a> {
37813780
rules: hir::DefaultBlock,
37823781
span,
37833782
targeted_by_break: false,
3784-
recovered: blk.recovered,
37853783
});
37863784
P(self.expr_block(blk, ThinVec::new()))
37873785
}
@@ -4823,7 +4821,6 @@ impl<'a> LoweringContext<'a> {
48234821
rules: hir::DefaultBlock,
48244822
span,
48254823
targeted_by_break: false,
4826-
recovered: false,
48274824
}
48284825
}
48294826

src/librustc/hir/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,6 @@ pub struct Block {
807807
/// break out of this block early.
808808
/// Used by `'label: {}` blocks and by `catch` statements.
809809
pub targeted_by_break: bool,
810-
/// If true, don't emit return value type errors as the parser had
811-
/// to recover from a parse error so this block will not have an
812-
/// appropriate type. A parse error will have been emitted so the
813-
/// compilation will never succeed if this is true.
814-
pub recovered: bool,
815810
}
816811

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

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ impl_stable_hash_for!(struct hir::Block {
410410
rules,
411411
span,
412412
targeted_by_break,
413-
recovered,
414413
});
415414

416415
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
@@ -741,15 +741,13 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
741741

742742
fn fold_block(&mut self, b: P<ast::Block>) -> P<ast::Block> {
743743
fn stmt_to_block(rules: ast::BlockCheckMode,
744-
recovered: bool,
745744
s: Option<ast::Stmt>,
746745
sess: &Session) -> ast::Block {
747746
ast::Block {
748747
stmts: s.into_iter().collect(),
749748
rules,
750749
id: sess.next_node_id(),
751750
span: syntax_pos::DUMMY_SP,
752-
recovered,
753751
}
754752
}
755753

@@ -768,7 +766,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
768766
}
769767
}
770768

771-
let empty_block = stmt_to_block(BlockCheckMode::Default, false, None, self.sess);
769+
let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess);
772770
let loop_expr = P(ast::Expr {
773771
node: ast::ExprKind::Loop(P(empty_block), None),
774772
id: self.sess.next_node_id(),
@@ -809,7 +807,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
809807
old_blocks.push(new_block);
810808
}
811809

812-
stmt_to_block(b.rules, b.recovered, Some(loop_stmt), self.sess)
810+
stmt_to_block(b.rules, Some(loop_stmt), self.sess)
813811
} else {
814812
//push `loop {}` onto the end of our fresh block and yield that
815813
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
@@ -4772,12 +4772,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47724772
//
47734773
// #41425 -- label the implicit `()` as being the
47744774
// "found type" here, rather than the "expected type".
4775-
//
4776-
// #44579 -- if the block was recovered during parsing,
4777-
// the type would be nonsensical and it is not worth it
4778-
// to perform the type check, so we avoid generating the
4779-
// diagnostic output.
4780-
if !self.diverges.get().always() && !blk.recovered {
4775+
if !self.diverges.get().always() {
47814776
coerce.coerce_forced_unit(self, &self.misc(blk.span), &mut |err| {
47824777
if let Some(expected_ty) = expected.only_has_type(self) {
47834778
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
@@ -444,7 +444,6 @@ pub struct Block {
444444
/// Distinguishes between `unsafe { ... }` and `{ ... }`
445445
pub rules: BlockCheckMode,
446446
pub span: Span,
447-
pub recovered: bool,
448447
}
449448

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

src/libsyntax/ext/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
587587
id: ast::DUMMY_NODE_ID,
588588
rules: BlockCheckMode::Default,
589589
span,
590-
recovered: false,
591590
})
592591
}
593592

src/libsyntax/fold.rs

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

894894
pub fn noop_fold_block<T: Folder>(b: P<Block>, folder: &mut T) -> P<Block> {
895-
b.map(|Block {id, stmts, rules, span, recovered}| Block {
895+
b.map(|Block {id, stmts, rules, span}| Block {
896896
id: folder.new_id(id),
897897
stmts: stmts.move_flat_map(|s| folder.fold_stmt(s).into_iter()),
898898
rules,
899899
span: folder.new_span(span),
900-
recovered,
901900
})
902901
}
903902

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use ast::{UseTree, UseTreeKind};
3232
use ast::{BinOpKind, UnOp};
3333
use ast::{RangeEnd, RangeSyntax};
3434
use {ast, attr};
35+
use ext::base::DummyResult;
3536
use source_map::{self, SourceMap, Spanned, respan};
3637
use syntax_pos::{self, Span, MultiSpan, BytePos, FileName};
3738
use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId};
@@ -4966,16 +4967,16 @@ impl<'a> Parser<'a> {
49664967
/// Precondition: already parsed the '{'.
49674968
fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P<Block>> {
49684969
let mut stmts = vec![];
4969-
let mut recovered = false;
4970-
49714970
while !self.eat(&token::CloseDelim(token::Brace)) {
49724971
let stmt = match self.parse_full_stmt(false) {
49734972
Err(mut err) => {
49744973
err.emit();
49754974
self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore);
4976-
self.eat(&token::CloseDelim(token::Brace));
4977-
recovered = true;
4978-
break;
4975+
Some(Stmt {
4976+
id: ast::DUMMY_NODE_ID,
4977+
node: StmtKind::Expr(DummyResult::raw_expr(self.span)),
4978+
span: self.span,
4979+
})
49794980
}
49804981
Ok(stmt) => stmt,
49814982
};
@@ -4993,7 +4994,6 @@ impl<'a> Parser<'a> {
49934994
id: ast::DUMMY_NODE_ID,
49944995
rules: s,
49954996
span: lo.to(self.prev_span),
4996-
recovered,
49974997
}))
49984998
}
49994999

src/libsyntax_ext/deriving/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,5 @@ fn call_intrinsic(cx: &ExtCtxt,
153153
id: ast::DUMMY_NODE_ID,
154154
rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated),
155155
span,
156-
recovered: false,
157156
}))
158157
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P<Expr>)) {
105105
id: DUMMY_NODE_ID,
106106
rules: BlockCheckMode::Default,
107107
span: DUMMY_SP,
108-
recovered: false,
109108
});
110109
iter_exprs(depth - 1, &mut |e| g(ExprKind::If(e, block.clone(), None)));
111110
},

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

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

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)