/// Only used for better errors on `fn(): fn()`.
current_type_ascription: Vec<Span>,
+ /// Only used for better errors on `let x = { foo: bar };`.
+ /// In the case of a parse error with `let x = { foo: bar, };`, this isn't needed, it's only
+ /// needed for cases where this parses as a correct type ascription.
+ current_block_could_be_bare_struct_literal: Option<Span>,
+
/// Only used for better errors on `let <pat>: <expr, not type>;`.
current_let_binding: Option<(Span, Option<Span>, Option<Span>)>,
let instead = res.is_some();
let suggestion =
if res.is_none() { this.report_missing_type_error(path) } else { None };
+ // get_from_node_id
this.r.use_injections.push(UseError {
err,
self.ribs[ValueNS].push(Rib::new(NormalRibKind));
}
+ let prev = self.diagnostic_metadata.current_block_could_be_bare_struct_literal.take();
+ if let (true, [Stmt { kind: StmtKind::Expr(expr), .. }]) =
+ (block.could_be_bare_literal, &block.stmts[..])
+ {
+ if let ExprKind::Type(..) = expr.kind {
+ self.diagnostic_metadata.current_block_could_be_bare_struct_literal =
+ Some(block.span);
+ }
+ }
// Descend into the block.
for stmt in &block.stmts {
if let StmtKind::Item(ref item) = stmt.kind {
self.visit_stmt(stmt);
}
+ self.diagnostic_metadata.current_block_could_be_bare_struct_literal = prev;
// Move back up.
self.parent_scope.module = orig_module;