diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index fb4eb61ceb4d4..e30fafda63cb4 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3037,6 +3037,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { check_ribs: bool, record_used: bool) -> Option { + if identifier.name == special_idents::invalid.name { + return Some(LocalDef::from_def(DefErr)); + } + // First, check to see whether the name is a primitive type. if namespace == TypeNS { if let Some(&prim_ty) = self.primitive_type_table diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index f49b25df66e87..922ebb3683e80 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -121,7 +121,7 @@ use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::codemap::{self, Span, Spanned}; use syntax::errors::DiagnosticBuilder; -use syntax::parse::token::{self, InternedString}; +use syntax::parse::token::{self, InternedString, special_idents}; use syntax::ptr::P; use syntax::util::lev_distance::find_best_match_for_name; @@ -2839,8 +2839,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, method_ty } Err(error) => { - method::report_error(fcx, method_name.span, expr_t, - method_name.node, Some(rcvr), error); + if method_name.node != special_idents::invalid.name { + method::report_error(fcx, method_name.span, expr_t, + method_name.node, Some(rcvr), error); + } fcx.write_error(expr.id); fcx.tcx().types.err } @@ -2938,6 +2940,11 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, None => {} } + if field.node == special_idents::invalid.name { + fcx.write_error(expr.id); + return; + } + if method::exists(fcx, field.span, field.node, expr_t, expr.id) { fcx.type_error_struct(field.span, |actual| { @@ -3788,8 +3795,9 @@ pub fn resolve_ty_and_def_ufcs<'a, 'b, 'tcx>(fcx: &FnCtxt<'b, 'tcx>, Some((Some(ty), slice::ref_slice(item_segment), def)) } Err(error) => { - method::report_error(fcx, span, ty, - item_name, None, error); + if item_name != special_idents::invalid.name { + method::report_error(fcx, span, ty, item_name, None, error); + } fcx.write_error(node_id); None }