Skip to content

Commit a015544

Browse files
committed
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 rust-lang#20401. Fixes rust-lang#20506. Fixes rust-lang#20614. Fixes rust-lang#20752. Fixes rust-lang#20829. Fixes rust-lang#20846. Fixes rust-lang#20885. Fixes rust-lang#20886.
1 parent d2d35db commit a015544

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20972097
pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> {
20982098
match self.inh.node_types.borrow().get(&id) {
20992099
Some(&t) => t,
2100+
None if self.err_count_since_creation() != 0 => self.tcx().types.err,
21002101
None => {
21012102
self.tcx().sess.bug(
21022103
&format!("no type for node {}: {} in fcx {}",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Related issues: #20401, #20506, #20614, #20752, #20829, #20846, #20885, #20886
12+
13+
fn main() {
14+
"".homura[""]; //~ ERROR no field with that name was found
15+
}

0 commit comments

Comments
 (0)