Skip to content

Commit 290bb5f

Browse files
authored
Rollup merge of #106039 - JohnTitor:issue-106030, r=oli-obk
Return `TyKind::Error` instead of `span_bug!` r? ``@oli-obk`` Fixes #106030 Signed-off-by: Yuki Okushi <[email protected]>
2 parents fa1b36c + 7085850 commit 290bb5f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
130130

131131
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> {
132132
self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| {
133-
span_bug!(span, "no type for local variable {}", self.tcx.hir().node_to_string(nid))
133+
let err = self.tcx.ty_error_with_message(
134+
span,
135+
&format!("no type for local variable {}", self.tcx.hir().node_to_string(nid)),
136+
);
137+
LocalTy { decl_ty: err, revealed_ty: err }
134138
})
135139
}
136140

src/test/ui/typeck/issue-106030.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
unknown(1, |glyf| { //~ ERROR: cannot find function `unknown` in this scope
3+
let actual = glyf;
4+
});
5+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find function `unknown` in this scope
2+
--> $DIR/issue-106030.rs:2:5
3+
|
4+
LL | unknown(1, |glyf| {
5+
| ^^^^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)