From a0155444cff7f4f479c568b474057e6efb73502c Mon Sep 17 00:00:00 2001 From: Barosl Lee Date: Sun, 11 Jan 2015 05:07:43 +0900 Subject: [PATCH] Permit node types to be missing if type errors occurred previously If the type of a node cannot be determined due to a previous type error, a "no type for node" ICE occurs. This commit makes it return ty_err instead in such a case. Fixes #20401. Fixes #20506. Fixes #20614. Fixes #20752. Fixes #20829. Fixes #20846. Fixes #20885. Fixes #20886. --- src/librustc_typeck/check/mod.rs | 1 + src/test/compile-fail/no-type-for-node-ice.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/compile-fail/no-type-for-node-ice.rs 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 +}