Prevent missing idents from causing problems down the line
This commit is contained in:
parent
0ac8915875
commit
585cf6fb5f
2 changed files with 17 additions and 5 deletions
|
|
@ -3037,6 +3037,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
check_ribs: bool,
|
||||
record_used: bool)
|
||||
-> Option<LocalDef> {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue