Skip to content

Commit 9ef83f3

Browse files
committed
Address review comments
1 parent c7a31e1 commit 9ef83f3

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

compiler/rustc_typeck/src/check/demand.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
360360
false
361361
}
362362

363-
crate fn hir_id_sole_block_element(
364-
&self,
365-
hir_id: hir::HirId,
366-
) -> Option<&'tcx rustc_hir::Expr<'tcx>> {
367-
let node: Option<Node<'_>> = self.tcx.hir().find(hir_id);
368-
match node {
369-
Some(Node::Expr(rustc_hir::Expr {
370-
kind: rustc_hir::ExprKind::Block(block, ..),
371-
..
372-
})) if block.stmts.len() == 0 => block.expr,
363+
crate fn hir_id_sole_block_element(&self, hir_id: hir::HirId) -> Option<&'tcx hir::Expr<'tcx>> {
364+
match self.tcx.hir().find(hir_id)? {
365+
Node::Expr(hir::Expr { kind: hir::ExprKind::Block(block, ..), .. }) => block.expr,
373366
_ => None,
374367
}
375368
}

src/test/ui/deref-suggestion.rs

+8
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,12 @@ fn main() {
5555
b
5656
//~^ ERROR mismatched types
5757
};
58+
let val: i32 = if true {
59+
let _ = 2;
60+
a + 1
61+
} else {
62+
let _ = 2;
63+
b
64+
//~^ ERROR mismatched types
65+
};
5866
}

src/test/ui/deref-suggestion.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ LL | b
9898
| expected `i32`, found `&{integer}`
9999
| help: consider dereferencing the borrow: `*b`
100100

101-
error: aborting due to 11 previous errors
101+
error[E0308]: mismatched types
102+
--> $DIR/deref-suggestion.rs:63:9
103+
|
104+
LL | b
105+
| ^
106+
| |
107+
| expected `i32`, found `&{integer}`
108+
| help: consider dereferencing the borrow: `*b`
109+
110+
error: aborting due to 12 previous errors
102111

103112
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)