Skip to content

Commit 15a4138

Browse files
committed
auto merge of #20897 : barosl/rust/no-type-for-node-ice, r=nick29581
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. Fixes #20952. Fixes #20970.
2 parents 4bed1e8 + a015544 commit 15a4138

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
@@ -2098,6 +2098,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20982098
pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> {
20992099
match self.inh.node_types.borrow().get(&id) {
21002100
Some(&t) => t,
2101+
None if self.err_count_since_creation() != 0 => self.tcx().types.err,
21012102
None => {
21022103
self.tcx().sess.bug(
21032104
&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)