aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/checks/errors/rust-ast-validation.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-02-22 18:55:53 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-08-01 13:12:15 +0200
commite01c9f40c13baf47f9404ae3068289688fe3499e (patch)
treec689c47ee7522310c4612c7be85e3087515c0ee3 /gcc/rust/checks/errors/rust-ast-validation.cc
parent68ec9f41ae49f14f510720a4e8dafbd49a279c58 (diff)
downloadgcc-e01c9f40c13baf47f9404ae3068289688fe3499e.zip
gcc-e01c9f40c13baf47f9404ae3068289688fe3499e.tar.gz
gcc-e01c9f40c13baf47f9404ae3068289688fe3499e.tar.bz2
gccrs: Replace unique_ptr references with references
This kind of double indirection is pointless and prone to error. This commit change the api of all getters from the AST to use references directly instead of references to unique pointers. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove reference to unique pointer and replace it with a direct reference to the wrapped data. * ast/rust-ast.cc (VariadicParam::as_string): Likewise. (BlockExpr::normalize_tail_expr): Likewise. * ast/rust-expr.h: Likewise and add pointer getter in order to allow pointer reseat. * ast/rust-item.h: Likewise and add pointer getter for reseat. * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. * ast/rust-stmt.h: Likewise. * ast/rust-type.h: Likewise. * expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_struct_fields): Remove references to unique pointers and replace it with direct references to the wrapped object. (CfgStrip::maybe_strip_tuple_fields): Likewise. (CfgStrip::maybe_strip_generic_args): Likewise. (CfgStrip::maybe_strip_qualified_path_type): Likewise. (CfgStrip::visit): Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::maybe_expand_expr): Likewise. (ExpandVisitor::maybe_expand_type): Likewise. (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_binding): Likewise. (ASTLoweringBase::lower_generic_args): Likewise. (ASTLoweringBase::lower_self): Likewise. (ASTLoweringBase::lower_type_no_bounds): Likewise. (ASTLoweringBase::lower_bound): Likewise. (ASTLoweringBase::lower_range_pattern_bound): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-block.h: Likewise. * hir/rust-ast-lower-enumitem.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise. (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-expr.h: Likewise. * hir/rust-ast-lower-extern.h: Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate): Likewise. (ASTLowerImplItem::visit): Likewise. (ASTLowerTraitItem::translate): Likewise. (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-implitem.h: Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise. (ASTLoweringItem::visit): Likewise. * hir/rust-ast-lower-item.h: Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Likewise. (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower-pattern.h: Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise. * hir/rust-ast-lower-struct-field-expr.h: Likewise. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise. (ASTLowerQualifiedPathInType::visit): Likewise. (ASTLoweringType::translate): Likewise. (ASTLoweringType::visit): Likewise. (ASTLowerGenericParam::translate): Likewise. (ASTLowerGenericParam::visit): Likewise. (ASTLoweringTypeBounds::translate): Likewise. (ASTLoweringTypeBounds::visit): Likewise. (ASTLowerWhereClauseItem::visit): Likewise. * hir/rust-ast-lower-type.h: Likewise. * hir/rust-ast-lower.cc (ASTLowering::go): Likewise. (ASTLoweringBlock::visit): Likewise. (ASTLoweringIfBlock::visit): Likewise. (ASTLoweringIfLetBlock::visit): Likewise. (ASTLowerStructExprField::visit): Likewise. (ASTLoweringExprWithBlock::visit): Likewise. (ASTLoweringBase::lower_qual_path_type): Likewise. (ASTLoweringBase::lower_closure_param): Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::resolve_visibility): Likewise. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::go): Likewise. (ResolveExpr::visit): Likewise. (ResolveExpr::resolve_closure_param): Likewise. * resolve/rust-ast-resolve-expr.h: Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::go): Likewise. (ResolveItem::visit): Likewise. (ResolveItem::resolve_impl_item): Likewise. (ResolveItem::resolve_extern_item): Likewise. (ResolveImplItems::go): Likewise. (ResolveExternItem::go): Likewise. (ResolveExternItem::visit): Likewise. * resolve/rust-ast-resolve-item.h: Likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::go): Likewise. (ResolvePath::resolve_path): Likewise. * resolve/rust-ast-resolve-path.h: Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go): Likewise. (PatternDeclaration::visit): Likewise. (resolve_range_pattern_bound): Likewise. * resolve/rust-ast-resolve-pattern.h: Likewise. * resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-struct-expr-field.cc (ResolveStructExprField::go): Likewise. (ResolveStructExprField::visit): Likewise. * resolve/rust-ast-resolve-struct-expr-field.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise. (ResolveRelativeTypePath::go): Likewise. (ResolveRelativeQualTypePath::resolve_qual_seg): Likewise. (ResolveTypeToCanonicalPath::go): Likewise. (ResolveTypeToCanonicalPath::visit): Likewise. (ResolveGenericArgs::resolve_disambiguated_generic): Likewise. (ResolveGenericArgs::go): Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-ast-resolve.cc (NameResolution::go): Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::resolve_qualified_path_type): Likewise. (EarlyNameResolver::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. * checks/errors/rust-ast-validation.cc: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/checks/errors/rust-ast-validation.cc')
-rw-r--r--gcc/rust/checks/errors/rust-ast-validation.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc
index d589208..e219fba 100644
--- a/gcc/rust/checks/errors/rust-ast-validation.cc
+++ b/gcc/rust/checks/errors/rust-ast-validation.cc
@@ -125,8 +125,8 @@ ASTValidation::visit (AST::Function &function)
// if functional parameter
if (!it->get ()->is_self () && !it->get ()->is_variadic ())
{
- auto param = static_cast<AST::FunctionParam *> (it->get ());
- auto kind = param->get_pattern ()->get_pattern_kind ();
+ auto &param = static_cast<AST::FunctionParam &> (**it);
+ auto kind = param.get_pattern ().get_pattern_kind ();
if (kind != AST::Pattern::Kind::Identifier
&& kind != AST::Pattern::Kind::Wildcard)