Skip to content

Commit

Permalink
Return TyKind::Error instead of span_bug!
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
  • Loading branch information
JohnTitor committed Dec 22, 2022
1 parent 75f4ee8 commit 7085850
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

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

Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/typeck/issue-106030.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
unknown(1, |glyf| { //~ ERROR: cannot find function `unknown` in this scope
let actual = glyf;
});
}
9 changes: 9 additions & 0 deletions src/test/ui/typeck/issue-106030.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0425]: cannot find function `unknown` in this scope
--> $DIR/issue-106030.rs:2:5
|
LL | unknown(1, |glyf| {
| ^^^^^^^ not found in this scope

error: aborting due to previous error

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

0 comments on commit 7085850

Please sign in to comment.