diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 1d184131dede3..7992befbdc707 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2097,6 +2097,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> { match self.inh.node_types.borrow().get(&id) { Some(&t) => t, + None if self.err_count_since_creation() != 0 => self.tcx().types.err, None => { self.tcx().sess.bug( &format!("no type for node {}: {} in fcx {}", diff --git a/src/test/compile-fail/no-type-for-node-ice.rs b/src/test/compile-fail/no-type-for-node-ice.rs new file mode 100644 index 0000000000000..aab4db6eadfd6 --- /dev/null +++ b/src/test/compile-fail/no-type-for-node-ice.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Related issues: #20401, #20506, #20614, #20752, #20829, #20846, #20885, #20886 + +fn main() { + "".homura[""]; //~ ERROR no field with that name was found +}