Skip to content

Commit 8037c28

Browse files
committed
Do not require semantic types for all syntactic types when there are type errors
1 parent 4491ea5 commit 8037c28

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/librustc_typeck/astconv.rs

-10
Original file line numberDiff line numberDiff line change
@@ -988,16 +988,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
988988
}
989989
}
990990
Def::Err => {
991-
for segment in &path.segments {
992-
segment.with_parameters(|parameters| {
993-
for ty in &parameters.types {
994-
self.ast_ty_to_ty(ty);
995-
}
996-
for binding in &parameters.bindings {
997-
self.ast_ty_to_ty(&binding.ty);
998-
}
999-
});
1000-
}
1001991
self.set_tainted_by_errors();
1002992
return self.tcx().types.err;
1003993
}

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
20092009
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {
20102010
match self.tables.borrow().node_types().get(id) {
20112011
Some(&t) => t,
2012-
None if self.err_count_since_creation() != 0 => self.tcx.types.err,
2012+
None if self.is_tainted_by_errors() => self.tcx.types.err,
20132013
None => {
20142014
let node_id = self.tcx.hir.definitions().find_node_for_hir_id(id);
20152015
bug!("no type for node {}: {} in fcx {}",

src/test/compile-fail/type-path-err-node-types.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,29 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Type arguments of unresolved types should have their types recorded
11+
// Type arguments in unresolved entities (reporting errors before type checking)
12+
// should have their types recorded.
1213

13-
fn main() {
14+
trait Tr<T> {}
15+
16+
fn local_type() {
1417
let _: Nonexistent<u8, Assoc = u16>; //~ ERROR cannot find type `Nonexistent` in this scope
18+
}
1519

16-
let _ = |a, b: _| -> _ { 0 };
20+
fn ufcs_trait() {
21+
<u8 as Tr<u8>>::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent`
1722
}
23+
24+
fn ufcs_item() {
25+
NonExistent::Assoc::<u8>; //~ ERROR undeclared type or module `NonExistent`
26+
}
27+
28+
fn method() {
29+
nonexistent.nonexistent::<u8>(); //~ ERROR cannot find value `nonexistent`
30+
}
31+
32+
fn closure() {
33+
let _ = |a, b: _| -> _ { 0 }; // OK
34+
}
35+
36+
fn main() {}

0 commit comments

Comments
 (0)