Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not require semantic types for all syntactic types when there are errors #44945

Merged
merged 1 commit into from
Oct 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,16 +988,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
}
}
Def::Err => {
for segment in &path.segments {
segment.with_parameters(|parameters| {
for ty in &parameters.types {
self.ast_ty_to_ty(ty);
}
for binding in &parameters.bindings {
self.ast_ty_to_ty(&binding.ty);
}
});
}
self.set_tainted_by_errors();
return self.tcx().types.err;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {
match self.tables.borrow().node_types().get(id) {
Some(&t) => t,
None if self.err_count_since_creation() != 0 => self.tcx.types.err,
None if self.is_tainted_by_errors() => self.tcx.types.err,
None => {
let node_id = self.tcx.hir.definitions().find_node_for_hir_id(id);
bug!("no type for node {}: {} in fcx {}",
Expand Down
25 changes: 22 additions & 3 deletions src/test/compile-fail/type-path-err-node-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,29 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

fn main() {
trait Tr<T> {}

fn local_type() {
let _: Nonexistent<u8, Assoc = u16>; //~ ERROR cannot find type `Nonexistent` in this scope
}

let _ = |a, b: _| -> _ { 0 };
fn ufcs_trait() {
<u8 as Tr<u8>>::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent`
}

fn ufcs_item() {
NonExistent::Assoc::<u8>; //~ ERROR undeclared type or module `NonExistent`
}

fn method() {
nonexistent.nonexistent::<u8>(); //~ ERROR cannot find value `nonexistent`
}

fn closure() {
let _ = |a, b: _| -> _ { 0 }; // OK
}

fn main() {}