From: Owen Avery Date: Mon, 3 Jul 2023 15:54:19 +0000 (-0400) Subject: gccrs: Replace value initialization of Location with UNDEF_LOCATION X-Git-Tag: basepoints/gcc-15~2376 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1678cdd3aac83c3e255e4395c12a9d7dff350a70;p=thirdparty%2Fgcc.git gccrs: Replace value initialization of Location with UNDEF_LOCATION gcc/rust/ChangeLog: * rust-location.h (UNDEF_LOCATION): New. * ast/rust-ast-collector.cc: Replace Location () with UNDEF_LOCATION. * ast/rust-ast-fragment.cc: Likewise. * ast/rust-ast.h: Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-implitem.h: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-item.h: Likewise. * backend/rust-compile.cc: Likewise. * backend/rust-constexpr.cc: Likewise. * expand/rust-expand-visitor.cc: Likewise. * expand/rust-macro-expand.cc: Likewise. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-invoc-lexer.cc: Likewise. * expand/rust-proc-macro-invoc-lexer.cc: Likewise. * expand/rust-proc-macro.cc: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.h: Likewise. * lex/rust-lex.cc: Likewise. * metadata/rust-export-metadata.cc: Likewise. * parse/rust-parse-impl.h: Likewise. * resolve/rust-ast-resolve-item.cc: Likewise. * resolve/rust-ast-resolve.cc: Likewise. * rust-diagnostics.h: Likewise. * rust-session-manager.cc: Likewise. * typecheck/rust-autoderef.cc: Likewise. * typecheck/rust-coercion.cc: Likewise. * typecheck/rust-hir-dot-operator.cc: Likewise. * typecheck/rust-hir-path-probe.cc: Likewise. * typecheck/rust-hir-trait-reference.cc: Likewise. * typecheck/rust-hir-trait-reference.h: Likewise. * typecheck/rust-hir-type-check-expr.cc: Likewise. * typecheck/rust-hir-type-check-implitem.cc: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-hir-type-check.cc: Likewise. * typecheck/rust-tyty-bounds.cc: Likewise. * typecheck/rust-tyty-subst.cc: Likewise. * typecheck/rust-tyty.cc: Likewise. * util/rust-hir-map.cc: Likewise. Signed-off-by: Owen Avery --- diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc index fcd9521917fb..9859861b4a5a 100644 --- a/gcc/rust/ast/rust-ast-collector.cc +++ b/gcc/rust/ast/rust-ast-collector.cc @@ -73,7 +73,7 @@ TokenCollector::visit_items_joined_by_separator (T &collection, auto size = collection.size () - end_offset; for (size_t i = start_offset + 1; i < size; i++) { - push (Rust::Token::make (separator, Location ())); + push (Rust::Token::make (separator, UNDEF_LOCATION)); visit (collection.at (i)); } } @@ -105,10 +105,10 @@ TokenCollector::visit_items_as_block (T &collection, std::vector trailing, TokenId left_brace, TokenId right_brace) { - push (Rust::Token::make (left_brace, Location ())); + push (Rust::Token::make (left_brace, UNDEF_LOCATION)); if (collection.empty ()) { - push (Rust::Token::make (right_brace, Location ())); + push (Rust::Token::make (right_brace, UNDEF_LOCATION)); newline (); } else @@ -118,7 +118,7 @@ TokenCollector::visit_items_as_block (T &collection, visit_items_as_lines (collection, trailing); decrement_indentation (); indentation (); - push (Rust::Token::make (right_brace, Location ())); + push (Rust::Token::make (right_brace, UNDEF_LOCATION)); newline (); } } @@ -128,7 +128,7 @@ TokenCollector::trailing_comma () { if (output_trailing_commas) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); } } @@ -173,7 +173,7 @@ void TokenCollector::visit (FunctionParam ¶m) { visit (param.get_pattern ()); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (param.get_type ()); } @@ -182,8 +182,8 @@ TokenCollector::visit (Attribute &attrib) { push (Rust::Token::make (HASH, attrib.get_locus ())); if (attrib.is_inner_attribute ()) - push (Rust::Token::make (EXCLAM, Location ())); - push (Rust::Token::make (LEFT_SQUARE, Location ())); + push (Rust::Token::make (EXCLAM, UNDEF_LOCATION)); + push (Rust::Token::make (LEFT_SQUARE, UNDEF_LOCATION)); visit (attrib.get_path ()); if (attrib.has_attr_input ()) @@ -211,7 +211,7 @@ TokenCollector::visit (Attribute &attrib) gcc_unreachable (); } } - push (Rust::Token::make (RIGHT_SQUARE, Location ())); + push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION)); } void @@ -261,28 +261,28 @@ TokenCollector::visit (Visibility &vis) break; case Visibility::PUB_CRATE: push (Rust::Token::make (PUB, vis.get_locus ())); - push (Rust::Token::make (LEFT_PAREN, Location ())); - push (Rust::Token::make (CRATE, Location ())); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); + push (Rust::Token::make (CRATE, UNDEF_LOCATION)); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); break; case Visibility::PUB_SELF: push (Rust::Token::make (PUB, vis.get_locus ())); - push (Rust::Token::make (LEFT_PAREN, Location ())); - push (Rust::Token::make (SELF, Location ())); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); + push (Rust::Token::make (SELF, UNDEF_LOCATION)); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); break; case Visibility::PUB_SUPER: push (Rust::Token::make (PUB, vis.get_locus ())); - push (Rust::Token::make (LEFT_PAREN, Location ())); - push (Rust::Token::make (SUPER, Location ())); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); + push (Rust::Token::make (SUPER, UNDEF_LOCATION)); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); break; case Visibility::PUB_IN_PATH: push (Rust::Token::make (PUB, vis.get_locus ())); - push (Rust::Token::make (LEFT_PAREN, Location ())); - push (Rust::Token::make (IN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); + push (Rust::Token::make (IN, UNDEF_LOCATION)); visit (vis.get_path ()); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); break; case Visibility::PRIV: break; @@ -294,16 +294,16 @@ TokenCollector::visit (NamedFunctionParam ¶m) { auto name = param.get_name (); push (Rust::Token::make_identifier (param.get_locus (), std::move (name))); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (param.get_type ()); } void TokenCollector::visit (std::vector> ¶ms) { - push (Rust::Token::make (LEFT_ANGLE, Location ())); + push (Rust::Token::make (LEFT_ANGLE, UNDEF_LOCATION)); visit_items_joined_by_separator (params, COMMA); - push (Rust::Token::make (RIGHT_ANGLE, Location ())); + push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION)); } void @@ -327,17 +327,17 @@ TokenCollector::visit (StructField &field) visit (field.get_visibility ()); auto name = field.get_field_name ().as_string (); push (Rust::Token::make_identifier (field.get_locus (), std::move (name))); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (field.get_field_type ()); } void TokenCollector::visit (std::vector &for_lifetimes) { - push (Rust::Token::make (FOR, Location ())); - push (Rust::Token::make (LEFT_ANGLE, Location ())); + push (Rust::Token::make (FOR, UNDEF_LOCATION)); + push (Rust::Token::make (LEFT_ANGLE, UNDEF_LOCATION)); visit_items_joined_by_separator (for_lifetimes, COMMA); - push (Rust::Token::make (RIGHT_ANGLE, Location ())); + push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION)); } void @@ -366,7 +366,7 @@ TokenCollector::visit (FunctionQualifiers &qualifiers) push (Rust::Token::make (EXTERN_TOK, qualifiers.get_locus ())); if (qualifiers.has_abi ()) { - push (Rust::Token::make_string (Location (), + push (Rust::Token::make_string (UNDEF_LOCATION, qualifiers.get_extern_abi ())); } } @@ -388,12 +388,13 @@ TokenCollector::visit (MaybeNamedParam ¶m) case MaybeNamedParam::UNNAMED: break; case MaybeNamedParam::IDENTIFIER: - push (Rust::Token::make_identifier (Location (), std::move (param_name))); - push (Rust::Token::make (COLON, Location ())); + push ( + Rust::Token::make_identifier (UNDEF_LOCATION, std::move (param_name))); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); break; case MaybeNamedParam::WILDCARD: - push (Rust::Token::make (UNDERSCORE, Location ())); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (UNDERSCORE, UNDEF_LOCATION)); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); break; } visit (param.get_type ()); @@ -515,7 +516,7 @@ TokenCollector::visit (LifetimeParam &lifetime_param) if (lifetime_param.has_lifetime_bounds ()) { - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); for (auto &bound : lifetime_param.get_lifetime_bounds ()) { visit (bound); @@ -531,12 +532,12 @@ TokenCollector::visit (ConstGenericParam ¶m) push (Rust::Token::make (CONST, param.get_locus ())); auto id = param.get_name ().as_string (); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (param.get_type ()); if (param.has_default_value ()) { - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (param.get_type ()); } } @@ -560,19 +561,19 @@ TokenCollector::visit (PathExprSegment &segment) if (!lifetime_args.empty () && (!generic_args.empty () || !binding_args.empty ())) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); } visit_items_joined_by_separator (binding_args, COMMA); if (!generic_args.empty () && !binding_args.empty ()) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); } visit_items_joined_by_separator (lifetime_args, COMMA); - push (Rust::Token::make (RIGHT_ANGLE, Location ())); + push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION)); } } @@ -613,9 +614,9 @@ TokenCollector::visit (TypePathSegmentGeneric &segment) Rust::Token::make_identifier (ident_segment.get_locus (), std::move (id))); if (segment.get_separating_scope_resolution ()) - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); - push (Rust::Token::make (LEFT_ANGLE, Location ())); + push (Rust::Token::make (LEFT_ANGLE, UNDEF_LOCATION)); { auto &lifetime_args = segment.get_generic_args ().get_lifetime_args (); @@ -625,14 +626,14 @@ TokenCollector::visit (TypePathSegmentGeneric &segment) visit_items_joined_by_separator (lifetime_args, COMMA); if (!lifetime_args.empty () && (!generic_args.empty () || !binding_args.empty ())) - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); visit_items_joined_by_separator (generic_args, COMMA); if (!generic_args.empty () && !binding_args.empty ()) - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); visit_items_joined_by_separator (binding_args, COMMA); } - push (Rust::Token::make (RIGHT_ANGLE, Location ())); + push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION)); } void @@ -644,7 +645,7 @@ TokenCollector::visit (GenericArgsBinding &binding) push (Rust::Token::make_identifier (binding.get_locus (), std::move (identifier))); - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (binding.get_type ()); } @@ -663,7 +664,7 @@ TokenCollector::visit (GenericArg &arg) break; case GenericArg::Kind::Either: { auto path = arg.get_path (); - push (Rust::Token::make_identifier (Location (), std::move (path))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (path))); } break; case GenericArg::Kind::Error: @@ -683,7 +684,7 @@ TokenCollector::visit (TypePathSegmentFunction &segment) Rust::Token::make_identifier (ident_segment.get_locus (), std::move (id))); if (segment.get_separating_scope_resolution ()) - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); if (!segment.is_ident_only ()) visit (segment.get_type_path_function ()); @@ -700,11 +701,11 @@ TokenCollector::visit (TypePathFunction &type_path_fn) push (Rust::Token::make (LEFT_PAREN, type_path_fn.get_locus ())); if (type_path_fn.has_inputs ()) visit_items_joined_by_separator (type_path_fn.get_params (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); if (type_path_fn.has_return_type ()) { - push (Rust::Token::make (RETURN_TYPE, Location ())); + push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION)); visit (type_path_fn.get_return_type ()); } } @@ -754,7 +755,7 @@ TokenCollector::visit (QualifiedPathInExpression &path) visit (path.get_qualified_path_type ()); for (auto &segment : path.get_segments ()) { - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); visit (segment); } } @@ -766,10 +767,10 @@ TokenCollector::visit (QualifiedPathType &path) visit (path.get_type ()); if (path.has_as_clause ()) { - push (Rust::Token::make (AS, Location ())); + push (Rust::Token::make (AS, UNDEF_LOCATION)); visit (path.get_as_type_path ()); } - push (Rust::Token::make (RIGHT_ANGLE, Location ())); + push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION)); } void @@ -777,11 +778,11 @@ TokenCollector::visit (QualifiedPathInType &path) { visit (path.get_qualified_path_type ()); - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); visit (path.get_associated_segment ()); for (auto &segment : path.get_segments ()) { - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); visit (segment); } } @@ -840,14 +841,14 @@ TokenCollector::visit (LiteralExpr &expr) void TokenCollector::visit (AttrInputLiteral &literal) { - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (literal.get_literal ()); } void TokenCollector::visit (AttrInputMacro ¯o) { - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (macro.get_macro ()); } @@ -873,9 +874,9 @@ TokenCollector::visit (BorrowExpr &expr) { push (Rust::Token::make (AMP, expr.get_locus ())); if (expr.get_is_double_borrow ()) - push (Rust::Token::make (AMP, Location ())); + push (Rust::Token::make (AMP, UNDEF_LOCATION)); if (expr.get_is_mut ()) - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); visit (expr.get_borrowed_expr ()); } @@ -1082,7 +1083,7 @@ void TokenCollector::visit (ArrayElemsCopied &elems) { visit (elems.get_elem_to_copy ()); - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); visit (elems.get_num_copies ()); } @@ -1091,7 +1092,7 @@ TokenCollector::visit (ArrayExpr &expr) { push (Rust::Token::make (LEFT_SQUARE, expr.get_locus ())); visit (expr.get_array_elems ()); - push (Rust::Token::make (RIGHT_SQUARE, Location ())); + push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION)); } void @@ -1100,7 +1101,7 @@ TokenCollector::visit (ArrayIndexExpr &expr) visit (expr.get_array_expr ()); push (Rust::Token::make (LEFT_SQUARE, expr.get_locus ())); visit (expr.get_index_expr ()); - push (Rust::Token::make (RIGHT_SQUARE, Location ())); + push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION)); } void @@ -1109,7 +1110,7 @@ TokenCollector::visit (TupleExpr &expr) visit_items_as_lines (expr.get_outer_attrs ()); push (Rust::Token::make (LEFT_PAREN, expr.get_locus ())); visit_items_joined_by_separator (expr.get_tuple_elems (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -1117,7 +1118,7 @@ TokenCollector::visit (TupleIndexExpr &expr) { visit (expr.get_tuple_expr ()); push (Rust::Token::make (DOT, expr.get_locus ())); - push (Rust::Token::make_int (Location (), + push (Rust::Token::make_int (UNDEF_LOCATION, std::to_string (expr.get_tuple_index ()))); } @@ -1143,7 +1144,7 @@ TokenCollector::visit (StructExprFieldIdentifierValue &expr) // visit_items_as_lines (expr.get_attrs ()); auto id = expr.get_field_name (); push (Rust::Token::make_identifier (expr.get_locus (), std::move (id))); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (expr.get_value ()); } @@ -1154,14 +1155,14 @@ TokenCollector::visit (StructExprFieldIndexValue &expr) // visit_items_as_lines (expr.get_attrs ()); push (Rust::Token::make_int (expr.get_locus (), std::to_string (expr.get_index ()))); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (expr.get_value ()); } void TokenCollector::visit (StructBase &base) { - push (Rust::Token::make (DOT_DOT, Location ())); + push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION)); visit (base.get_base_struct ()); } @@ -1173,7 +1174,7 @@ TokenCollector::visit (StructExprStructFields &expr) visit_items_joined_by_separator (expr.get_fields (), COMMA); if (expr.has_struct_base ()) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); visit (expr.get_struct_base ()); } else @@ -1195,11 +1196,11 @@ TokenCollector::visit (CallExpr &expr) { visit (expr.get_function_expr ()); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (expr.get_params (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -1208,10 +1209,10 @@ TokenCollector::visit (MethodCallExpr &expr) visit (expr.get_receiver_expr ()); push (Rust::Token::make (DOT, expr.get_locus ())); visit (expr.get_method_name ()); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (expr.get_params (), COMMA); trailing_comma (); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -1220,7 +1221,7 @@ TokenCollector::visit (FieldAccessExpr &expr) visit (expr.get_receiver_expr ()); push (Rust::Token::make (DOT, expr.get_locus ())); auto field_name = expr.get_field_name ().as_string (); - push (Rust::Token::make_identifier (Location (), std::move (field_name))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (field_name))); } void @@ -1242,9 +1243,9 @@ TokenCollector::visit_closure_common (ClosureExpr &expr) { push (Rust::Token::make (MOVE, expr.get_locus ())); } - push (Rust::Token::make (PIPE, Location ())); + push (Rust::Token::make (PIPE, UNDEF_LOCATION)); visit_items_joined_by_separator (expr.get_params (), COMMA); - push (Rust::Token::make (PIPE, Location ())); + push (Rust::Token::make (PIPE, UNDEF_LOCATION)); } void @@ -1400,13 +1401,13 @@ TokenCollector::visit (WhileLetLoopExpr &expr) { visit_loop_common (expr); push (Rust::Token::make (WHILE, expr.get_locus ())); - push (Rust::Token::make (LET, Location ())); + push (Rust::Token::make (LET, UNDEF_LOCATION)); // TODO: The reference mention only one Pattern for (auto &item : expr.get_patterns ()) { visit (item); } - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (expr.get_scrutinee_expr ()); visit (expr.get_loop_block ()); } @@ -1417,7 +1418,7 @@ TokenCollector::visit (ForLoopExpr &expr) visit_loop_common (expr); push (Rust::Token::make (FOR, expr.get_locus ())); visit (expr.get_pattern ()); - push (Rust::Token::make (IN, Location ())); + push (Rust::Token::make (IN, UNDEF_LOCATION)); visit (expr.get_iterator_expr ()); visit (expr.get_loop_block ()); } @@ -1443,12 +1444,12 @@ void TokenCollector::visit (IfLetExpr &expr) { push (Rust::Token::make (IF, expr.get_locus ())); - push (Rust::Token::make (LET, Location ())); + push (Rust::Token::make (LET, UNDEF_LOCATION)); for (auto &pattern : expr.get_patterns ()) { visit (pattern); } - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (expr.get_value_expr ()); visit (expr.get_if_block ()); } @@ -1472,7 +1473,7 @@ TokenCollector::visit (MatchArm &arm) } if (arm.has_match_arm_guard ()) { - push (Rust::Token::make (IF, Location ())); + push (Rust::Token::make (IF, UNDEF_LOCATION)); visit (arm.get_guard_expr ()); } } @@ -1482,10 +1483,10 @@ TokenCollector::visit (MatchCase &match_case) { indentation (); visit (match_case.get_arm ()); - push (Rust::Token::make (MATCH_ARROW, Location ())); + push (Rust::Token::make (MATCH_ARROW, UNDEF_LOCATION)); visit (match_case.get_expr ()); indentation (); - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); newline (); } @@ -1494,7 +1495,7 @@ TokenCollector::visit (MatchExpr &expr) { push (Rust::Token::make (MATCH_TOK, expr.get_locus ())); visit (expr.get_scrutinee_expr ()); - push (Rust::Token::make (LEFT_CURLY, Location ())); + push (Rust::Token::make (LEFT_CURLY, UNDEF_LOCATION)); newline (); increment_indentation (); visit_items_as_lines (expr.get_inner_attrs ()); @@ -1504,7 +1505,7 @@ TokenCollector::visit (MatchExpr &expr) } decrement_indentation (); indentation (); - push (Rust::Token::make (RIGHT_CURLY, Location ())); + push (Rust::Token::make (RIGHT_CURLY, UNDEF_LOCATION)); } void @@ -1513,7 +1514,7 @@ TokenCollector::visit (AwaitExpr &expr) visit (expr.get_awaited_expr ()); push (Rust::Token::make (DOT, expr.get_locus ())); // TODO: Check status of await keyword (Context dependant ?) - push (Rust::Token::make_identifier (Location (), "await")); + push (Rust::Token::make_identifier (UNDEF_LOCATION, "await")); } void @@ -1521,7 +1522,7 @@ TokenCollector::visit (AsyncBlockExpr &expr) { push (Rust::Token::make (ASYNC, expr.get_locus ())); if (expr.get_has_move ()) - push (Rust::Token::make (MOVE, Location ())); + push (Rust::Token::make (MOVE, UNDEF_LOCATION)); visit (expr.get_block_expr ()); } @@ -1539,12 +1540,12 @@ TokenCollector::visit (TypeParam ¶m) push (Rust::Token::make_identifier (param.get_locus (), std::move (id))); if (param.has_type_param_bounds ()) { - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit_items_joined_by_separator (param.get_type_param_bounds (), PLUS); } if (param.has_type ()) { - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (param.get_type ()); } } @@ -1558,7 +1559,7 @@ TokenCollector::visit (WhereClause &rule) // LifetimeWhereClauseItem // | TypeBoundWhereClauseItem - push (Rust::Token::make (WHERE, Location ())); + push (Rust::Token::make (WHERE, UNDEF_LOCATION)); newline (); increment_indentation (); visit_items_joined_by_separator (rule.get_items (), COMMA); @@ -1574,7 +1575,7 @@ TokenCollector::visit (LifetimeWhereClauseItem &item) // ( Lifetime + )* Lifetime? visit (item.get_lifetime ()); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit_items_joined_by_separator (item.get_lifetime_bounds (), PLUS); } @@ -1593,7 +1594,7 @@ TokenCollector::visit (TypeBoundWhereClauseItem &item) visit (item.get_type ()); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit_items_joined_by_separator (item.get_type_param_bounds (), PLUS); } @@ -1606,27 +1607,27 @@ TokenCollector::visit (Method &method) visit (qualifiers); push (Rust::Token::make (FN_TOK, method.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (method_name))); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (method_name))); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit (method.get_self_param ()); if (!method.get_function_params ().empty ()) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); visit_items_joined_by_separator (method.get_function_params (), COMMA); } - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); if (method.has_return_type ()) { - push (Rust::Token::make (RETURN_TYPE, Location ())); + push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION)); visit (method.get_return_type ()); } auto &block = method.get_definition (); if (!block) - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); else visit (block); newline (); @@ -1646,16 +1647,16 @@ TokenCollector::visit (Module &module) visit (module.get_visibility ()); auto name = module.get_name ().as_string (); push (Rust::Token::make (MOD, module.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (name))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (name))); if (module.get_kind () == Module::UNLOADED) { - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); newline (); } else /* Module::LOADED */ { - push (Rust::Token::make (LEFT_CURLY, Location ())); + push (Rust::Token::make (LEFT_CURLY, UNDEF_LOCATION)); newline (); increment_indentation (); @@ -1664,7 +1665,7 @@ TokenCollector::visit (Module &module) decrement_indentation (); - push (Rust::Token::make (RIGHT_CURLY, Location ())); + push (Rust::Token::make (RIGHT_CURLY, UNDEF_LOCATION)); newline (); } } @@ -1674,16 +1675,17 @@ TokenCollector::visit (ExternCrate &crate) { visit_items_as_lines (crate.get_outer_attrs ()); push (Rust::Token::make (EXTERN_TOK, crate.get_locus ())); - push (Rust::Token::make (CRATE, Location ())); + push (Rust::Token::make (CRATE, UNDEF_LOCATION)); auto ref = crate.get_referenced_crate (); - push (Rust::Token::make_identifier (Location (), std::move (ref))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (ref))); if (crate.has_as_clause ()) { auto as_clause = crate.get_as_clause (); - push (Rust::Token::make (AS, Location ())); - push (Rust::Token::make_identifier (Location (), std::move (as_clause))); + push (Rust::Token::make (AS, UNDEF_LOCATION)); + push ( + Rust::Token::make_identifier (UNDEF_LOCATION, std::move (as_clause))); } - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); newline (); } @@ -1695,16 +1697,16 @@ TokenCollector::visit (UseTreeGlob &use_tree) case UseTreeGlob::PathType::PATH_PREFIXED: { auto path = use_tree.get_path (); visit (path); - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); } break; case UseTreeGlob::PathType::NO_PATH: - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); break; case UseTreeGlob::PathType::GLOBAL: break; } - push (Rust::Token::make (ASTERISK, Location ())); + push (Rust::Token::make (ASTERISK, UNDEF_LOCATION)); } void @@ -1715,22 +1717,22 @@ TokenCollector::visit (UseTreeList &use_tree) case UseTreeList::PathType::PATH_PREFIXED: { auto path = use_tree.get_path (); visit (path); - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); } break; case UseTreeList::PathType::NO_PATH: - push (Rust::Token::make (SCOPE_RESOLUTION, Location ())); + push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION)); break; case UseTreeList::PathType::GLOBAL: break; } - push (Rust::Token::make (LEFT_CURLY, Location ())); + push (Rust::Token::make (LEFT_CURLY, UNDEF_LOCATION)); if (use_tree.has_trees ()) { visit_items_joined_by_separator (use_tree.get_trees (), COMMA); } - push (Rust::Token::make (RIGHT_CURLY, Location ())); + push (Rust::Token::make (RIGHT_CURLY, UNDEF_LOCATION)); } void @@ -1741,14 +1743,14 @@ TokenCollector::visit (UseTreeRebind &use_tree) switch (use_tree.get_new_bind_type ()) { case UseTreeRebind::NewBindType::IDENTIFIER: { - push (Rust::Token::make (AS, Location ())); + push (Rust::Token::make (AS, UNDEF_LOCATION)); auto id = use_tree.get_identifier ().as_string (); push ( Rust::Token::make_identifier (use_tree.get_locus (), std::move (id))); } break; case UseTreeRebind::NewBindType::WILDCARD: - push (Rust::Token::make (AS, Location ())); + push (Rust::Token::make (AS, UNDEF_LOCATION)); push (Rust::Token::make (UNDERSCORE, use_tree.get_locus ())); break; case UseTreeRebind::NewBindType::NONE: @@ -1762,7 +1764,7 @@ TokenCollector::visit (UseDeclaration &decl) visit_items_as_lines (decl.get_outer_attrs ()); push (Rust::Token::make (USE, decl.get_locus ())); visit (*decl.get_tree ()); - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); newline (); } @@ -1782,17 +1784,17 @@ TokenCollector::visit (Function &function) push (Rust::Token::make (FN_TOK, function.get_locus ())); auto name = function.get_function_name ().as_string (); - push (Rust::Token::make_identifier (Location (), std::move (name))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (name))); if (function.has_generics ()) visit (function.get_generic_params ()); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (function.get_function_params ()); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); if (function.has_return_type ()) { - push (Rust::Token::make (RETURN_TYPE, Location ())); + push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION)); visit (function.get_return_type ()); } @@ -1801,7 +1803,7 @@ TokenCollector::visit (Function &function) auto &block = function.get_definition (); if (!block) - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); else visit (block); newline (); @@ -1820,7 +1822,7 @@ TokenCollector::visit (TypeAlias &type_alias) visit (type_alias.get_visibility ()); auto alias_name = type_alias.get_new_type_name ().as_string (); push (Rust::Token::make (TYPE, type_alias.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (alias_name))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (alias_name))); if (type_alias.has_generics ()) visit (type_alias.get_generic_params ()); @@ -1828,9 +1830,9 @@ TokenCollector::visit (TypeAlias &type_alias) if (type_alias.has_where_clause ()) visit (type_alias.get_where_clause ()); - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (type_alias.get_type_aliased ()); - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } void @@ -1841,7 +1843,7 @@ TokenCollector::visit (StructStruct &struct_item) visit (struct_item.get_visibility ()); auto struct_name = struct_item.get_identifier ().as_string (); push (Rust::Token::make (STRUCT_TOK, struct_item.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (struct_name))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (struct_name))); if (struct_item.has_generics ()) visit (struct_item.get_generic_params ()); @@ -1849,12 +1851,12 @@ TokenCollector::visit (StructStruct &struct_item) visit (struct_item.get_where_clause ()); if (struct_item.is_unit_struct ()) { - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); newline (); } else visit_items_as_block (struct_item.get_fields (), - {Rust::Token::make (COMMA, Location ())}); + {Rust::Token::make (COMMA, UNDEF_LOCATION)}); } void @@ -1863,16 +1865,16 @@ TokenCollector::visit (TupleStruct &tuple_struct) visit_items_as_lines (tuple_struct.get_outer_attrs ()); auto struct_name = tuple_struct.get_identifier ().as_string (); push (Rust::Token::make (STRUCT_TOK, tuple_struct.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (struct_name))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (struct_name))); if (tuple_struct.has_generics ()) visit (tuple_struct.get_generic_params ()); if (tuple_struct.has_where_clause ()) visit (tuple_struct.get_where_clause ()); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (tuple_struct.get_fields (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); newline (); } @@ -1889,9 +1891,9 @@ TokenCollector::visit (EnumItemTuple &item) { auto id = item.get_identifier ().as_string (); push (Rust::Token::make_identifier (item.get_locus (), std::move (id))); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (item.get_tuple_fields (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -1900,7 +1902,7 @@ TokenCollector::visit (EnumItemStruct &item) auto id = item.get_identifier ().as_string (); push (Rust::Token::make_identifier (item.get_locus (), std::move (id))); visit_items_as_block (item.get_struct_fields (), - {Rust::Token::make (COMMA, Location ())}); + {Rust::Token::make (COMMA, UNDEF_LOCATION)}); } void @@ -1908,7 +1910,7 @@ TokenCollector::visit (EnumItemDiscriminant &item) { auto id = item.get_identifier ().as_string (); push (Rust::Token::make_identifier (item.get_locus (), std::move (id))); - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (item.get_expr ()); } @@ -1928,7 +1930,7 @@ TokenCollector::visit (Enum &enumeration) visit (enumeration.get_where_clause ()); visit_items_as_block (enumeration.get_variants (), - {Rust::Token::make (COMMA, Location ())}); + {Rust::Token::make (COMMA, UNDEF_LOCATION)}); } void @@ -1937,7 +1939,7 @@ TokenCollector::visit (Union &union_item) visit_items_as_lines (union_item.get_outer_attrs ()); auto id = union_item.get_identifier ().as_string (); push (Rust::Token::make_identifier (union_item.get_locus (), "union")); - push (Rust::Token::make_identifier (Location (), std::move (id))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); if (union_item.has_generics ()) visit (union_item.get_generic_params ()); @@ -1946,7 +1948,7 @@ TokenCollector::visit (Union &union_item) visit (union_item.get_where_clause ()); visit_items_as_block (union_item.get_variants (), - {Rust::Token::make (COMMA, Location ())}); + {Rust::Token::make (COMMA, UNDEF_LOCATION)}); } void @@ -1956,21 +1958,21 @@ TokenCollector::visit (ConstantItem &item) push (Rust::Token::make (CONST, item.get_locus ())); if (item.is_unnamed ()) { - push (Rust::Token::make (UNDERSCORE, Location ())); + push (Rust::Token::make (UNDERSCORE, UNDEF_LOCATION)); } else { auto id = item.get_identifier (); - push (Rust::Token::make_identifier (Location (), std::move (id))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); } - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (item.get_type ()); if (item.has_expr ()) { - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (item.get_expr ()); } - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } void @@ -1979,20 +1981,20 @@ TokenCollector::visit (StaticItem &item) visit_items_as_lines (item.get_outer_attrs ()); push (Rust::Token::make (STATIC_TOK, item.get_locus ())); if (item.is_mutable ()) - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); auto id = item.get_identifier ().as_string (); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (item.get_type ()); if (item.has_expr ()) { - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (item.get_expr ()); } - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } void @@ -2002,7 +2004,7 @@ TokenCollector::visit_function_common (std::unique_ptr &return_type, // FIXME: This should format the ` fn ( [args] )` as well if (return_type) { - push (Rust::Token::make (RETURN_TYPE, Location ())); + push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION)); visit (return_type); } @@ -2012,7 +2014,7 @@ TokenCollector::visit_function_common (std::unique_ptr &return_type, } else { - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); newline (); } } @@ -2024,12 +2026,12 @@ TokenCollector::visit (TraitItemFunc &item) auto id = func.get_identifier ().as_string (); push (Rust::Token::make (FN_TOK, item.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (func.get_function_params ()); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); visit_function_common (func.get_return_type (), item.get_definition ()); } @@ -2039,19 +2041,19 @@ TokenCollector::visit (SelfParam ¶m) { if (param.get_has_ref ()) { - push (Rust::Token::make (AMP, Location ())); + push (Rust::Token::make (AMP, UNDEF_LOCATION)); if (param.has_lifetime ()) { auto lifetime = param.get_lifetime (); visit (lifetime); } if (param.get_is_mut ()) - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); } - push (Rust::Token::make (SELF, Location ())); + push (Rust::Token::make (SELF, UNDEF_LOCATION)); if (param.has_type ()) { - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (param.get_type ()); } } @@ -2063,18 +2065,18 @@ TokenCollector::visit (TraitItemMethod &item) auto id = method.get_identifier ().as_string (); push (Rust::Token::make (FN_TOK, item.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit (method.get_self_param ()); if (!method.get_function_params ().empty ()) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); visit_items_joined_by_separator (method.get_function_params (), COMMA); } - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); visit_function_common (method.get_return_type (), item.get_definition ()); } @@ -2085,10 +2087,10 @@ TokenCollector::visit (TraitItemConst &item) auto id = item.get_identifier ().as_string (); indentation (); push (Rust::Token::make (CONST, item.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (item.get_type ()); - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); newline (); } @@ -2100,8 +2102,8 @@ TokenCollector::visit (TraitItemType &item) indentation (); push (Rust::Token::make (TYPE, item.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); newline (); } @@ -2119,7 +2121,7 @@ TokenCollector::visit (Trait &trait) auto id = trait.get_identifier ().as_string (); push (Rust::Token::make (TRAIT, trait.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); visit (trait.get_generic_params ()); @@ -2150,9 +2152,9 @@ TokenCollector::visit (TraitImpl &impl) push (Rust::Token::make (IMPL, impl.get_locus ())); visit (impl.get_generic_params ()); if (impl.is_exclam ()) - push (Rust::Token::make (EXCLAM, Location ())); + push (Rust::Token::make (EXCLAM, UNDEF_LOCATION)); visit (impl.get_trait_path ()); - push (Rust::Token::make (FOR, Location ())); + push (Rust::Token::make (FOR, UNDEF_LOCATION)); visit (impl.get_type ()); if (impl.has_where_clause ()) @@ -2168,9 +2170,9 @@ TokenCollector::visit (ExternalTypeItem &type) auto id = type.get_identifier ().as_string (); - push (Rust::Token::make (TYPE, Location ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (TYPE, UNDEF_LOCATION)); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } void @@ -2182,13 +2184,13 @@ TokenCollector::visit (ExternalStaticItem &item) visit (item.get_visibility ()); push (Rust::Token::make (STATIC_TOK, item.get_locus ())); if (item.is_mut ()) - push (Rust::Token::make (MUT, Location ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (item.get_type ()); // TODO: No expr ? The "(= Expression)?" part from the reference seems missing // in the ast. - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } void @@ -2200,27 +2202,27 @@ TokenCollector::visit (ExternalFunctionItem &function) auto id = function.get_identifier ().as_string (); push (Rust::Token::make (FN_TOK, function.get_locus ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); if (function.has_generics ()) visit (function.get_generic_params ()); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (function.get_function_params ()); if (function.is_variadic ()) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); // TODO: Add variadic outer attributes? // TODO: Add variadic name once implemented. - push (Rust::Token::make (ELLIPSIS, Location ())); + push (Rust::Token::make (ELLIPSIS, UNDEF_LOCATION)); } - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); if (function.has_return_type ()) { - push (Rust::Token::make (RETURN_TYPE, Location ())); + push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION)); visit (function.get_return_type ()); } - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } void @@ -2232,7 +2234,7 @@ TokenCollector::visit (ExternBlock &block) if (block.has_abi ()) { auto abi = block.get_abi (); - push (Rust::Token::make_string (Location (), std::move (abi))); + push (Rust::Token::make_string (UNDEF_LOCATION, std::move (abi))); } visit_items_as_block (block.get_extern_items (), {}); @@ -2259,24 +2261,24 @@ TokenCollector::visit (MacroMatchFragment &match) { auto id = match.get_ident ().as_string (); auto frag_spec = match.get_frag_spec ().as_string (); - push (Rust::Token::make (DOLLAR_SIGN, Location ())); - push (Rust::Token::make_identifier (Location (), std::move (id))); - push (Rust::Token::make (COLON, Location ())); - push (Rust::Token::make_identifier (Location (), std::move (frag_spec))); + push (Rust::Token::make (DOLLAR_SIGN, UNDEF_LOCATION)); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (frag_spec))); } void TokenCollector::visit (MacroMatchRepetition &repetition) { - push (Rust::Token::make (DOLLAR_SIGN, Location ())); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (DOLLAR_SIGN, UNDEF_LOCATION)); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); for (auto &match : repetition.get_matches ()) { visit (match); } - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); if (repetition.has_sep ()) { @@ -2286,13 +2288,13 @@ TokenCollector::visit (MacroMatchRepetition &repetition) switch (repetition.get_op ()) { case MacroMatchRepetition::ANY: - push (Rust::Token::make (ASTERISK, Location ())); + push (Rust::Token::make (ASTERISK, UNDEF_LOCATION)); break; case MacroMatchRepetition::ONE_OR_MORE: - push (Rust::Token::make (PLUS, Location ())); + push (Rust::Token::make (PLUS, UNDEF_LOCATION)); break; case MacroMatchRepetition::ZERO_OR_ONE: - push (Rust::Token::make (QUESTION_MARK, Location ())); + push (Rust::Token::make (QUESTION_MARK, UNDEF_LOCATION)); break; case MacroMatchRepetition::NONE: break; @@ -2304,14 +2306,14 @@ TokenCollector::visit (MacroMatcher &matcher) { auto delimiters = get_delimiters (matcher.get_delim_type ()); - push (Rust::Token::make (delimiters.first, Location ())); + push (Rust::Token::make (delimiters.first, UNDEF_LOCATION)); for (auto &item : matcher.get_matches ()) { visit (item); } - push (Rust::Token::make (delimiters.second, Location ())); + push (Rust::Token::make (delimiters.second, UNDEF_LOCATION)); } void @@ -2331,12 +2333,12 @@ TokenCollector::visit (MacroRulesDefinition &rules_def) auto rule_name = rules_def.get_rule_name ().as_string (); push (Rust::Token::make_identifier (rules_def.get_locus (), "macro_rules")); - push (Rust::Token::make (EXCLAM, Location ())); + push (Rust::Token::make (EXCLAM, UNDEF_LOCATION)); - push (Rust::Token::make_identifier (Location (), std::move (rule_name))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (rule_name))); visit_items_as_block (rules_def.get_rules (), - {Rust::Token::make (SEMICOLON, Location ())}); + {Rust::Token::make (SEMICOLON, UNDEF_LOCATION)}); } void @@ -2344,11 +2346,11 @@ TokenCollector::visit (MacroInvocation &invocation) { auto data = invocation.get_invoc_data (); visit (data.get_path ()); - push (Rust::Token::make (EXCLAM, Location ())); + push (Rust::Token::make (EXCLAM, UNDEF_LOCATION)); visit (data.get_delim_tok_tree ()); if (invocation.has_semicolon ()) { - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } } @@ -2364,9 +2366,9 @@ TokenCollector::visit (MetaItemSeq &item) { visit (item.get_path ()); // TODO: Double check this, there is probably a mistake. - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (item.get_seq (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -2386,9 +2388,9 @@ TokenCollector::visit (MetaNameValueStr &name) push (Rust::Token::make_identifier (name.get_locus (), std::move (id))); push (Rust::Token::make (EQUAL, name.get_locus ())); - push (Rust::Token::make (DOUBLE_QUOTE, Location ())); + push (Rust::Token::make (DOUBLE_QUOTE, UNDEF_LOCATION)); push (Rust::Token::make_identifier (name.get_locus (), std::move (value))); - push (Rust::Token::make (DOUBLE_QUOTE, Location ())); + push (Rust::Token::make (DOUBLE_QUOTE, UNDEF_LOCATION)); } void @@ -2397,11 +2399,11 @@ TokenCollector::visit (MetaListPaths &list) auto id = list.get_ident ().as_string (); push (Rust::Token::make_identifier (list.get_locus (), std::move (id))); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (list.get_paths (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -2410,11 +2412,11 @@ TokenCollector::visit (MetaListNameValueStr &list) auto id = list.get_ident ().as_string (); push (Rust::Token::make_identifier (list.get_locus (), std::move (id))); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (list.get_values (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } // rust-pattern.h @@ -2433,15 +2435,15 @@ TokenCollector::visit (IdentifierPattern &pattern) } if (pattern.get_is_mut ()) { - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); } auto id = pattern.get_ident ().as_string (); - push (Rust::Token::make_identifier (Location (), std::move (id))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); if (pattern.has_pattern_to_bind ()) { - push (Rust::Token::make (PATTERN_BIND, Location ())); + push (Rust::Token::make (PATTERN_BIND, UNDEF_LOCATION)); visit (pattern.get_pattern_to_bind ()); } } @@ -2521,7 +2523,7 @@ TokenCollector::visit (ReferencePattern &pattern) if (pattern.get_is_mut ()) { - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); } visit (pattern.get_referenced_pattern ()); @@ -2545,7 +2547,7 @@ TokenCollector::visit (StructPatternFieldIdentPat &pattern) visit_items_as_lines (pattern.get_outer_attrs ()); auto id = pattern.get_identifier ().as_string (); - push (Rust::Token::make_identifier (Location (), std::move (id))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); push (Rust::Token::make (COLON, pattern.get_locus ())); @@ -2557,12 +2559,12 @@ TokenCollector::visit (StructPatternFieldIdent &pattern) { visit_items_as_lines (pattern.get_outer_attrs ()); if (pattern.is_ref ()) - push (Rust::Token::make (REF, Location ())); + push (Rust::Token::make (REF, UNDEF_LOCATION)); if (pattern.is_mut ()) - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); auto id = pattern.get_identifier ().as_string (); - push (Rust::Token::make_identifier (Location (), std::move (id))); + push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); } void @@ -2576,7 +2578,7 @@ TokenCollector::visit (StructPattern &pattern) visit_items_joined_by_separator (elems.get_struct_pattern_fields ()); if (elems.has_etc ()) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); visit_items_as_lines (elems.get_etc_outer_attrs ()); } } @@ -2585,7 +2587,7 @@ TokenCollector::visit (StructPattern &pattern) visit_items_as_lines (elems.get_etc_outer_attrs ()); } - push (Rust::Token::make (RIGHT_CURLY, Location ())); + push (Rust::Token::make (RIGHT_CURLY, UNDEF_LOCATION)); } // void TokenCollector::visit(TupleStructItems& ){} @@ -2606,7 +2608,7 @@ TokenCollector::visit (TupleStructItemsRange &pattern) { visit (lower); } - push (Rust::Token::make (DOT_DOT, Location ())); + push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION)); for (auto &upper : pattern.get_lower_patterns ()) { visit (upper); @@ -2620,7 +2622,7 @@ TokenCollector::visit (TupleStructPattern &pattern) push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ())); if (pattern.has_items ()) visit (pattern.get_items ()); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } // void @@ -2640,7 +2642,7 @@ TokenCollector::visit (TuplePatternItemsRanged &pattern) { visit (lower); } - push (Rust::Token::make (DOT_DOT, Location ())); + push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION)); for (auto &upper : pattern.get_lower_patterns ()) { visit (upper); @@ -2652,7 +2654,7 @@ TokenCollector::visit (TuplePattern &pattern) { push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ())); visit (pattern.get_items ()); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -2660,7 +2662,7 @@ TokenCollector::visit (GroupedPattern &pattern) { push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ())); visit (pattern.get_pattern_in_parens ()); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -2668,7 +2670,7 @@ TokenCollector::visit (SlicePattern &pattern) { push (Rust::Token::make (LEFT_SQUARE, pattern.get_locus ())); visit_items_joined_by_separator (pattern.get_items (), COMMA); - push (Rust::Token::make (RIGHT_SQUARE, Location ())); + push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION)); } void @@ -2692,16 +2694,16 @@ TokenCollector::visit (LetStmt &stmt) if (stmt.has_type ()) { - push (Rust::Token::make (COLON, Location ())); + push (Rust::Token::make (COLON, UNDEF_LOCATION)); visit (stmt.get_type ()); } if (stmt.has_init_expr ()) { - push (Rust::Token::make (EQUAL, Location ())); + push (Rust::Token::make (EQUAL, UNDEF_LOCATION)); visit (stmt.get_init_expr ()); } - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } void @@ -2709,7 +2711,7 @@ TokenCollector::visit (ExprStmt &stmt) { visit (stmt.get_expr ()); if (stmt.is_semicolon_followed ()) - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); } // rust-type.h @@ -2762,7 +2764,7 @@ TokenCollector::visit (ParenthesisedType &type) push (Rust::Token::make (LEFT_PAREN, type.get_locus ())); visit (type.get_type_in_parens ()); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -2795,7 +2797,7 @@ TokenCollector::visit (TupleType &type) push (Rust::Token::make (LEFT_PAREN, type.get_locus ())); visit_items_joined_by_separator (type.get_elems (), COMMA); - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); } void @@ -2815,9 +2817,9 @@ TokenCollector::visit (RawPointerType &type) push (Rust::Token::make (ASTERISK, type.get_locus ())); if (type.get_pointer_type () == RawPointerType::MUT) - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); else /* RawPointerType::CONST */ - push (Rust::Token::make (CONST, Location ())); + push (Rust::Token::make (CONST, UNDEF_LOCATION)); visit (type.get_type_pointed_to ()); } @@ -2836,7 +2838,7 @@ TokenCollector::visit (ReferenceType &type) } if (type.get_has_mut ()) - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (MUT, UNDEF_LOCATION)); visit (type.get_type_referenced ()); } @@ -2849,9 +2851,9 @@ TokenCollector::visit (ArrayType &type) push (Rust::Token::make (LEFT_SQUARE, type.get_locus ())); visit (type.get_elem_type ()); - push (Rust::Token::make (SEMICOLON, Location ())); + push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION)); visit (type.get_size_expr ()); - push (Rust::Token::make (RIGHT_SQUARE, Location ())); + push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION)); } void @@ -2862,7 +2864,7 @@ TokenCollector::visit (SliceType &type) push (Rust::Token::make (LEFT_SQUARE, type.get_locus ())); visit (type.get_elem_type ()); - push (Rust::Token::make (RIGHT_SQUARE, Location ())); + push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION)); } void @@ -2899,25 +2901,25 @@ TokenCollector::visit (BareFunctionType &type) visit (type.get_function_qualifiers ()); push (Rust::Token::make (FN_TOK, type.get_locus ())); - push (Rust::Token::make (LEFT_PAREN, Location ())); + push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION)); visit_items_joined_by_separator (type.get_function_params (), COMMA); if (type.is_variadic ()) { - push (Rust::Token::make (COMMA, Location ())); + push (Rust::Token::make (COMMA, UNDEF_LOCATION)); for (auto &item : type.get_variadic_attr ()) { visit (item); } - push (Rust::Token::make (ELLIPSIS, Location ())); + push (Rust::Token::make (ELLIPSIS, UNDEF_LOCATION)); } - push (Rust::Token::make (RIGHT_PAREN, Location ())); + push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION)); if (type.has_return_type ()) { - push (Rust::Token::make (RETURN_TYPE, Location ())); + push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION)); visit (type.get_return_type ()); } } diff --git a/gcc/rust/ast/rust-ast-fragment.cc b/gcc/rust/ast/rust-ast-fragment.cc index 22d2e6307488..0814ef49426d 100644 --- a/gcc/rust/ast/rust-ast-fragment.cc +++ b/gcc/rust/ast/rust-ast-fragment.cc @@ -162,14 +162,14 @@ Fragment::assert_single_fragment (SingleASTNode::NodeType expected) const if (!is_single_fragment ()) { - rust_error_at (Location (), "fragment is not single"); + rust_error_at (UNDEF_LOCATION, "fragment is not single"); fail = true; } if (actual != expected) { rust_error_at ( - Location (), + UNDEF_LOCATION, "invalid fragment operation: expected %qs node, got %qs node", str_map.find (expected)->second, str_map.find (nodes[0].get_kind ())->second); diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index e8398d5c890b..1f6d0c08e9c9 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -38,10 +38,10 @@ public: // Create dummy identifier Identifier () : ident (""), node_id (Analysis::Mappings::get ()->get_next_node_id ()), - loc (Location ()) + loc (UNDEF_LOCATION) {} // Create identifier with dummy location - Identifier (std::string ident, Location loc = Location ()) + Identifier (std::string ident, Location loc = UNDEF_LOCATION) : ident (ident), node_id (Analysis::Mappings::get ()->get_next_node_id ()), loc (loc) {} @@ -387,7 +387,7 @@ public: // Creates an error SimplePathSegment static SimplePathSegment create_error () { - return SimplePathSegment (std::string (""), Location ()); + return SimplePathSegment (std::string (""), UNDEF_LOCATION); } std::string as_string () const override; @@ -419,7 +419,7 @@ public: // Constructor SimplePath (std::vector path_segments, bool has_opening_scope_resolution = false, - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : opening_scope_resolution (has_opening_scope_resolution), segments (std::move (path_segments)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) @@ -509,7 +509,7 @@ public: // Constructor has pointer AttrInput for polymorphism reasons Attribute (SimplePath path, std::unique_ptr input, - Location locus = Location (), bool inner_attribute = false) + Location locus = UNDEF_LOCATION, bool inner_attribute = false) : path (std::move (path)), attr_input (std::move (input)), locus (locus), inner_attribute (inner_attribute) {} @@ -819,7 +819,7 @@ public: DelimTokenTree (DelimType delim_type, std::vector> token_trees = std::vector> (), - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : delim_type (delim_type), token_trees (std::move (token_trees)), locus (locus) {} @@ -1282,13 +1282,13 @@ private: public: // Constructor Lifetime (LifetimeType type, std::string name = std::string (), - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : TypeParamBound (Analysis::Mappings::get ()->get_next_node_id ()), lifetime_type (type), lifetime_name (std::move (name)), locus (locus) {} Lifetime (NodeId id, LifetimeType type, std::string name = std::string (), - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : TypeParamBound (id), lifetime_type (type), lifetime_name (std::move (name)), locus (locus) {} @@ -1382,7 +1382,7 @@ public: static LifetimeParam create_error () { return LifetimeParam (Lifetime::error (), {}, Attribute::create_empty (), - Location ()); + UNDEF_LOCATION); } // Returns whether the lifetime param is in an error state. diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 9a1da7afb8bd..dd589e77db5c 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -1609,7 +1609,7 @@ public: StructBase &operator= (StructBase &&other) = default; // Returns a null expr-ed StructBase - error state - static StructBase error () { return StructBase (nullptr, Location ()); } + static StructBase error () { return StructBase (nullptr, UNDEF_LOCATION); } // Returns whether StructBase is in error state bool is_invalid () const { return base_struct == nullptr; } @@ -2248,7 +2248,7 @@ public: // Creates an error state closure parameter. static ClosureParam create_error () { - return ClosureParam (nullptr, Location ()); + return ClosureParam (nullptr, UNDEF_LOCATION); } std::string as_string () const; @@ -3353,7 +3353,7 @@ class LoopLabel /*: public Node*/ public: std::string as_string () const; - LoopLabel (Lifetime loop_label, Location locus = Location ()) + LoopLabel (Lifetime loop_label, Location locus = UNDEF_LOCATION) : label (std::move (loop_label)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -4128,7 +4128,7 @@ public: // Creates a match arm in an error state. static MatchArm create_error () { - Location locus = Location (); + Location locus = UNDEF_LOCATION; return MatchArm (std::vector > (), locus); } diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 5b3529bf4e96..8ddfb1d8daf7 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -77,7 +77,7 @@ public: // Returns whether the type param has an outer attribute. bool has_outer_attribute () const { return !outer_attr.is_empty (); } - TypeParam (Identifier type_representation, Location locus = Location (), + TypeParam (Identifier type_representation, Location locus = UNDEF_LOCATION, std::vector> type_param_bounds = std::vector> (), std::unique_ptr type = nullptr, @@ -575,7 +575,7 @@ public: // Creates an error FunctionParam. static FunctionParam create_error () { - return FunctionParam (nullptr, nullptr, {}, Location ()); + return FunctionParam (nullptr, nullptr, {}, UNDEF_LOCATION); } std::string as_string () const; @@ -653,7 +653,8 @@ public: // Creates an error visibility. static Visibility create_error () { - return Visibility (PUB_IN_PATH, SimplePath::create_empty (), Location ()); + return Visibility (PUB_IN_PATH, SimplePath::create_empty (), + UNDEF_LOCATION); } // Unique pointer custom clone function @@ -701,7 +702,7 @@ public: // Creates a private visibility static Visibility create_private () { - return Visibility (PRIV, SimplePath::create_empty (), Location ()); + return Visibility (PRIV, SimplePath::create_empty (), UNDEF_LOCATION); } // Creates a public visibility with a given path or whatever. @@ -752,7 +753,7 @@ public: // Creates an error state method. static Method create_error () { - return Method ({""}, FunctionQualifiers (Location (), NONE, true), + return Method ({""}, FunctionQualifiers (UNDEF_LOCATION, NONE, true), std::vector> (), SelfParam::create_error (), std::vector (), nullptr, WhereClause::create_empty (), nullptr, @@ -2001,7 +2002,7 @@ public: static StructField create_error () { return StructField (std::string (""), nullptr, Visibility::create_error (), - Location ()); + UNDEF_LOCATION); } std::string as_string () const; @@ -2148,7 +2149,7 @@ public: // Creates an error state tuple field. static TupleField create_error () { - return TupleField (nullptr, Visibility::create_error (), Location ()); + return TupleField (nullptr, Visibility::create_error (), UNDEF_LOCATION); } std::string as_string () const; @@ -4152,7 +4153,7 @@ public: // Creates an error state named function parameter. static NamedFunctionParam create_error () { - return NamedFunctionParam ("", nullptr, {}, Location ()); + return NamedFunctionParam ("", nullptr, {}, UNDEF_LOCATION); } NamedFunctionParam (std::string name, std::unique_ptr param_type, diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 877df2a4e004..decc7bee21d8 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -432,7 +432,7 @@ public: { return MacroRule (MacroMatcher::create_error (locus), MacroTranscriber (DelimTokenTree::create_empty (), - Location ()), + UNDEF_LOCATION), locus); } @@ -507,7 +507,7 @@ private: : VisItem (std::move (vis), std::vector ()), outer_attrs (std::vector ()), rule_name (builtin_name), delim_type (delim_type), rules (std::vector ()), - locus (Location ()), associated_transcriber (associated_transcriber), + locus (UNDEF_LOCATION), associated_transcriber (associated_transcriber), is_builtin_rule (true), kind (kind) {} diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index cad9d5d2c383..cdd90e84b724 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -42,7 +42,7 @@ public: // Creates an error PathIdentSegment. static PathIdentSegment create_error () { - return PathIdentSegment ("", Location ()); + return PathIdentSegment ("", UNDEF_LOCATION); } // Returns whether PathIdentSegment is in an error state. @@ -82,7 +82,7 @@ public: // Pointer type for type in constructor to enable polymorphism GenericArgsBinding (Identifier ident, std::unique_ptr type_ptr, - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : identifier (std::move (ident)), type (std::move (type_ptr)), locus (locus) {} @@ -159,7 +159,7 @@ public: static GenericArg create_error () { - return GenericArg (nullptr, nullptr, {""}, Kind::Error, Location ()); + return GenericArg (nullptr, nullptr, {""}, Kind::Error, UNDEF_LOCATION); } static GenericArg create_const (std::unique_ptr expression) @@ -407,7 +407,7 @@ public: GenericArgs (std::vector lifetime_args, std::vector generic_args, std::vector binding_args, - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : lifetime_args (std::move (lifetime_args)), generic_args (std::move (generic_args)), binding_args (std::move (binding_args)), locus (locus) @@ -506,7 +506,7 @@ public: // Creates an error-state path expression segment. static PathExprSegment create_error () { - return PathExprSegment (PathIdentSegment::create_error (), Location ()); + return PathExprSegment (PathIdentSegment::create_error (), UNDEF_LOCATION); } std::string as_string () const; @@ -602,7 +602,7 @@ public: // Creates an error state path in expression. static PathInExpression create_error () { - return PathInExpression ({}, {}, Location ()); + return PathInExpression ({}, {}, UNDEF_LOCATION); } // Returns whether path in expression is in an error state. @@ -889,7 +889,7 @@ public: // Creates an error state function. static TypePathFunction create_error () { - return TypePathFunction (true, Location ()); + return TypePathFunction (true, UNDEF_LOCATION); } // Constructor @@ -1031,7 +1031,7 @@ public: static TypePath create_error () { return TypePath (std::vector > (), - Location ()); + UNDEF_LOCATION); } // Constructor @@ -1108,7 +1108,7 @@ private: public: // Constructor QualifiedPathType (std::unique_ptr invoke_on_type, - Location locus = Location (), + Location locus = UNDEF_LOCATION, TypePath trait_path = TypePath::create_error ()) : type_to_invoke_on (std::move (invoke_on_type)), trait_path (std::move (trait_path)), locus (locus), @@ -1212,7 +1212,7 @@ public: static QualifiedPathInExpression create_error () { return QualifiedPathInExpression (QualifiedPathType::create_error (), {}, - {}, Location ()); + {}, UNDEF_LOCATION); } Location get_locus () const override final { return locus; } @@ -1336,7 +1336,7 @@ public: { return QualifiedPathInType ( QualifiedPathType::create_error (), nullptr, - std::vector > (), Location ()); + std::vector > (), UNDEF_LOCATION); } std::string as_string () const override; diff --git a/gcc/rust/ast/rust-type.h b/gcc/rust/ast/rust-type.h index 7b679d5cc154..d2a5f27253c8 100644 --- a/gcc/rust/ast/rust-type.h +++ b/gcc/rust/ast/rust-type.h @@ -813,7 +813,7 @@ public: // Creates an error state param. static MaybeNamedParam create_error () { - return MaybeNamedParam ({""}, UNNAMED, nullptr, {}, Location ()); + return MaybeNamedParam ({""}, UNNAMED, nullptr, {}, UNDEF_LOCATION); } Location get_locus () const { return locus; } diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 100b766f8413..b6f92bb1e155 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -1092,7 +1092,7 @@ sort_tuple_patterns (HIR::MatchExpr &expr) // compile. auto foo = std::vector> (); foo.emplace_back (std::move (result_pattern)); - HIR::MatchArm new_arm (std::move (foo), Location (), nullptr, + HIR::MatchArm new_arm (std::move (foo), UNDEF_LOCATION, nullptr, AST::AttrVec ()); HIR::MatchCase new_case (match_case.get_mappings (), new_arm, diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h index 1f18d1a23ca3..29a886864ed5 100644 --- a/gcc/rust/backend/rust-compile-extern.h +++ b/gcc/rust/backend/rust-compile-extern.h @@ -33,7 +33,7 @@ public: static tree compile (HIR::ExternalItem *item, Context *ctx, TyTy::BaseType *concrete = nullptr, bool is_query_mode = false, - Location ref_locus = Location ()) + Location ref_locus = UNDEF_LOCATION) { CompileExternItem compiler (ctx, concrete, ref_locus); item->accept_vis (compiler); diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index 132175b99c56..b29b7a5a3d45 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -31,7 +31,7 @@ public: static tree Compile (HIR::ImplItem *item, Context *ctx, TyTy::BaseType *concrete = nullptr, bool is_query_mode = false, - Location ref_locus = Location ()) + Location ref_locus = UNDEF_LOCATION) { CompileInherentImplItem compiler (ctx, concrete, ref_locus); item->accept_vis (compiler); @@ -55,7 +55,7 @@ class CompileTraitItem : public HIRCompileBase, public HIR::HIRTraitItemVisitor public: static tree Compile (HIR::TraitItem *item, Context *ctx, TyTy::BaseType *concrete, bool is_query_mode = false, - Location ref_locus = Location ()) + Location ref_locus = UNDEF_LOCATION) { CompileTraitItem compiler (ctx, concrete, ref_locus); item->accept_vis (compiler); diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index 697f40f2196c..5cb64370fa68 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -322,8 +322,8 @@ static void enter_intrinsic_block (Context *ctx, tree fndecl) { tree enclosing_scope = NULL_TREE; - Location start_location = Location (); - Location end_location = Location (); + Location start_location = UNDEF_LOCATION; + Location end_location = UNDEF_LOCATION; auto block = ctx->get_backend ()->block (fndecl, enclosing_scope, {}, start_location, end_location); @@ -366,13 +366,13 @@ offset_handler (Context *ctx, TyTy::FnType *fntype) enter_intrinsic_block (ctx, fndecl); // BUILTIN offset FN BODY BEGIN - tree dst = ctx->get_backend ()->var_expression (dst_param, Location ()); - tree size = ctx->get_backend ()->var_expression (size_param, Location ()); + tree dst = ctx->get_backend ()->var_expression (dst_param, UNDEF_LOCATION); + tree size = ctx->get_backend ()->var_expression (size_param, UNDEF_LOCATION); tree pointer_offset_expr = pointer_offset_expression (dst, size, BUILTINS_LOCATION); auto return_statement = ctx->get_backend ()->return_statement (fndecl, {pointer_offset_expr}, - Location ()); + UNDEF_LOCATION); ctx->add_statement (return_statement); // BUILTIN offset FN BODY END @@ -406,7 +406,8 @@ sizeof_handler (Context *ctx, TyTy::FnType *fntype) // BUILTIN size_of FN BODY BEGIN tree size_expr = TYPE_SIZE_UNIT (template_parameter_type); auto return_statement - = ctx->get_backend ()->return_statement (fndecl, {size_expr}, Location ()); + = ctx->get_backend ()->return_statement (fndecl, {size_expr}, + UNDEF_LOCATION); ctx->add_statement (return_statement); // BUILTIN size_of FN BODY END @@ -437,7 +438,7 @@ transmute_handler (Context *ctx, TyTy::FnType *fntype) // param to convert Bvariable *convert_me_param = param_vars.at (0); tree convert_me_expr - = ctx->get_backend ()->var_expression (convert_me_param, Location ()); + = ctx->get_backend ()->var_expression (convert_me_param, UNDEF_LOCATION); // check for transmute pre-conditions tree target_type_expr = TREE_TYPE (DECL_RESULT (fndecl)); @@ -480,7 +481,7 @@ transmute_handler (Context *ctx, TyTy::FnType *fntype) auto return_statement = ctx->get_backend ()->return_statement (fndecl, {result_expr}, - Location ()); + UNDEF_LOCATION); ctx->add_statement (return_statement); // BUILTIN transmute FN BODY END @@ -514,13 +515,13 @@ rotate_handler (Context *ctx, TyTy::FnType *fntype, tree_code op) enter_intrinsic_block (ctx, fndecl); // BUILTIN rotate FN BODY BEGIN - tree x = ctx->get_backend ()->var_expression (x_param, Location ()); - tree y = ctx->get_backend ()->var_expression (y_param, Location ()); + tree x = ctx->get_backend ()->var_expression (x_param, UNDEF_LOCATION); + tree y = ctx->get_backend ()->var_expression (y_param, UNDEF_LOCATION); tree rotate_expr = fold_build2_loc (BUILTINS_LOCATION, op, TREE_TYPE (x), x, y); auto return_statement = ctx->get_backend ()->return_statement (fndecl, {rotate_expr}, - Location ()); + UNDEF_LOCATION); ctx->add_statement (return_statement); // BUILTIN rotate FN BODY END @@ -557,8 +558,8 @@ wrapping_op_handler_inner (Context *ctx, TyTy::FnType *fntype, tree_code op) enter_intrinsic_block (ctx, fndecl); // BUILTIN wrapping_ FN BODY BEGIN - auto lhs = ctx->get_backend ()->var_expression (lhs_param, Location ()); - auto rhs = ctx->get_backend ()->var_expression (rhs_param, Location ()); + auto lhs = ctx->get_backend ()->var_expression (lhs_param, UNDEF_LOCATION); + auto rhs = ctx->get_backend ()->var_expression (rhs_param, UNDEF_LOCATION); // Operations are always wrapping in Rust, as we have -fwrapv enabled by // default. The difference between a wrapping_{add, sub, mul} and a regular @@ -567,7 +568,8 @@ wrapping_op_handler_inner (Context *ctx, TyTy::FnType *fntype, tree_code op) auto wrap_expr = build2 (op, TREE_TYPE (lhs), lhs, rhs); auto return_statement - = ctx->get_backend ()->return_statement (fndecl, {wrap_expr}, Location ()); + = ctx->get_backend ()->return_statement (fndecl, {wrap_expr}, + UNDEF_LOCATION); ctx->add_statement (return_statement); // BUILTIN wrapping_ FN BODY END @@ -604,8 +606,8 @@ op_with_overflow_inner (Context *ctx, TyTy::FnType *fntype, tree_code op) enter_intrinsic_block (ctx, fndecl); // BUILTIN op_with_overflow FN BODY BEGIN - auto x = ctx->get_backend ()->var_expression (x_param, Location ()); - auto y = ctx->get_backend ()->var_expression (y_param, Location ()); + auto x = ctx->get_backend ()->var_expression (x_param, UNDEF_LOCATION); + auto y = ctx->get_backend ()->var_expression (y_param, UNDEF_LOCATION); tree overflow_builtin = error_mark_node; switch (op) @@ -638,10 +640,10 @@ op_with_overflow_inner (Context *ctx, TyTy::FnType *fntype, tree_code op) = ctx->get_backend ()->temporary_variable (fndecl, NULL_TREE, overflow_op_type, NULL_TREE, true /*address_is_taken*/, - Location (), &tmp_stmt); + UNDEF_LOCATION, &tmp_stmt); ctx->add_statement (tmp_stmt); - tree result_decl = bvar->get_tree (Location ()); + tree result_decl = bvar->get_tree (UNDEF_LOCATION); tree result_ref = build_fold_addr_expr_loc (BUILTINS_LOCATION, result_decl); tree did_overflow_node @@ -652,11 +654,11 @@ op_with_overflow_inner (Context *ctx, TyTy::FnType *fntype, tree_code op) tree tuple_type = TREE_TYPE (DECL_RESULT (fndecl)); tree result_expr = ctx->get_backend ()->constructor_expression (tuple_type, false, vals, -1, - Location ()); + UNDEF_LOCATION); auto return_statement = ctx->get_backend ()->return_statement (fndecl, {result_expr}, - Location ()); + UNDEF_LOCATION); ctx->add_statement (return_statement); // BUILTIN wrapping_ FN BODY END @@ -696,9 +698,12 @@ copy_nonoverlapping_handler (Context *ctx, TyTy::FnType *fntype) // BUILTIN copy_nonoverlapping BODY BEGIN - auto src = ctx->get_backend ()->var_expression (param_vars[0], Location ()); - auto dst = ctx->get_backend ()->var_expression (param_vars[1], Location ()); - auto count = ctx->get_backend ()->var_expression (param_vars[2], Location ()); + auto src + = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION); + auto dst + = ctx->get_backend ()->var_expression (param_vars[1], UNDEF_LOCATION); + auto count + = ctx->get_backend ()->var_expression (param_vars[2], UNDEF_LOCATION); // We want to create the following statement // memcpy(dst, src, size_of::()); @@ -718,7 +723,7 @@ copy_nonoverlapping_handler (Context *ctx, TyTy::FnType *fntype) auto copy_call = ctx->get_backend ()->call_expression (memcpy, {dst, src, size_expr}, - nullptr, Location ()); + nullptr, UNDEF_LOCATION); ctx->add_statement (copy_call); @@ -762,8 +767,8 @@ prefetch_data_handler (Context *ctx, TyTy::FnType *fntype, Prefetch kind) enter_intrinsic_block (ctx, fndecl); - auto addr = ctx->get_backend ()->var_expression (args[0], Location ()); - auto locality = ctx->get_backend ()->var_expression (args[1], Location ()); + auto addr = ctx->get_backend ()->var_expression (args[0], UNDEF_LOCATION); + auto locality = ctx->get_backend ()->var_expression (args[1], UNDEF_LOCATION); auto rw_flag = make_unsigned_long_tree (ctx, kind == Prefetch::Write ? 1 : 0); auto prefetch_raw = NULL_TREE; @@ -774,7 +779,7 @@ prefetch_data_handler (Context *ctx, TyTy::FnType *fntype, Prefetch kind) auto prefetch_call = ctx->get_backend ()->call_expression (prefetch, {addr, rw_flag, locality}, - nullptr, Location ()); + nullptr, UNDEF_LOCATION); TREE_READONLY (prefetch_call) = 0; TREE_SIDE_EFFECTS (prefetch_call) = 1; @@ -845,10 +850,12 @@ atomic_store_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering) enter_intrinsic_block (ctx, fndecl); - auto dst = ctx->get_backend ()->var_expression (param_vars[0], Location ()); + auto dst + = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION); TREE_READONLY (dst) = 0; - auto value = ctx->get_backend ()->var_expression (param_vars[1], Location ()); + auto value + = ctx->get_backend ()->var_expression (param_vars[1], UNDEF_LOCATION); auto memorder = make_unsigned_long_tree (ctx, ordering); auto monomorphized_type @@ -871,7 +878,7 @@ atomic_store_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering) auto store_call = ctx->get_backend ()->call_expression (atomic_store, {dst, value, memorder}, nullptr, - Location ()); + UNDEF_LOCATION); TREE_READONLY (store_call) = 0; TREE_SIDE_EFFECTS (store_call) = 1; @@ -908,7 +915,8 @@ atomic_load_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering) enter_intrinsic_block (ctx, fndecl); - auto src = ctx->get_backend ()->var_expression (param_vars[0], Location ()); + auto src + = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION); auto memorder = make_unsigned_long_tree (ctx, ordering); auto monomorphized_type @@ -930,9 +938,10 @@ atomic_load_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering) auto load_call = ctx->get_backend ()->call_expression (atomic_load, {src, memorder}, - nullptr, Location ()); + nullptr, UNDEF_LOCATION); auto return_statement - = ctx->get_backend ()->return_statement (fndecl, {load_call}, Location ()); + = ctx->get_backend ()->return_statement (fndecl, {load_call}, + UNDEF_LOCATION); TREE_READONLY (load_call) = 0; TREE_SIDE_EFFECTS (load_call) = 1; @@ -966,8 +975,8 @@ unchecked_op_inner (Context *ctx, TyTy::FnType *fntype, tree_code op) // BUILTIN unchecked_ BODY BEGIN - auto x = ctx->get_backend ()->var_expression (param_vars[0], Location ()); - auto y = ctx->get_backend ()->var_expression (param_vars[1], Location ()); + auto x = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION); + auto y = ctx->get_backend ()->var_expression (param_vars[1], UNDEF_LOCATION); auto *monomorphized_type = fntype->get_substs ().at (0).get_param_ty ()->resolve (); @@ -977,7 +986,7 @@ unchecked_op_inner (Context *ctx, TyTy::FnType *fntype, tree_code op) auto expr = build2 (op, TREE_TYPE (x), x, y); auto return_statement - = ctx->get_backend ()->return_statement (fndecl, {expr}, Location ()); + = ctx->get_backend ()->return_statement (fndecl, {expr}, UNDEF_LOCATION); ctx->add_statement (return_statement); @@ -1032,7 +1041,7 @@ uninit_handler (Context *ctx, TyTy::FnType *fntype) auto return_statement = ctx->get_backend ()->return_statement (fndecl, {DECL_RESULT (fndecl)}, - Location ()); + UNDEF_LOCATION); ctx->add_statement (return_statement); // BUILTIN size_of FN BODY END @@ -1070,8 +1079,10 @@ move_val_init_handler (Context *ctx, TyTy::FnType *fntype) // BUILTIN size_of FN BODY BEGIN - tree dst = ctx->get_backend ()->var_expression (param_vars[0], Location ()); - tree src = ctx->get_backend ()->var_expression (param_vars[1], Location ()); + tree dst + = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION); + tree src + = ctx->get_backend ()->var_expression (param_vars[1], UNDEF_LOCATION); tree size = TYPE_SIZE_UNIT (template_parameter_type); tree memcpy_builtin = error_mark_node; diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 7ee1d2826478..441c448be00f 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -32,7 +32,7 @@ public: static tree compile (HIR::Item *item, Context *ctx, TyTy::BaseType *concrete = nullptr, bool is_query_mode = false, - Location ref_locus = Location ()) + Location ref_locus = UNDEF_LOCATION) { CompileItem compiler (ctx, concrete, ref_locus); item->accept_vis (compiler); diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 6867737801ad..b4c46e9cb12e 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -336,11 +336,12 @@ HIRCompileBase::compute_address_for_trait_item ( if (lookup_fntype->needs_substitution ()) { TyTy::BaseType *infer - = Resolver::SubstMapper::InferSubst (lookup_fntype, Location ()); + = Resolver::SubstMapper::InferSubst (lookup_fntype, UNDEF_LOCATION); infer = Resolver::unify_site (infer->get_ref (), TyTy::TyWithLocation (trait_item_fntype), - TyTy::TyWithLocation (infer), Location ()); + TyTy::TyWithLocation (infer), + UNDEF_LOCATION); rust_assert (infer->get_kind () == TyTy::TypeKind::FNDEF); lookup_fntype = static_cast (infer); } diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc index 3fd1b967b5f9..df5c2e427d1e 100644 --- a/gcc/rust/backend/rust-constexpr.cc +++ b/gcc/rust/backend/rust-constexpr.cc @@ -3830,7 +3830,8 @@ build_data_member_initialization (tree t, vec **vec) member = TREE_OPERAND (member, 1); else if (ANON_AGGR_TYPE_P (TREE_TYPE (aggr))) /* Initializing a member of an anonymous union. */ - rust_sorry_at (Location (), "cannot handle value initialization yet"); + rust_sorry_at (UNDEF_LOCATION, + "cannot handle value initialization yet"); // return build_anon_member_initialization (member, init, vec); else /* We're initializing a vtable pointer in a base. Leave it as @@ -3841,10 +3842,10 @@ build_data_member_initialization (tree t, vec **vec) /* Value-initialization can produce multiple initializers for the same field; use the last one. */ if (!vec_safe_is_empty (*vec) && (*vec)->last ().index == member) - rust_sorry_at (Location (), "cannot handle value initialization yet"); + rust_sorry_at (UNDEF_LOCATION, "cannot handle value initialization yet"); // (*vec)->last ().value = init; else - rust_sorry_at (Location (), "cannot handle value initialization yet"); + rust_sorry_at (UNDEF_LOCATION, "cannot handle value initialization yet"); // CONSTRUCTOR_APPEND_ELT (*vec, member, init); return true; } diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index cbd0e5057ca3..d40d1059683c 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -643,7 +643,7 @@ ExpandVisitor::visit (AST::AttrInputLiteral &) void ExpandVisitor::visit (AST::AttrInputMacro ¯o) { - rust_sorry_at (Location (), "macros in attributes not supported"); + rust_sorry_at (UNDEF_LOCATION, "macros in attributes not supported"); } void diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 4ac6fdc3762e..abe8f20ed9c3 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -1102,7 +1102,7 @@ MacroExpander::import_proc_macros (std::string extern_crate) { // Extern crate path is not available. // FIXME: Emit error - rust_error_at (Location (), "Cannot find requested proc macro crate"); + rust_error_at (UNDEF_LOCATION, "Cannot find requested proc macro crate"); gcc_unreachable (); } auto macros = load_macros (path->second); diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h index 14afac042028..85af83fe21e6 100644 --- a/gcc/rust/expand/rust-macro-expand.h +++ b/gcc/rust/expand/rust-macro-expand.h @@ -422,7 +422,7 @@ struct MacroExpander if (!mappings->lookup_derive_proc_macro (std::make_pair (crate, name), macro)) { - rust_error_at (Location (), "procedural macro %s not found", + rust_error_at (UNDEF_LOCATION, "procedural macro %s not found", name.c_str ()); rust_assert (false); } @@ -453,7 +453,7 @@ struct MacroExpander if (!mappings->lookup_bang_proc_macro (std::make_pair (crate, name), macro)) { - rust_error_at (Location (), "procedural macro %s not found", + rust_error_at (UNDEF_LOCATION, "procedural macro %s not found", name.c_str ()); rust_assert (false); } @@ -485,7 +485,7 @@ struct MacroExpander name), macro)) { - rust_error_at (Location (), "procedural macro %s not found", + rust_error_at (UNDEF_LOCATION, "procedural macro %s not found", name.c_str ()); rust_assert (false); } diff --git a/gcc/rust/expand/rust-macro-invoc-lexer.cc b/gcc/rust/expand/rust-macro-invoc-lexer.cc index 59d343f86a6c..db1471eab729 100644 --- a/gcc/rust/expand/rust-macro-invoc-lexer.cc +++ b/gcc/rust/expand/rust-macro-invoc-lexer.cc @@ -25,7 +25,7 @@ const_TokenPtr MacroInvocLexer::peek_token (int n) { if ((offs + n) >= token_stream.size ()) - return Token::make (END_OF_FILE, Location ()); + return Token::make (END_OF_FILE, UNDEF_LOCATION); return token_stream.at (offs + n)->get_tok_ptr (); } diff --git a/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc b/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc index f365549bdc1c..d9164179d30b 100644 --- a/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc +++ b/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc @@ -25,7 +25,7 @@ const_TokenPtr ProcMacroInvocLexer::peek_token (int n) { if ((offs + n) >= token_stream.size ()) - return Token::make (END_OF_FILE, Location ()); + return Token::make (END_OF_FILE, UNDEF_LOCATION); return token_stream.at (offs + n); } diff --git a/gcc/rust/expand/rust-proc-macro.cc b/gcc/rust/expand/rust-proc-macro.cc index 22744cb547d2..07a8d915474d 100644 --- a/gcc/rust/expand/rust-proc-macro.cc +++ b/gcc/rust/expand/rust-proc-macro.cc @@ -41,7 +41,7 @@ load_macros_array (std::string path) return *reinterpret_cast ( dlsym (handle, PROC_MACRO_DECL_PREFIX.c_str ())); #else - rust_sorry_at (Location (), + rust_sorry_at (UNDEF_LOCATION, "Procedural macros are not yet supported on windows host"); gcc_unreachable (); #endif diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h index 7dc77352f32f..98d71ddef81f 100644 --- a/gcc/rust/hir/tree/rust-hir-expr.h +++ b/gcc/rust/hir/tree/rust-hir-expr.h @@ -3582,7 +3582,7 @@ public: // Creates a match arm in an error state. static MatchArm create_error () { - Location locus = Location (); + Location locus = UNDEF_LOCATION; return MatchArm (std::vector > (), locus); } diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 0d5a31921020..b361190d5dd6 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -62,7 +62,7 @@ public: AST::Attribute &get_outer_attribute () { return outer_attr; } TypeParam (Analysis::NodeMapping mappings, Identifier type_representation, - Location locus = Location (), + Location locus = UNDEF_LOCATION, std::vector> type_param_bounds = std::vector> (), std::unique_ptr type = nullptr, @@ -581,7 +581,7 @@ private: public: Visibility (VisType vis_type, HIR::SimplePath path = HIR::SimplePath::create_empty (), - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : vis_type (vis_type), path (std::move (path)), locus (locus) {} diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h index b005e71ec423..35dbcd67c666 100644 --- a/gcc/rust/hir/tree/rust-hir-path.h +++ b/gcc/rust/hir/tree/rust-hir-path.h @@ -76,7 +76,7 @@ public: // Pointer type for type in constructor to enable polymorphism GenericArgsBinding (Identifier ident, std::unique_ptr type_ptr, - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : identifier (std::move (ident)), type (std::move (type_ptr)), locus (locus) {} @@ -202,7 +202,7 @@ public: GenericArgs &operator= (GenericArgs &&other) = default; // Creates an empty GenericArgs (no arguments) - static GenericArgs create_empty (Location locus = Location ()) + static GenericArgs create_empty (Location locus = UNDEF_LOCATION) { return GenericArgs ({}, {}, {}, {}, locus); } @@ -340,7 +340,7 @@ public: // Constructor PathInExpression (Analysis::NodeMapping mappings, std::vector path_segments, - Location locus = Location (), + Location locus = UNDEF_LOCATION, bool has_opening_scope_resolution = false, std::vector outer_attrs = std::vector ()) @@ -694,7 +694,7 @@ public: { return TypePath (Analysis::NodeMapping::get_error (), std::vector > (), - Location ()); + UNDEF_LOCATION); } // Constructor @@ -856,7 +856,7 @@ public: QualifiedPathInExpression (Analysis::NodeMapping mappings, QualifiedPathType qual_path_type, std::vector path_segments, - Location locus = Location (), + Location locus = UNDEF_LOCATION, std::vector outer_attrs = std::vector ()) : PathPattern (std::move (path_segments)), @@ -923,7 +923,7 @@ public: Analysis::NodeMapping mappings, QualifiedPathType qual_path_type, std::unique_ptr associated_segment, std::vector > path_segments, - Location locus = Location ()) + Location locus = UNDEF_LOCATION) : TypeNoBounds (mappings, locus), path_type (std::move (qual_path_type)), associated_segment (std::move (associated_segment)), segments (std::move (path_segments)) @@ -1005,7 +1005,7 @@ public: static HIR::SimplePath create_empty () { return HIR::SimplePath ({}, Analysis::NodeMapping::get_error (), - Location ()); + UNDEF_LOCATION); } bool is_error () const { return segments.empty (); } diff --git a/gcc/rust/hir/tree/rust-hir-type.h b/gcc/rust/hir/tree/rust-hir-type.h index 71f4cd20f0e6..3d1f8de7d634 100644 --- a/gcc/rust/hir/tree/rust-hir-type.h +++ b/gcc/rust/hir/tree/rust-hir-type.h @@ -737,7 +737,7 @@ public: // Creates an error state param. static MaybeNamedParam create_error () { - return MaybeNamedParam ({""}, UNNAMED, nullptr, Location ()); + return MaybeNamedParam ({""}, UNNAMED, nullptr, UNDEF_LOCATION); } Location get_locus () const { return locus; } diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h index 0c77572bb5bd..4e003855a6cf 100644 --- a/gcc/rust/hir/tree/rust-hir.h +++ b/gcc/rust/hir/tree/rust-hir.h @@ -565,7 +565,7 @@ public: static Lifetime error () { return Lifetime (Analysis::NodeMapping::get_error (), - AST::Lifetime::LifetimeType::NAMED, "", Location ()); + AST::Lifetime::LifetimeType::NAMED, "", UNDEF_LOCATION); } std::string as_string () const override; @@ -670,7 +670,7 @@ public: // Constructor LifetimeParam (Analysis::NodeMapping mappings, Lifetime lifetime, - Location locus = Location (), + Location locus = UNDEF_LOCATION, std::vector lifetime_bounds = std::vector (), AST::Attribute outer_attr = AST::Attribute::create_empty ()) diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc index e5d318d5af90..9f2fec6d57fe 100644 --- a/gcc/rust/lex/rust-lex.cc +++ b/gcc/rust/lex/rust-lex.cc @@ -187,7 +187,7 @@ Lexer::get_current_location () return line_map->get_location (current_column); else // If we have no linemap, we're lexing something without proper locations - return Location (); + return UNDEF_LOCATION; } Codepoint diff --git a/gcc/rust/metadata/rust-export-metadata.cc b/gcc/rust/metadata/rust-export-metadata.cc index 493e73bb4ee3..74c57ea68e1c 100644 --- a/gcc/rust/metadata/rust-export-metadata.cc +++ b/gcc/rust/metadata/rust-export-metadata.cc @@ -273,7 +273,7 @@ PublicInterface::write_to_path (const std::string &path) const const char *path_base_name = basename (path.c_str ()); if (strcmp (path_base_name, expected_file_name.c_str ()) != 0) { - rust_error_at (Location (), + rust_error_at (UNDEF_LOCATION, "expected metadata-output path to have base file name of: " "%<%s%> got %<%s%>", expected_file_name.c_str (), path_base_name); @@ -299,7 +299,8 @@ PublicInterface::write_to_path (const std::string &path) const FILE *nfd = fopen (path.c_str (), "wb"); if (nfd == NULL) { - rust_error_at (Location (), "failed to open file %<%s%> for writing: %s", + rust_error_at (UNDEF_LOCATION, + "failed to open file %<%s%> for writing: %s", path.c_str (), xstrerror (errno)); return; } @@ -307,7 +308,7 @@ PublicInterface::write_to_path (const std::string &path) const // write data if (fwrite (kMagicHeader, sizeof (kMagicHeader), 1, nfd) < 1) { - rust_error_at (Location (), "failed to write to file %<%s%>: %s", + rust_error_at (UNDEF_LOCATION, "failed to write to file %<%s%>: %s", path.c_str (), xstrerror (errno)); fclose (nfd); return; @@ -315,7 +316,7 @@ PublicInterface::write_to_path (const std::string &path) const if (fwrite (checksum, sizeof (checksum), 1, nfd) < 1) { - rust_error_at (Location (), "failed to write to file %<%s%>: %s", + rust_error_at (UNDEF_LOCATION, "failed to write to file %<%s%>: %s", path.c_str (), xstrerror (errno)); fclose (nfd); return; @@ -323,7 +324,7 @@ PublicInterface::write_to_path (const std::string &path) const if (fwrite (kSzDelim, sizeof (kSzDelim), 1, nfd) < 1) { - rust_error_at (Location (), "failed to write to file %<%s%>: %s", + rust_error_at (UNDEF_LOCATION, "failed to write to file %<%s%>: %s", path.c_str (), xstrerror (errno)); fclose (nfd); return; @@ -332,7 +333,7 @@ PublicInterface::write_to_path (const std::string &path) const if (fwrite (current_crate_name.c_str (), current_crate_name.size (), 1, nfd) < 1) { - rust_error_at (Location (), "failed to write to file %<%s%>: %s", + rust_error_at (UNDEF_LOCATION, "failed to write to file %<%s%>: %s", path.c_str (), xstrerror (errno)); fclose (nfd); return; @@ -340,7 +341,7 @@ PublicInterface::write_to_path (const std::string &path) const if (fwrite (kSzDelim, sizeof (kSzDelim), 1, nfd) < 1) { - rust_error_at (Location (), "failed to write to file %<%s%>: %s", + rust_error_at (UNDEF_LOCATION, "failed to write to file %<%s%>: %s", path.c_str (), xstrerror (errno)); fclose (nfd); return; @@ -348,7 +349,7 @@ PublicInterface::write_to_path (const std::string &path) const if (fwrite (size_buffer.c_str (), size_buffer.size (), 1, nfd) < 1) { - rust_error_at (Location (), "failed to write to file %<%s%>: %s", + rust_error_at (UNDEF_LOCATION, "failed to write to file %<%s%>: %s", path.c_str (), xstrerror (errno)); fclose (nfd); return; @@ -356,7 +357,7 @@ PublicInterface::write_to_path (const std::string &path) const if (fwrite (kSzDelim, sizeof (kSzDelim), 1, nfd) < 1) { - rust_error_at (Location (), "failed to write to file %<%s%>: %s", + rust_error_at (UNDEF_LOCATION, "failed to write to file %<%s%>: %s", path.c_str (), xstrerror (errno)); fclose (nfd); return; @@ -365,7 +366,7 @@ PublicInterface::write_to_path (const std::string &path) const if (!buf.empty ()) if (fwrite (buf.c_str (), buf.size (), 1, nfd) < 1) { - rust_error_at (Location (), "failed to write to file %<%s%>: %s", + rust_error_at (UNDEF_LOCATION, "failed to write to file %<%s%>: %s", path.c_str (), xstrerror (errno)); fclose (nfd); return; diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 6fe64f179cf5..509d6657b5c8 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -571,7 +571,7 @@ Parser::parse_attribute_body () // Skip past potential further info in attribute (i.e. attr_input) skip_after_end_attribute (); - return std::make_tuple (std::move (attr_path), nullptr, Location ()); + return std::make_tuple (std::move (attr_path), nullptr, UNDEF_LOCATION); } std::unique_ptr attr_input = parse_attr_input (); diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index 224d570f9369..1dee98ab0035 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -956,7 +956,7 @@ flatten_rebind (const AST::UseTreeRebind &rebind, // Add the identifier as a new path rebind_path.get_segments ().back () - = AST::SimplePathSegment (new_seg.as_string (), Location ()); + = AST::SimplePathSegment (new_seg.as_string (), UNDEF_LOCATION); paths.emplace_back (rebind_path); } @@ -1159,13 +1159,13 @@ namespace selftest { static void rust_flatten_nested_glob (void) { - auto foo = Rust::AST::SimplePathSegment ("foo", Location ()); - auto bar = Rust::AST::SimplePathSegment ("bar", Location ()); + auto foo = Rust::AST::SimplePathSegment ("foo", UNDEF_LOCATION); + auto bar = Rust::AST::SimplePathSegment ("bar", UNDEF_LOCATION); auto foobar = Rust::AST::SimplePath ({foo, bar}); auto glob = Rust::AST::UseTreeGlob (Rust::AST::UseTreeGlob::PathType::PATH_PREFIXED, - foobar, Location ()); + foobar, UNDEF_LOCATION); auto paths = std::vector (); Rust::Resolver::flatten_glob (glob, paths); @@ -1179,11 +1179,11 @@ rust_flatten_nested_glob (void) static void rust_flatten_glob (void) { - auto frob = Rust::AST::SimplePath::from_str ("frobulator", Location ()); + auto frob = Rust::AST::SimplePath::from_str ("frobulator", UNDEF_LOCATION); auto glob = Rust::AST::UseTreeGlob (Rust::AST::UseTreeGlob::PathType::PATH_PREFIXED, - frob, Location ()); + frob, UNDEF_LOCATION); auto paths = std::vector (); Rust::Resolver::flatten_glob (glob, paths); @@ -1196,12 +1196,12 @@ rust_flatten_glob (void) static void rust_flatten_rebind_none (void) { - auto foo = Rust::AST::SimplePathSegment ("foo", Location ()); - auto bar = Rust::AST::SimplePathSegment ("bar", Location ()); + auto foo = Rust::AST::SimplePathSegment ("foo", UNDEF_LOCATION); + auto bar = Rust::AST::SimplePathSegment ("bar", UNDEF_LOCATION); auto foobar = Rust::AST::SimplePath ({foo, bar}); auto rebind = Rust::AST::UseTreeRebind (Rust::AST::UseTreeRebind::NONE, - foobar, Location ()); + foobar, UNDEF_LOCATION); auto paths = std::vector (); Rust::Resolver::flatten_rebind (rebind, paths); @@ -1215,10 +1215,10 @@ rust_flatten_rebind_none (void) static void rust_flatten_rebind (void) { - auto frob = Rust::AST::SimplePath::from_str ("frobulator", Location ()); + auto frob = Rust::AST::SimplePath::from_str ("frobulator", UNDEF_LOCATION); auto rebind = Rust::AST::UseTreeRebind (Rust::AST::UseTreeRebind::IDENTIFIER, - frob, Location (), {"saindoux"}); + frob, UNDEF_LOCATION, {"saindoux"}); auto paths = std::vector (); Rust::Resolver::flatten_rebind (rebind, paths); @@ -1232,15 +1232,15 @@ rust_flatten_rebind (void) static void rust_flatten_rebind_nested (void) { - auto foo = Rust::AST::SimplePathSegment ("foo", Location ()); - auto bar = Rust::AST::SimplePathSegment ("bar", Location ()); - auto baz = Rust::AST::SimplePathSegment ("baz", Location ()); + auto foo = Rust::AST::SimplePathSegment ("foo", UNDEF_LOCATION); + auto bar = Rust::AST::SimplePathSegment ("bar", UNDEF_LOCATION); + auto baz = Rust::AST::SimplePathSegment ("baz", UNDEF_LOCATION); auto foo_bar_baz = Rust::AST::SimplePath ({foo, bar, baz}); auto rebind = Rust::AST::UseTreeRebind (Rust::AST::UseTreeRebind::IDENTIFIER, - foo_bar_baz, Location (), {"saindoux"}); + foo_bar_baz, UNDEF_LOCATION, {"saindoux"}); auto paths = std::vector (); Rust::Resolver::flatten_rebind (rebind, paths); @@ -1258,28 +1258,29 @@ rust_flatten_rebind_nested (void) static void rust_flatten_list (void) { - auto foo = Rust::AST::SimplePathSegment ("foo", Location ()); - auto bar = Rust::AST::SimplePathSegment ("bar", Location ()); + auto foo = Rust::AST::SimplePathSegment ("foo", UNDEF_LOCATION); + auto bar = Rust::AST::SimplePathSegment ("bar", UNDEF_LOCATION); auto foo_bar = Rust::AST::SimplePath ({foo, bar}); - auto baz = Rust::AST::SimplePath::from_str ("baz", Location ()); - auto bul = Rust::AST::SimplePath::from_str ("bul", Location ()); + auto baz = Rust::AST::SimplePath::from_str ("baz", UNDEF_LOCATION); + auto bul = Rust::AST::SimplePath::from_str ("bul", UNDEF_LOCATION); // use foo::bar::{baz, bul}; auto use0 = std::unique_ptr ( new Rust::AST::UseTreeRebind (Rust::AST::UseTreeRebind::NONE, baz, - Location ())); + UNDEF_LOCATION)); auto use1 = std::unique_ptr ( new Rust::AST::UseTreeRebind (Rust::AST::UseTreeRebind::NONE, bul, - Location ())); + UNDEF_LOCATION)); auto uses = std::vector> (); uses.emplace_back (std::move (use0)); uses.emplace_back (std::move (use1)); - auto list = Rust::AST::UseTreeList (Rust::AST::UseTreeList::PATH_PREFIXED, - foo_bar, std::move (uses), Location ()); + auto list + = Rust::AST::UseTreeList (Rust::AST::UseTreeList::PATH_PREFIXED, foo_bar, + std::move (uses), UNDEF_LOCATION); auto paths = std::vector (); Rust::Resolver::flatten_list (list, paths); diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc index ad03b79fde92..401434cb6675 100644 --- a/gcc/rust/resolve/rust-ast-resolve.cc +++ b/gcc/rust/resolve/rust-ast-resolve.cc @@ -84,7 +84,7 @@ NameResolution::go (AST::Crate &crate) // setup a dummy crate node resolver->get_name_scope ().insert ( CanonicalPath::new_seg (crate.get_node_id (), "__$$crate__"), - crate.get_node_id (), Location ()); + crate.get_node_id (), UNDEF_LOCATION); // setup the root scope resolver->push_new_module_scope (scope_node_id); diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index 4ec1c53db489..58b13616480d 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -200,7 +200,7 @@ struct Error } // namespace Rust // rust_debug uses normal printf formatting, not GCC diagnostic formatting. -#define rust_debug(...) rust_debug_loc (Location (), __VA_ARGS__) +#define rust_debug(...) rust_debug_loc (UNDEF_LOCATION, __VA_ARGS__) // rust_sorry_at wraps GCC diagnostic "sorry_at" to accept "Location" instead of // "location_t" diff --git a/gcc/rust/rust-location.h b/gcc/rust/rust-location.h index b0b14c6ebb49..1944bb7b84aa 100644 --- a/gcc/rust/rust-location.h +++ b/gcc/rust/rust-location.h @@ -26,6 +26,9 @@ // A location in an input source file. +// Used to replace Location default constructor +#define UNDEF_LOCATION UNKNOWN_LOCATION + typedef location_t Location; class RichLocation diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index aaf19f380fc9..e524bc3d0550 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -115,12 +115,12 @@ validate_crate_name (const std::string &crate_name, Error &error) { if (crate_name.empty ()) { - error = Error (Location (), "crate name cannot be empty"); + error = Error (UNDEF_LOCATION, "crate name cannot be empty"); return false; } if (crate_name.length () > kMaxNameLength) { - error = Error (Location (), "crate name cannot exceed %lu characters", + error = Error (UNDEF_LOCATION, "crate name cannot exceed %lu characters", (unsigned long) kMaxNameLength); return false; } @@ -128,7 +128,7 @@ validate_crate_name (const std::string &crate_name, Error &error) { if (!(ISALNUM (c) || c == '_')) { - error = Error (Location (), + error = Error (UNDEF_LOCATION, "invalid character %<%c%> in crate name: %<%s%>", c, crate_name.c_str ()); return false; @@ -197,7 +197,7 @@ Session::handle_option ( // set the crate name if (arg != nullptr) { - auto error = Error (Location (), std::string ()); + auto error = Error (UNDEF_LOCATION, std::string ()); if ((ret = validate_crate_name (arg, error))) { options.set_crate_name (arg); @@ -276,7 +276,7 @@ Session::handle_cfg_option (std::string &input) if (!parse_cfg_option (input, key, value)) { rust_error_at ( - Location (), + UNDEF_LOCATION, "invalid argument to %<-frust-cfg%>: Accepted formats are " "%<-frust-cfg=key%> or %<-frust-cfg=key=\"value\"%> (quoted)"); return false; @@ -299,7 +299,7 @@ Session::enable_dump (std::string arg) if (arg.empty ()) { rust_error_at ( - Location (), + UNDEF_LOCATION, "dump option was not given a name. choose %, %, " "%, %, " "%, %, %, %, " @@ -350,7 +350,7 @@ Session::enable_dump (std::string arg) else { rust_error_at ( - Location (), + UNDEF_LOCATION, "dump option %qs was unrecognised. choose %, %, " "%, %, " "%, %, %, %, " @@ -367,7 +367,7 @@ void Session::handle_input_files (int num_files, const char **files) { if (num_files != 1) - rust_fatal_error (Location (), + rust_fatal_error (UNDEF_LOCATION, "only one file may be specified on the command line"); const auto &file = files[0]; @@ -397,7 +397,7 @@ Session::handle_crate_name (const AST::Crate &parsed_crate) { auto mappings = Analysis::Mappings::get (); auto crate_name_changed = false; - auto error = Error (Location (), std::string ()); + auto error = Error (UNDEF_LOCATION, std::string ()); for (const auto &attr : parsed_crate.inner_attrs) { @@ -450,7 +450,7 @@ Session::compile_crate (const char *filename) if (!flag_rust_experimental && !std::getenv ("GCCRS_INCOMPLETE_AND_EXPERIMENTAL_COMPILER_DO_NOT_USE")) rust_fatal_error ( - Location (), "%s", + UNDEF_LOCATION, "%s", "gccrs is not yet able to compile Rust code " "properly. Most of the errors produced will be gccrs' fault and not the " "crate you are trying to compile. Because of this, please reports issues " @@ -472,7 +472,7 @@ Session::compile_crate (const char *filename) RAIIFile file_wrap (filename); if (!file_wrap.ok ()) { - rust_error_at (Location (), "cannot open filename %s: %m", filename); + rust_error_at (UNDEF_LOCATION, "cannot open filename %s: %m", filename); return; } @@ -795,7 +795,8 @@ Session::injection (AST::Crate &crate) { // create "macro use" attribute for use on extern crate item to enable // loading macros from it - AST::Attribute attr (AST::SimplePath::from_str ("macro_use", Location ()), + AST::Attribute attr (AST::SimplePath::from_str ("macro_use", + UNDEF_LOCATION), nullptr); // create "extern crate" item with the name @@ -813,20 +814,21 @@ Session::injection (AST::Crate &crate) // FIXME: Once we do want to include the standard library, add the prelude // use item // std::vector segments - // = {AST::SimplePathSegment (injected_crate_name, Location ()), - // AST::SimplePathSegment ("prelude", Location ()), - // AST::SimplePathSegment ("v1", Location ())}; + // = {AST::SimplePathSegment (injected_crate_name, UNDEF_LOCATION), + // AST::SimplePathSegment ("prelude", UNDEF_LOCATION), + // AST::SimplePathSegment ("v1", UNDEF_LOCATION)}; // // create use tree and decl // std::unique_ptr use_tree ( // new AST::UseTreeGlob (AST::UseTreeGlob::PATH_PREFIXED, - // AST::SimplePath (std::move (segments)), Location ())); + // AST::SimplePath (std::move (segments)), + // UNDEF_LOCATION)); // AST::Attribute prelude_attr (AST::SimplePath::from_str ("prelude_import", - // Location ()), + // UNDEF_LOCATION), // nullptr); // std::unique_ptr use_decl ( // new AST::UseDeclaration (std::move (use_tree), // AST::Visibility::create_error (), - // {std::move (prelude_attr)}, Location ())); + // {std::move (prelude_attr)}, UNDEF_LOCATION)); // crate.items.insert (crate.items.begin (), std::move (use_decl)); @@ -1227,7 +1229,7 @@ namespace selftest { void rust_crate_name_validation_test (void) { - auto error = Rust::Error (Location (), std::string ()); + auto error = Rust::Error (UNDEF_LOCATION, std::string ()); ASSERT_TRUE (Rust::validate_crate_name ("example", error)); ASSERT_TRUE (Rust::validate_crate_name ("abcdefg_1234", error)); ASSERT_TRUE (Rust::validate_crate_name ("1", error)); diff --git a/gcc/rust/typecheck/rust-autoderef.cc b/gcc/rust/typecheck/rust-autoderef.cc index 7c8c55d7db94..9437f3fe0d66 100644 --- a/gcc/rust/typecheck/rust-autoderef.cc +++ b/gcc/rust/typecheck/rust-autoderef.cc @@ -292,7 +292,7 @@ resolve_operator_overload_fn ( // requires another deref which is matched to the deref trait impl of // &&T so this requires another reference and deref call - lookup = fn->infer_substitions (Location ()); + lookup = fn->infer_substitions (UNDEF_LOCATION); rust_assert (lookup->get_kind () == TyTy::TypeKind::FNDEF); fn = static_cast (lookup); diff --git a/gcc/rust/typecheck/rust-coercion.cc b/gcc/rust/typecheck/rust-coercion.cc index f0324d15dcdf..f1f349ad6ec3 100644 --- a/gcc/rust/typecheck/rust-coercion.cc +++ b/gcc/rust/typecheck/rust-coercion.cc @@ -438,7 +438,7 @@ TypeCoercionRules::select (TyTy::BaseType &autoderefed) TyTy::BaseType *result = unify_site_and (autoderefed.get_ref (), TyTy::TyWithLocation (expected), TyTy::TyWithLocation (&autoderefed), - Location () /* locus */, false /*emit_errors*/, + UNDEF_LOCATION /* locus */, false /*emit_errors*/, false /*commit_if_ok*/, true /*infer*/, true /*cleanup*/); bool ok = result->get_kind () != TyTy::TypeKind::ERROR; if (!ok) diff --git a/gcc/rust/typecheck/rust-hir-dot-operator.cc b/gcc/rust/typecheck/rust-hir-dot-operator.cc index 1c8ee000a10d..85544a0a926f 100644 --- a/gcc/rust/typecheck/rust-hir-dot-operator.cc +++ b/gcc/rust/typecheck/rust-hir-dot-operator.cc @@ -65,7 +65,7 @@ MethodResolver::Select (std::set &candidates, TyTy::BaseType *param = fn.get_params ().at (i + 1).second; TyTy::BaseType *coerced = try_coercion (0, TyTy::TyWithLocation (param), - TyTy::TyWithLocation (arg), Location ()); + TyTy::TyWithLocation (arg), UNDEF_LOCATION); if (coerced->get_kind () == TyTy::TypeKind::ERROR) { failed = true; @@ -325,8 +325,9 @@ MethodResolver::select (TyTy::BaseType &receiver) fn_self->debug_str ().c_str (), receiver.debug_str ().c_str ()); - auto res = TypeCoercionRules::TryCoerce (&receiver, fn_self, Location (), - false /*allow-autoderef*/); + auto res + = TypeCoercionRules::TryCoerce (&receiver, fn_self, UNDEF_LOCATION, + false /*allow-autoderef*/); bool ok = !res.is_error (); if (ok) { @@ -365,8 +366,9 @@ MethodResolver::select (TyTy::BaseType &receiver) fn_self->debug_str ().c_str (), receiver.debug_str ().c_str ()); - auto res = TypeCoercionRules::TryCoerce (&receiver, fn_self, Location (), - false /*allow-autoderef*/); + auto res + = TypeCoercionRules::TryCoerce (&receiver, fn_self, UNDEF_LOCATION, + false /*allow-autoderef*/); bool ok = !res.is_error (); if (ok) { @@ -400,8 +402,9 @@ MethodResolver::select (TyTy::BaseType &receiver) "dot-operator trait_impl_item fn_self={%s} can_eq receiver={%s}", fn_self->debug_str ().c_str (), receiver.debug_str ().c_str ()); - auto res = TypeCoercionRules::TryCoerce (&receiver, fn_self, Location (), - false /*allow-autoderef*/); + auto res + = TypeCoercionRules::TryCoerce (&receiver, fn_self, UNDEF_LOCATION, + false /*allow-autoderef*/); bool ok = !res.is_error (); if (ok) { @@ -431,8 +434,9 @@ MethodResolver::select (TyTy::BaseType &receiver) fn_self->debug_str ().c_str (), receiver.debug_str ().c_str ()); - auto res = TypeCoercionRules::TryCoerce (&receiver, fn_self, Location (), - false /*allow-autoderef*/); + auto res + = TypeCoercionRules::TryCoerce (&receiver, fn_self, UNDEF_LOCATION, + false /*allow-autoderef*/); bool ok = !res.is_error (); if (ok) { diff --git a/gcc/rust/typecheck/rust-hir-path-probe.cc b/gcc/rust/typecheck/rust-hir-path-probe.cc index faa4fdad6921..496f8109fdd7 100644 --- a/gcc/rust/typecheck/rust-hir-path-probe.cc +++ b/gcc/rust/typecheck/rust-hir-path-probe.cc @@ -89,7 +89,7 @@ PathProbeCandidate::is_full_trait_item_candidate () const PathProbeCandidate PathProbeCandidate::get_error () { - return PathProbeCandidate (ERROR, nullptr, Location (), + return PathProbeCandidate (ERROR, nullptr, UNDEF_LOCATION, ImplItemCandidate{nullptr, nullptr}); } @@ -343,7 +343,7 @@ PathProbeType::process_associated_trait_for_candidates ( break; } - const TyTy::TypeBoundPredicate p (*trait_ref, Location ()); + const TyTy::TypeBoundPredicate p (*trait_ref, UNDEF_LOCATION); TyTy::TypeBoundPredicateItem item (&p, trait_item_ref); TyTy::BaseType *trait_item_tyty = item.get_raw_item ()->get_tyty (); diff --git a/gcc/rust/typecheck/rust-hir-trait-reference.cc b/gcc/rust/typecheck/rust-hir-trait-reference.cc index a24b99f0e49f..72069caaf0cc 100644 --- a/gcc/rust/typecheck/rust-hir-trait-reference.cc +++ b/gcc/rust/typecheck/rust-hir-trait-reference.cc @@ -387,7 +387,7 @@ TraitReference::is_object_safe (bool emit_error, Location locus) const std::vector non_object_super_traits; for (auto &item : super_traits) { - if (!item->is_object_safe (false, Location ())) + if (!item->is_object_safe (false, UNDEF_LOCATION)) non_object_super_traits.push_back (item); } diff --git a/gcc/rust/typecheck/rust-hir-trait-reference.h b/gcc/rust/typecheck/rust-hir-trait-reference.h index 440a232a50e2..38f2949ece78 100644 --- a/gcc/rust/typecheck/rust-hir-trait-reference.h +++ b/gcc/rust/typecheck/rust-hir-trait-reference.h @@ -51,7 +51,7 @@ public: static TraitItemReference error () { return TraitItemReference ("", false, ERROR, nullptr, nullptr, {}, - Location ()); + UNDEF_LOCATION); } static TraitItemReference &error_node () diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index 16036431db4d..b9c7f72acf93 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -940,7 +940,7 @@ TypeCheckExpr::visit (HIR::ArrayExpr &expr) capacity_expr = new HIR::LiteralExpr (mapping, capacity_str, HIR::Literal::LitType::INT, PrimitiveCoreType::CORETYPE_USIZE, - Location (), {}); + UNDEF_LOCATION, {}); // mark the type for this implicit node TyTy::BaseType *expected_ty = nullptr; diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc index 6c1a07787c6d..b12dc258c517 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc @@ -123,7 +123,7 @@ TypeCheckTopLevelExternItem::visit (HIR::ExternalFunctionItem &function) HIR::IdentifierPattern *param_pattern = new HIR::IdentifierPattern (mapping, param.get_param_name (), - Location (), false, Mutability::Imm, + UNDEF_LOCATION, false, Mutability::Imm, std::unique_ptr (nullptr)); params.push_back ( diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc index 16656171b12f..be4c47920acb 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc @@ -826,7 +826,7 @@ ResolveWhereClauseItem::visit (HIR::TypeBoundWhereClauseItem &item) if (!resolver->lookup_resolved_type (ast_node_id, &ref_node_id)) { // FIXME - rust_error_at (Location (), + rust_error_at (UNDEF_LOCATION, "Failed to lookup type reference for node: %s", binding_type_path->as_string ().c_str ()); return; @@ -837,7 +837,7 @@ ResolveWhereClauseItem::visit (HIR::TypeBoundWhereClauseItem &item) if (!mappings->lookup_node_to_hir (ref_node_id, &ref)) { // FIXME - rust_error_at (Location (), "where-clause reverse lookup failure"); + rust_error_at (UNDEF_LOCATION, "where-clause reverse lookup failure"); return; } diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc index 7c1477d4f4d7..60231dc13641 100644 --- a/gcc/rust/typecheck/rust-hir-type-check.cc +++ b/gcc/rust/typecheck/rust-hir-type-check.cc @@ -65,7 +65,7 @@ TypeResolution::Resolve (HIR::Crate &crate) { auto result = unify_site (id, TyTy::TyWithLocation (ty), - TyTy::TyWithLocation (default_type), Location ()); + TyTy::TyWithLocation (default_type), UNDEF_LOCATION); rust_assert (result); rust_assert (result->get_kind () != TyTy::TypeKind::ERROR); result->set_ref (id); diff --git a/gcc/rust/typecheck/rust-tyty-bounds.cc b/gcc/rust/typecheck/rust-tyty-bounds.cc index af172d6b6507..7b6f788452bd 100644 --- a/gcc/rust/typecheck/rust-tyty-bounds.cc +++ b/gcc/rust/typecheck/rust-tyty-bounds.cc @@ -395,7 +395,7 @@ TypeBoundPredicate::operator= (const TypeBoundPredicate &other) TypeBoundPredicate TypeBoundPredicate::error () { - auto p = TypeBoundPredicate (UNKNOWN_DEFID, {}, Location ()); + auto p = TypeBoundPredicate (UNKNOWN_DEFID, {}, UNDEF_LOCATION); p.error_flag = true; return p; } diff --git a/gcc/rust/typecheck/rust-tyty-subst.cc b/gcc/rust/typecheck/rust-tyty-subst.cc index 9c5c76dd8d22..07ce8d4f4d83 100644 --- a/gcc/rust/typecheck/rust-tyty-subst.cc +++ b/gcc/rust/typecheck/rust-tyty-subst.cc @@ -278,14 +278,14 @@ SubstitutionArgumentMappings::operator= ( SubstitutionArgumentMappings SubstitutionArgumentMappings::error () { - return SubstitutionArgumentMappings ({}, {}, Location (), nullptr, false, + return SubstitutionArgumentMappings ({}, {}, UNDEF_LOCATION, nullptr, false, true); } SubstitutionArgumentMappings SubstitutionArgumentMappings::empty () { - return SubstitutionArgumentMappings ({}, {}, Location (), nullptr, false, + return SubstitutionArgumentMappings ({}, {}, UNDEF_LOCATION, nullptr, false, false); } diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 06a8e7085364..03d3b8d1087a 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -463,7 +463,7 @@ BaseType::destructure () if (recurisve_ops++ >= rust_max_recursion_depth) { rust_error_at ( - Location (), + UNDEF_LOCATION, "% count exceeds limit of %i (use " "% to increase the limit)", rust_max_recursion_depth); @@ -515,7 +515,7 @@ BaseType::destructure () const if (recurisve_ops++ >= rust_max_recursion_depth) { rust_error_at ( - Location (), + UNDEF_LOCATION, "% count exceeds limit of %i (use " "% to increase the limit)", rust_max_recursion_depth); @@ -1267,12 +1267,12 @@ InferType::apply_primitive_type_hint (const BaseType &hint) ErrorType::ErrorType (HirId ref, std::set refs) : BaseType (ref, ref, TypeKind::ERROR, - {Resolver::CanonicalPath::create_empty (), Location ()}, refs) + {Resolver::CanonicalPath::create_empty (), UNDEF_LOCATION}, refs) {} ErrorType::ErrorType (HirId ref, HirId ty_ref, std::set refs) : BaseType (ref, ty_ref, TypeKind::ERROR, - {Resolver::CanonicalPath::create_empty (), Location ()}, refs) + {Resolver::CanonicalPath::create_empty (), UNDEF_LOCATION}, refs) {} std::string @@ -3877,7 +3877,7 @@ DynamicObjectType::is_equal (const BaseType &other) const if (num_specified_bounds () != other.num_specified_bounds ()) return false; - return bounds_compatible (other, Location (), false); + return bounds_compatible (other, UNDEF_LOCATION, false); } const std::vector< diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index e023f1fe76c1..d7b5c96205d1 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -102,7 +102,7 @@ Mappings::Mappings () = new HIR::ImplBlock (node, {}, {}, nullptr, nullptr, HIR::WhereClause ({}), Positive, HIR::Visibility (HIR::Visibility::VisType::PUBLIC), - {}, {}, Location ()); + {}, {}, UNDEF_LOCATION); } Mappings::~Mappings () { delete builtinMarker; } @@ -802,7 +802,7 @@ Mappings::lookup_location (HirId id) { auto it = locations.find (id); if (it == locations.end ()) - return Location (); + return UNDEF_LOCATION; return it->second; }