Use block_symbol in var_value_operation

Message ID 20210401164346.2353102-1-tromey@adacore.com
State New
Headers show
Series
  • Use block_symbol in var_value_operation
Related show

Commit Message

Tom Tromey April 1, 2021, 4:43 p.m.
I noticed that var_value_operation takes a block and a symbol, and
most callers destructure a block_symbol to pass in.  It seems better
for this class to simply hold a block_symbol instead.

Tested on x86-64 Fedora 32.

gdb/ChangeLog
2021-04-01  Tom Tromey  <tromey@adacore.com>

	* rust-exp.y (rust_parser::convert_ast_to_expression): Update.
	* parse.c (parser_state::push_symbol, parser_state::push_dollar):
	Update.
	* p-exp.y (variable): Update.
	* m2-exp.y (variable): Update.
	* go-exp.y (variable): Update.
	* expprint.c (dump_for_expression): New overload.
	* expop.h (check_objfile): New overload.
	(check_constant): New overload.
	(class var_value_operation): Use block_symbol.
	<get_symbol>: Rewrite.
	* eval.c (var_value_operation::evaluate)
	(var_value_operation::evaluate_funcall)
	(var_value_operation::evaluate_for_address)
	(var_value_operation::evaluate_for_address)
	(var_value_operation::evaluate_with_coercion)
	(var_value_operation::evaluate_for_sizeof)
	(var_value_operation::evaluate_for_cast): Update.
	* d-exp.y (PrimaryExpression): Update.
	* c-exp.y (variable): Update.
	* ax-gdb.c (var_value_operation::do_generate_ax): Update.
	* ada-lang.c (ada_var_value_operation::evaluate_for_cast)
	(ada_var_value_operation::evaluate)
	(ada_var_value_operation::resolve)
	(ada_funcall_operation::resolve): Update.
	* ada-exp.y (write_var_from_sym, write_object_renaming)
	(write_ambiguous_var, write_var_or_type, write_name_assoc)
	(maybe_overload): Update.
	* ada-exp.h (class ada_var_value_operation) <get_block>: Rewrite.
---
 gdb/ChangeLog  | 34 +++++++++++++++++++++++++++++++++-
 gdb/ada-exp.h  |  4 ++--
 gdb/ada-exp.y  | 25 +++++++++++--------------
 gdb/ada-lang.c | 19 +++++++++----------
 gdb/ax-gdb.c   |  6 +++---
 gdb/c-exp.y    | 13 +++++++------
 gdb/d-exp.y    |  3 +--
 gdb/eval.c     | 24 +++++++++++++-----------
 gdb/expop.h    | 33 +++++++++++++++++++++++++--------
 gdb/expprint.c |  9 +++++++++
 gdb/go-exp.y   |  3 +--
 gdb/m2-exp.y   |  7 +++----
 gdb/p-exp.y    |  6 ++----
 gdb/parse.c    |  4 ++--
 gdb/rust-exp.y |  2 +-
 15 files changed, 122 insertions(+), 70 deletions(-)

-- 
2.26.2

Comments

Tom Tromey April 15, 2021, 4:05 p.m. | #1
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:


Tom> I noticed that var_value_operation takes a block and a symbol, and
Tom> most callers destructure a block_symbol to pass in.  It seems better
Tom> for this class to simply hold a block_symbol instead.

I'm checking this in.

Tom

Patch

diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 82941dd0634..598dc7072ad 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -1,6 +1,6 @@ 
 /* Definitions for Ada expressions
 
-   Copyright (C) 2020 Free Software Foundation, Inc.
+   Copyright (C) 2020, 2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -352,7 +352,7 @@  class ada_var_value_operation
 			    enum noside noside) override;
 
   const block *get_block () const
-  { return std::get<1> (m_storage); }
+  { return std::get<0> (m_storage).block; }
 
   bool resolve (struct expression *exp,
 		bool deprocedure_p,
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 146b1acbe14..7b1b60fd46b 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -194,8 +194,7 @@  maybe_overload (enum exp_opcode op, operation_up &lhs, operation_up &rhs)
 
   if (symbol_read_needs_frame (fn.symbol))
     pstate->block_tracker->update (fn.block, INNERMOST_BLOCK_FOR_SYMBOLS);
-  operation_up callee
-    = make_operation<ada_var_value_operation> (fn.symbol, fn.block);
+  operation_up callee = make_operation<ada_var_value_operation> (fn);
 
   std::vector<operation_up> argvec;
   argvec.push_back (std::move (lhs));
@@ -1124,14 +1123,12 @@  yyerror (const char *msg)
    non-NULL).  */
 
 static void
-write_var_from_sym (struct parser_state *par_state,
-		    const struct block *block,
-		    struct symbol *sym)
+write_var_from_sym (struct parser_state *par_state, block_symbol sym)
 {
-  if (symbol_read_needs_frame (sym))
-    par_state->block_tracker->update (block, INNERMOST_BLOCK_FOR_SYMBOLS);
+  if (symbol_read_needs_frame (sym.symbol))
+    par_state->block_tracker->update (sym.block, INNERMOST_BLOCK_FOR_SYMBOLS);
 
-  par_state->push_new<ada_var_value_operation> (sym, block);
+  par_state->push_new<ada_var_value_operation> (sym);
 }
 
 /* Write integer or boolean constant ARG of type TYPE.  */
@@ -1190,7 +1187,7 @@  write_object_renaming (struct parser_state *par_state,
 				&inner_renaming_expr))
       {
       case ADA_NOT_RENAMING:
-	write_var_from_sym (par_state, sym_info.block, sym_info.symbol);
+	write_var_from_sym (par_state, sym_info);
 	break;
       case ADA_OBJECT_RENAMING:
 	write_object_renaming (par_state, sym_info.block,
@@ -1247,8 +1244,7 @@  write_object_renaming (struct parser_state *par_state,
 	    else if (SYMBOL_CLASS (index_sym_info.symbol) == LOC_TYPEDEF)
 	      /* Index is an old-style renaming symbol.  */
 	      index_sym_info.block = orig_left_context;
-	    write_var_from_sym (par_state, index_sym_info.block,
-				index_sym_info.symbol);
+	    write_var_from_sym (par_state, index_sym_info);
 	  }
 	if (slice_state == SIMPLE_INDEX)
 	  ada_funcall (1);
@@ -1458,7 +1454,8 @@  write_ambiguous_var (struct parser_state *par_state,
   sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len));
   sym->set_language (language_ada, nullptr);
 
-  par_state->push_new<ada_var_value_operation> (sym, block);
+  block_symbol bsym { sym, block };
+  par_state->push_new<ada_var_value_operation> (bsym);
 }
 
 /* A convenient wrapper around ada_get_field_index that takes
@@ -1637,7 +1634,7 @@  write_var_or_type (struct parser_state *par_state,
 
 	  if (syms.size () == 1)
 	    {
-	      write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
+	      write_var_from_sym (par_state, syms[0]);
 	      write_selectors (par_state, encoded_name + tail_index);
 	      return NULL;
 	    }
@@ -1711,7 +1708,7 @@  write_name_assoc (struct parser_state *par_state, struct stoken name)
       if (syms.size () != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
 	pstate->push_new<ada_string_operation> (copy_name (name));
       else
-	write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
+	write_var_from_sym (par_state, syms[0]);
     }
   else
     if (write_var_or_type (par_state, NULL, name) != NULL)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index e5fbf74ef27..f7860f27bfc 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10248,8 +10248,8 @@  ada_var_value_operation::evaluate_for_cast (struct type *expect_type,
 					    enum noside noside)
 {
   value *val = evaluate_var_value (noside,
-				   std::get<1> (m_storage),
-				   std::get<0> (m_storage));
+				   std::get<0> (m_storage).block,
+				   std::get<0> (m_storage).symbol);
 
   val = ada_value_cast (expect_type, val);
 
@@ -10269,7 +10269,7 @@  ada_var_value_operation::evaluate (struct type *expect_type,
 				   struct expression *exp,
 				   enum noside noside)
 {
-  symbol *sym = std::get<0> (m_storage);
+  symbol *sym = std::get<0> (m_storage).symbol;
 
   if (SYMBOL_DOMAIN (sym) == UNDEF_DOMAIN)
     /* Only encountered when an unresolved symbol occurs in a
@@ -10360,19 +10360,19 @@  ada_var_value_operation::resolve (struct expression *exp,
 				  innermost_block_tracker *tracker,
 				  struct type *context_type)
 {
-  symbol *sym = std::get<0> (m_storage);
+  symbol *sym = std::get<0> (m_storage).symbol;
   if (SYMBOL_DOMAIN (sym) == UNDEF_DOMAIN)
     {
       block_symbol resolved
-	= ada_resolve_variable (sym, std::get<1> (m_storage),
+	= ada_resolve_variable (sym, std::get<0> (m_storage).block,
 				context_type, parse_completion,
 				deprocedure_p, tracker);
-      std::get<0> (m_storage) = resolved.symbol;
-      std::get<1> (m_storage) = resolved.block;
+      std::get<0> (m_storage) = resolved;
     }
 
   if (deprocedure_p
-      && SYMBOL_TYPE (std::get<0> (m_storage))->code () == TYPE_CODE_FUNC)
+      && (SYMBOL_TYPE (std::get<0> (m_storage).symbol)->code ()
+	  == TYPE_CODE_FUNC))
     return true;
 
   return false;
@@ -10694,8 +10694,7 @@  ada_funcall_operation::resolve (struct expression *exp,
 			   tracker);
 
   std::get<0> (m_storage)
-    = make_operation<ada_var_value_operation> (resolved.symbol,
-					       resolved.block);
+    = make_operation<ada_var_value_operation> (resolved);
   return false;
 }
 
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 33fc5383764..009c128c83c 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1980,16 +1980,16 @@  var_value_operation::do_generate_ax (struct expression *exp,
 				     struct axs_value *value,
 				     struct type *cast_type)
 {
-  gen_var_ref (ax, value, std::get<0> (m_storage));
+  gen_var_ref (ax, value, std::get<0> (m_storage).symbol);
 
   if (value->optimized_out)
     error (_("`%s' has been optimized out, cannot use"),
-	   std::get<0> (m_storage)->print_name ());
+	   std::get<0> (m_storage).symbol->print_name ());
 
   if (value->type->code () == TYPE_CODE_ERROR)
     {
       if (cast_type == nullptr)
-	error_unknown_type (std::get<0> (m_storage)->print_name ());
+	error_unknown_type (std::get<0> (m_storage).symbol->print_name ());
       value->type = cast_type;
     }
 }
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index c0e4b494f3d..6f4c7d65132 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1125,8 +1125,7 @@  variable:	block COLONCOLON name
 			  if (symbol_read_needs_frame (sym.symbol))
 			    pstate->block_tracker->update (sym);
 
-			  pstate->push_new<var_value_operation> (sym.symbol,
-								 sym.block);
+			  pstate->push_new<var_value_operation> (sym);
 			}
 	;
 
@@ -1197,8 +1196,7 @@  variable:	name_not_typename
 				pstate->push_new<var_msym_value_operation>
 				  (resolver);
 			      else
-				pstate->push_new<var_value_operation>
-				  (sym.symbol, sym.block);
+				pstate->push_new<var_value_operation> (sym);
 			    }
 			  else if ($1.is_a_field_of_this)
 			    {
@@ -1239,8 +1237,11 @@  variable:	name_not_typename
 				   ? find_function_alias_target (msymbol)
 				   : NULL);
 			      if (alias_target != NULL)
-				pstate->push_new<var_value_operation>
-				  (alias_target, SYMBOL_BLOCK_VALUE (alias_target));
+				{
+				  block_symbol bsym { alias_target,
+				    SYMBOL_BLOCK_VALUE (alias_target) };
+				  pstate->push_new<var_value_operation> (bsym);
+				}
 			      else
 				pstate->push_new<var_msym_value_operation>
 				  (msymbol);
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 90c342e0e21..f72fbcfc116 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -452,8 +452,7 @@  PrimaryExpression:
 		    {
 		      if (symbol_read_needs_frame (sym.symbol))
 			pstate->block_tracker->update (sym);
-		      pstate->push_new<var_value_operation> (sym.symbol,
-							     sym.block);
+		      pstate->push_new<var_value_operation> (sym);
 		    }
 		  else if (is_a_field_of_this.type != NULL)
 		     {
diff --git a/gdb/eval.c b/gdb/eval.c
index 363ab4fa4af..1b3c974009a 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -579,10 +579,10 @@  var_value_operation::evaluate (struct type *expect_type,
 			       struct expression *exp,
 			       enum noside noside)
 {
-  symbol *var = std::get<0> (m_storage);
+  symbol *var = std::get<0> (m_storage).symbol;
   if (SYMBOL_TYPE (var)->code () == TYPE_CODE_ERROR)
     error_unknown_type (var->print_name ());
-  return evaluate_var_value (noside, std::get<1> (m_storage), var);
+  return evaluate_var_value (noside, std::get<0> (m_storage).block, var);
 }
 
 } /* namespace expr */
@@ -719,12 +719,13 @@  var_value_operation::evaluate_funcall (struct type *expect_type,
 
   struct symbol *symp;
   find_overload_match (argvec, NULL, NON_METHOD,
-		       NULL, std::get<0> (m_storage),
+		       NULL, std::get<0> (m_storage).symbol,
 		       NULL, &symp, NULL, 0, noside);
 
   if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR)
     error_unknown_type (symp->print_name ());
-  value *callee = evaluate_var_value (noside, std::get<1> (m_storage), symp);
+  value *callee = evaluate_var_value (noside, std::get<0> (m_storage).block,
+				      symp);
 
   return evaluate_subexp_do_call (exp, noside, callee, argvec,
 				  nullptr, expect_type);
@@ -2573,7 +2574,7 @@  value *
 var_value_operation::evaluate_for_address (struct expression *exp,
 					   enum noside noside)
 {
-  symbol *var = std::get<0> (m_storage);
+  symbol *var = std::get<0> (m_storage).symbol;
 
   /* C++: The "address" of a reference should yield the address
    * of the object pointed to.  Let value_addr() deal with it.  */
@@ -2593,20 +2594,21 @@  var_value_operation::evaluate_for_address (struct expression *exp,
       return value_zero (type, not_lval);
     }
   else
-    return address_of_variable (var, std::get<1> (m_storage));
+    return address_of_variable (var, std::get<0> (m_storage).block);
 }
 
 value *
 var_value_operation::evaluate_with_coercion (struct expression *exp,
 					     enum noside noside)
 {
-  struct symbol *var = std::get<0> (m_storage);
+  struct symbol *var = std::get<0> (m_storage).symbol;
   struct type *type = check_typedef (SYMBOL_TYPE (var));
   if (type->code () == TYPE_CODE_ARRAY
       && !type->is_vector ()
       && CAST_IS_CONVERSION (exp->language_defn))
     {
-      struct value *val = address_of_variable (var, std::get<1> (m_storage));
+      struct value *val = address_of_variable (var,
+					       std::get<0> (m_storage).block);
       return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), val);
     }
   return evaluate (nullptr, exp, noside);
@@ -2730,7 +2732,7 @@  value *
 var_value_operation::evaluate_for_sizeof (struct expression *exp,
 					  enum noside noside)
 {
-  struct type *type = SYMBOL_TYPE (std::get<0> (m_storage));
+  struct type *type = SYMBOL_TYPE (std::get<0> (m_storage).symbol);
   if (is_dynamic_type (type))
     {
       value *val = evaluate (nullptr, exp, EVAL_NORMAL);
@@ -2778,8 +2780,8 @@  var_value_operation::evaluate_for_cast (struct type *to_type,
 					enum noside noside)
 {
   value *val = evaluate_var_value (noside,
-				   std::get<1> (m_storage),
-				   std::get<0> (m_storage));
+				   std::get<0> (m_storage).block,
+				   std::get<0> (m_storage).symbol);
 
   val = value_cast (to_type, val);
 
diff --git a/gdb/expop.h b/gdb/expop.h
index cc8d9ca6741..b8e28b5a590 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -221,7 +221,7 @@  check_objfile (struct objfile *exp_objfile, struct objfile *objfile)
   return exp_objfile == objfile;
 }
 
-static inline bool 
+static inline bool
 check_objfile (struct type *type, struct objfile *objfile)
 {
   struct objfile *ty_objfile = type->objfile_owner ();
@@ -230,18 +230,25 @@  check_objfile (struct type *type, struct objfile *objfile)
   return false;
 }
 
-static inline bool 
+static inline bool
 check_objfile (struct symbol *sym, struct objfile *objfile)
 {
   return check_objfile (symbol_objfile (sym), objfile);
 }
 
-static inline bool 
+static inline bool
 check_objfile (const struct block *block, struct objfile *objfile)
 {
   return check_objfile (block_objfile (block), objfile);
 }
 
+static inline bool
+check_objfile (const block_symbol &sym, struct objfile *objfile)
+{
+  return (check_objfile (sym.symbol, objfile)
+	  || check_objfile (sym.block, objfile));
+}
+
 static inline bool
 check_objfile (bound_minimal_symbol minsym, struct objfile *objfile)
 {
@@ -260,7 +267,7 @@  check_objfile (const std::string &str, struct objfile *objfile)
   return false;
 }
 
-static inline bool 
+static inline bool
 check_objfile (const operation_up &op, struct objfile *objfile)
 {
   return op->uses_objfile (objfile);
@@ -286,7 +293,7 @@  check_objfile (enum_flags<T> val, struct objfile *objfile)
 }
 
 template<typename T>
-static inline bool 
+static inline bool
 check_objfile (const std::vector<T> &collection, struct objfile *objfile)
 {
   for (const auto &item : collection)
@@ -298,7 +305,7 @@  check_objfile (const std::vector<T> &collection, struct objfile *objfile)
 }
 
 template<typename S, typename T>
-static inline bool 
+static inline bool
 check_objfile (const std::pair<S, T> &item, struct objfile *objfile)
 {
   return (check_objfile (item.first, objfile)
@@ -327,6 +334,8 @@  extern void dump_for_expression (struct ui_file *stream, int depth,
 				 internalvar *ivar);
 extern void dump_for_expression (struct ui_file *stream, int depth,
 				 symbol *sym);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+				 const block_symbol &sym);
 extern void dump_for_expression (struct ui_file *stream, int depth,
 				 bound_minimal_symbol msym);
 extern void dump_for_expression (struct ui_file *stream, int depth,
@@ -480,6 +489,14 @@  check_constant (struct symbol *sym)
 	  || sc == LOC_LABEL);
 }
 
+static inline bool
+check_constant (const block_symbol &sym)
+{
+  /* We know the block is constant, so we only need to check the
+     symbol.  */
+  return check_constant (sym.symbol);
+}
+
 template<typename T>
 static inline bool
 check_constant (const std::vector<T> &collection)
@@ -612,7 +629,7 @@  class scope_operation
 
 /* Compute the value of a variable.  */
 class var_value_operation
-  : public maybe_constant_operation<symbol *, const block *>
+  : public maybe_constant_operation<block_symbol>
 {
 public:
 
@@ -646,7 +663,7 @@  class var_value_operation
   /* Return the symbol referenced by this object.  */
   symbol *get_symbol () const
   {
-    return std::get<0> (m_storage);
+    return std::get<0> (m_storage).symbol;
   }
 
 protected:
diff --git a/gdb/expprint.c b/gdb/expprint.c
index e228beb83a5..0c21ce9eaae 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -123,6 +123,15 @@  dump_for_expression (struct ui_file *stream, int depth, const block *bl)
   fprintf_filtered (stream, _("%*sBlock: %p\n"), depth, "", bl);
 }
 
+void
+dump_for_expression (struct ui_file *stream, int depth,
+		     const block_symbol &sym)
+{
+  fprintf_filtered (stream, _("%*sBlock symbol:\n"), depth, "");
+  dump_for_expression (stream, depth + 1, sym.symbol);
+  dump_for_expression (stream, depth + 1, sym.block);
+}
+
 void
 dump_for_expression (struct ui_file *stream, int depth,
 		     type_instance_flags flags)
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 05822d142db..aaa65170a03 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -563,8 +563,7 @@  variable:	name_not_typename
 			      if (symbol_read_needs_frame (sym.symbol))
 				pstate->block_tracker->update (sym);
 
-			      pstate->push_new<var_value_operation>
-				(sym.symbol, sym.block);
+			      pstate->push_new<var_value_operation> (sym);
 			    }
 			  else if ($1.is_a_field_of_this)
 			    {
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index b19bbeb3fb2..f4d4eecda10 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -517,8 +517,8 @@  fblock	:	block COLONCOLON BLOCKNAME
 /* Useful for assigning to PROCEDURE variables */
 variable:	fblock
 			{
-			  pstate->push_new<var_value_operation>
-			    ($1, nullptr);
+			  block_symbol sym { $1, nullptr };
+			  pstate->push_new<var_value_operation> (sym);
 			}
 	;
 
@@ -539,8 +539,7 @@  variable:	block COLONCOLON NAME
 			  if (symbol_read_needs_frame (sym.symbol))
 			    pstate->block_tracker->update (sym);
 
-			  pstate->push_new<var_value_operation>
-			    (sym.symbol, sym.block);
+			  pstate->push_new<var_value_operation> (sym);
 			}
 	;
 
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 02ad6bddc4f..f496ce2016e 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -651,8 +651,7 @@  variable:	block COLONCOLON name
 			    error (_("No symbol \"%s\" in specified context."),
 				   copy.c_str ());
 
-			  pstate->push_new<var_value_operation>
-			    (sym.symbol, sym.block);
+			  pstate->push_new<var_value_operation> (sym);
 			}
 	;
 
@@ -690,8 +689,7 @@  variable:	name_not_typename
 			      if (symbol_read_needs_frame (sym.symbol))
 				pstate->block_tracker->update (sym);
 
-			      pstate->push_new<var_value_operation>
-				(sym.symbol, sym.block);
+			      pstate->push_new<var_value_operation> (sym);
 			      current_type = sym.symbol->type; }
 			  else if ($1.is_a_field_of_this)
 			    {
diff --git a/gdb/parse.c b/gdb/parse.c
index 692d38d363d..b2f23eb67bb 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -224,7 +224,7 @@  parser_state::push_symbol (const char *name, block_symbol sym)
     {
       if (symbol_read_needs_frame (sym.symbol))
 	block_tracker->update (sym);
-      push_new<expr::var_value_operation> (sym.symbol, sym.block);
+      push_new<expr::var_value_operation> (sym);
     }
   else
     {
@@ -301,7 +301,7 @@  parser_state::push_dollar (struct stoken str)
   sym = lookup_symbol (copy.c_str (), NULL, VAR_DOMAIN, NULL);
   if (sym.symbol)
     {
-      push_new<expr::var_value_operation> (sym.symbol, sym.block);
+      push_new<expr::var_value_operation> (sym);
       return;
     }
   msym = lookup_bound_minimal_symbol (copy.c_str ());
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index 3750af0dc34..a0ceb6a42c7 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -2429,7 +2429,7 @@  rust_parser::convert_ast_to_expression (const struct rust_op *operation,
 			     VAR_DOMAIN);
 	operation_up result;
 	if (sym.symbol != NULL && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
-	  result.reset (new var_value_operation (sym.symbol, sym.block));
+	  result.reset (new var_value_operation (sym));
 	else
 	  {
 	    struct type *type = NULL;