aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.cc
AgeCommit message (Collapse)AuthorFilesLines
2025-03-19gccrs: Use name resolver 2.0 for compiling break/continueOwen Avery1-4/+37
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Use name resolver 2.0 to lookup label definitions for break and continue statements when name resolution 2.0 is enabled. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-19gccrs: [gccrs#3141] Remove double negation by returning CompileExpr::Compile ↵JoanVC1-6/+5
early Fixes gccrs#3141. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc Signed-off-by: Joan Vilardaga <github-91yu@joanvc.cat>
2025-03-19gccrs: [gccrs#3141] Fix incorrect handling of overflow in numeric typesJoanVC1-5/+62
Fixes gccrs#3141. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc: Fix range checking for both integers and floats. * hir/tree/rust-hir-expr.h: Add "negative_number" boolean to LiteralExpr class. gcc/testsuite/ChangeLog: * rust/compile/issue-3141.rs: New test. Signed-off-by: Joan Vilardaga <github-91yu@joanvc.cat>
2025-03-19gccrs: Rehaul, Apply code review from Arthurbadumbatish1-2/+2
gcc/rust/ChangeLog: * backend/rust-compile-asm.cc (CompileAsm::visit): Change API, public/private, comments, formatting from code review (CompileAsm::asm_build_expr): Likewise. (CompileAsm::tree_codegen_asm): Likewise. * backend/rust-compile-asm.h (class CompileAsm): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * expand/rust-macro-builtins-asm.cc (strip_double_quotes): Likewise. (parse_options): Likewise. (parse_asm_arg): Likewise. (expand_inline_asm_strings): Likewise. (parse_asm): Likewise. * expand/rust-macro-builtins-asm.h (strip_double_quotes): Likewise. (expand_inline_asm_strings): Likewise. (expand_inline_asm_string): Likewise. * hir/tree/rust-hir-expr.h: Likewise. gcc/testsuite/ChangeLog: * rust/compile/inline_asm_typecheck.rs: Change comments
2025-03-19gccrs: Successfully produce pseudo-nopbadumbatish1-1/+2
gcc/rust/ChangeLog: * backend/rust-compile-asm.cc (CompileAsm::add_stmt): Deleted (CompileAsm::CompileAsm): Successfully produce pseudo-nop (CompileAsm::visit): Likewise (CompileAsm::asm_build_asm_stmt): Likewise (CompileAsm::asm_construct_string_tree): Likewise (CompileAsm::asm_is_inline): Likewise * backend/rust-compile-asm.h (class CompileAsm): Likewise * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise
2025-03-19gccrs: Scaffolding codebadumbatish1-0/+1
gcc/rust/ChangeLog: * backend/rust-compile-asm.cc (CompileAsm::add_stmt): Scaffolding code. (CompileAsm::asm_build_asm_stmt): Likewise. (CompileAsm::asm_build_expr): Likewise. (CompileAsm::asm_construct_string_tree): Likewise. * backend/rust-compile-asm.h: Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
2025-03-19gccrs: Scaffolding new compile-asm filesbadumbatish1-5/+4
gcc/rust/ChangeLog: * Make-lang.in: Scaffolding new compile-asm files * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise * hir/tree/rust-hir-expr.h: Likewise * backend/rust-compile-asm.cc: New file. Likewise * backend/rust-compile-asm.h: New file. Likewise
2025-03-19gccrs: Setting up interfaces for codegenjjasmine1-2/+4
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Setting up interfaces for codegen * hir/tree/rust-hir-expr.h: Likewise.
2025-03-19gccrs: Local testing for build_string and debug()jjasmine1-1/+4
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Local testing for build_string and debug()
2025-03-19gccrs: Scaffolding asm codegenjjasmine1-0/+4
gcc/rust/ChangeLog: * backend/rust-compile-block.h: Scaffolding asm codegen * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-expr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Likewise. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-visitor.h: Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise.
2025-03-17gccrs: Change lookup_hir_to_node return type to optionalPierre-Emmanuel Patry1-4/+6
Optional are more convenient to use and avoid uninitialized data. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::generate_closure_function): Adapt code for new optional return type. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy): Likewise. * util/rust-hir-map.cc (Mappings::lookup_hir_to_node): Change return type to an optional. * util/rust-hir-map.h: Adapt function prototype with the new return type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-17gccrs: Change lookup_node_to_hir return type to optionalPierre-Emmanuel Patry1-31/+37
Previous API was using a boolean and a pointer, this was not practical and could be replaced with an optional. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Change call to use the returned optional. (CompileExpr::generate_closure_function): Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::visit): Likewise. (MarkLive::visit_path_segment): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. (ResolveWhereClauseItem::visit): Likewise. * util/rust-hir-map.cc (Mappings::lookup_node_to_hir): Return an optional instead of a boolean. * util/rust-hir-map.h: Change function prototype to match the new return type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-17gccrs: Improve matching on non-enum ADTsOwen Avery1-0/+2
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (check_match_scrutinee): Add assertion. * backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): Handle HIR::PathInExpression matching a non-enum. gcc/testsuite/ChangeLog: * rust/compile/match-struct-path.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-17gccrs: Handle structs as scrutinee for match expressionsNobel Singh1-2/+2
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (check_match_scrutinee): Handle structs Signed-off-by: Nobel Singh <nobel2073@gmail.com>
2025-03-17gccrs: Remove unused Context parameter for some backend methodsOwen Avery1-3/+3
gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_function_body): Adjust unit_expression calls. (HIRCompileBase::unit_expression): Remove unused Context parameter. * backend/rust-compile-base.h (HIRCompileBase::unit_expression): Likewise. * backend/rust-compile-block.cc (CompileBlock::visit): Adjust unit_expression calls. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-pattern.cc (CompilePatternLet::visit): Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::attempt_constructor_expression_lookup): Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::get_implicit_enumeral_node_type): Remove unused Context parameter. (TyTyResolveCompile::get_unit_type): Likewise. (TyTyResolveCompile::visit): Adjust get_implicit_enumeral_node_type and get_unit_type calls. * backend/rust-compile-type.h (TyTyResolveCompile::get_implicit_enumeral_node_type): Remove unused Context parameter. (TyTyResolveCompile::get_unit_type): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-17gccrs: Change singleton returned type to a referencePierre-Emmanuel Patry1-11/+11
We do not need a raw pointer for this singleton, nor we need having it on the heap through a smart pointer. gcc/rust/ChangeLog: * ast/rust-ast.h: Change dereference from a pointer to a reference accessor. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address): Likewise. * backend/rust-compile-context.h: Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. (CompileExpr::generate_closure_function): Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-intrinsic.cc (Intrinsics::compile): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Likewise. (HIRCompileBase::query_compile): Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. (TyTyResolveCompile::create_dyn_obj_record): Likewise. * backend/rust-compile.cc (HIRCompileBase::coerce_to_dyn_object): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. (v0_mangle_item): Likewise. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Likewise. * checks/errors/privacy/rust-privacy-check.cc (Resolver::resolve): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::ConstChecker): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::UnsafeChecker): Likewise. * checks/lints/rust-lint-marklive-base.h: Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise. (MarkLive::visit): Likewise. (MarkLive::visit_path_segment): Likewise. * checks/lints/rust-lint-marklive.h: Likewise. * checks/lints/rust-lint-scan-deadcode.h: Likewise. * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Likewise. * expand/rust-macro-expand.h (struct MacroExpander): Change mapping from pointer to a reference. * expand/rust-proc-macro.cc (BangProcMacro::BangProcMacro): Replace pointer accessor with reference accessor. (AttributeProcMacro::AttributeProcMacro): Likewise. (CustomDeriveProcMacro::CustomDeriveProcMacro): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_lifetime): Likewise. (ASTLoweringBase::lower_loop_label): Likewise. (ASTLoweringBase::lower_path_expr_seg): Likewise. (ASTLoweringBase::lower_self): Likewise. (ASTLoweringBase::handle_lang_item_attribute): Likewise. (ASTLoweringBase::lower_extern_block): Likewise. (ASTLoweringBase::lower_macro_definition): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-block.h: Likewise. * hir/rust-ast-lower-enumitem.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise. (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-extern.h: Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate): Likewise. (ASTLowerImplItem::visit): Likewise. (ASTLowerTraitItem::translate): Likewise. (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise. (ASTLoweringItem::visit): Likewise. (ASTLoweringSimplePath::lower): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Likewise. (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::translate): Likewise. (ASTLoweringStmt::visit): Likewise. * hir/rust-ast-lower-struct-field-expr.h: Likewise. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise. (ASTLowerQualifiedPathInType::visit): Likewise. (ASTLoweringType::translate): Likewise. (ASTLoweringType::visit): Likewise. (ASTLowerGenericParam::translate): Likewise. (ASTLowerGenericParam::visit): Likewise. (ASTLoweringTypeBounds::translate): Likewise. (ASTLoweringTypeBounds::visit): Likewise. (ASTLowerWhereClauseItem::translate): Likewise. (ASTLowerWhereClauseItem::visit): Likewise. * hir/rust-ast-lower.cc (ASTLowering::go): Likewise. (ASTLoweringBlock::visit): Likewise. (ASTLoweringIfBlock::visit): Likewise. (ASTLoweringIfLetBlock::visit): Likewise. (ASTLowerStructExprField::visit): Likewise. (ASTLoweringExprWithBlock::visit): Likewise. (ASTLowerPathInExpression::visit): Likewise. (ASTLoweringBase::lower_qual_path_type): Likewise. (ASTLowerQualPathInExpression::visit): Likewise. * metadata/rust-export-metadata.cc (ExportContext::emit_trait): Likewise. (ExportContext::emit_function): Likewise. (ExportContext::emit_macro): Likewise. (PublicInterface::PublicInterface): Likewise. (PublicInterface::expected_metadata_filename): Likewise. * metadata/rust-export-metadata.h: Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::visit): Likewise. (ResolveExternItem::visit): Likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. (ResolveTypeToCanonicalPath::visit): Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-ast-resolve.cc (NameResolution::NameResolution): Likewise. (NameResolution::go): Likewise. * resolve/rust-ast-resolve.h: Likewise. * resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::EarlyNameResolver): Likewise. * resolve/rust-late-name-resolver-2.0.cc (next_node_id): Likewise. (next_hir_id): Likewise. * resolve/rust-name-resolution-context.cc (NameResolutionContext::NameResolutionContext): Likewise. * resolve/rust-name-resolver.cc (Resolver::Resolver): Likewise. (Resolver::generate_builtins): Likewise. (Resolver::setup_builtin): Likewise. * resolve/rust-name-resolver.h: Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. (TopLevel::handle_use_glob): Likewise. * rust-session-manager.cc (Session::get_instance): Likewise. (Session::handle_input_files): Likewise. (Session::handle_crate_name): Likewise. (Session::compile_crate): Likewise. (Session::load_extern_crate): Likewise. * rust-session-manager.h: Likewise. * typecheck/rust-autoderef.cc (Adjuster::try_unsize_type): Likewise. * typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Likewise. (TypeCoercionRules::coerce_unsafe_ptr): Likewise. (TypeCoercionRules::coerce_borrowed_pointer): Likewise. (TypeCoercionRules::coerce_unsized): Likewise. * typecheck/rust-coercion.h: Likewise. * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): Likewise. * typecheck/rust-hir-inherent-impl-overlap.h: Likewise. * typecheck/rust-hir-path-probe.cc (PathProbeType::process_enum_item_for_candiates): Likewise. (PathProbeType::process_impl_items_for_candidates): Likewise. (PathProbeImplTrait::process_trait_impl_items_for_candidates): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. (TraitItemReference::get_parent_trait_mappings): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): Likewise. (TypeCheckBase::get_marker_predicate): Likewise. * typecheck/rust-hir-type-check-base.h: Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_operator_overload): Likewise. (TypeCheckExpr::resolve_fn_trait_call): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): Likewise. (TypeCheckExpr::resolve_segments): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::emit_pattern_size_error): Likewise. (ClosureParamInfer::Resolve): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Likewise. (TypeCheckType::resolve_root_path): Likewise. (TypeResolveGenericParam::visit): Likewise. (ResolveWhereClauseItem::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * typecheck/rust-typecheck-context.cc (TypeCheckContext::compute_inference_variables): Likewise. * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Likewise. (TypeBoundsProbe::assemble_builtin_candidate): Likewise. (TypeCheckBase::get_predicate_from_bound): Likewise. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise. (TypeCheckMethodCallExpr::check): Likewise. * typecheck/rust-tyty-call.h: Likewise. * typecheck/rust-tyty-cmp.h: Likewise. * typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::override_context): Likewise. (SubstitutionRef::monomorphize): Likewise. * typecheck/rust-tyty-util.cc (TyVar::get_implicit_infer_var): Likewise. (TyVar::monomorphized_clone): Likewise. (TyWithLocation::TyWithLocation): Likewise. * typecheck/rust-tyty.cc (BaseType::satisfies_bound): Likewise. (InferType::clone): Likewise. (ADTType::handle_substitions): Likewise. (TupleType::handle_substitions): Likewise. (FnType::handle_substitions): Likewise. (ClosureType::setup_fn_once_output): Likewise. (ArrayType::handle_substitions): Likewise. (SliceType::handle_substitions): Likewise. (ReferenceType::handle_substitions): Likewise. (PointerType::handle_substitions): Likewise. (ParamType::handle_substitions): Likewise. * typecheck/rust-tyty.h: Likewise. * typecheck/rust-unify.cc (UnifyRules::UnifyRules): Likewise. (UnifyRules::commit): Likewise. * util/rust-hir-map.cc: Change getter return type to a reference. * util/rust-hir-map.h: Update function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-17gccrs: Removed obsolete objectsKushal Pal1-11/+2
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Lines removed as the objects are unused. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2025-01-02Update copyright years.Jakub Jelinek1-1/+1
2024-11-27diagnostics: replace %<%s%> with %qs [PR104896]David Malcolm1-2/+2
No functional change intended. gcc/analyzer/ChangeLog: PR c/104896 * sm-malloc.cc: Replace "%<%s%>" with "%qs" in message wording. gcc/c-family/ChangeLog: PR c/104896 * c-lex.cc (c_common_lex_availability_macro): Replace "%<%s%>" with "%qs" in message wording. * c-opts.cc (c_common_handle_option): Likewise. * c-warn.cc (warn_parm_array_mismatch): Likewise. gcc/ChangeLog: PR c/104896 * common/config/ia64/ia64-common.cc (ia64_handle_option): Replace "%<%s%>" with "%qs" in message wording. * common/config/rs6000/rs6000-common.cc (rs6000_handle_option): Likewise. * config/aarch64/aarch64.cc (aarch64_validate_sls_mitigation): Likewise. (aarch64_override_options): Likewise. (aarch64_process_target_attr): Likewise. * config/arm/aarch-common.cc (aarch_validate_mbranch_protection): Likewise. * config/pru/pru.cc (pru_insert_attributes): Likewise. * config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::parse_arch): Likewise. * omp-general.cc (oacc_verify_routine_clauses): Likewise. * tree-ssa-uninit.cc (maybe_warn_read_write_only): Likewise. (maybe_warn_pass_by_reference): Likewise. gcc/cp/ChangeLog: PR c/104896 * cvt.cc (maybe_warn_nodiscard): Replace "%<%s%>" with "%qs" in message wording. gcc/fortran/ChangeLog: PR c/104896 * resolve.cc (resolve_operator): Replace "%<%s%>" with "%qs" in message wording. gcc/go/ChangeLog: PR c/104896 * gofrontend/embed.cc (Gogo::initializer_for_embeds): Replace "%<%s%>" with "%qs" in message wording. * gofrontend/expressions.cc (Selector_expression::lower_method_expression): Likewise. * gofrontend/gogo.cc (Gogo::set_package_name): Likewise. (Named_object::export_named_object): Likewise. * gofrontend/parse.cc (Parse::struct_type): Likewise. (Parse::parameter_list): Likewise. gcc/rust/ChangeLog: PR c/104896 * backend/rust-compile-expr.cc (CompileExpr::compile_integer_literal): Replace "%<%s%>" with "%qs" in message wording. (CompileExpr::compile_float_literal): Likewise. * backend/rust-compile-intrinsic.cc (Intrinsics::compile): Likewise. * backend/rust-tree.cc (maybe_warn_nodiscard): Likewise. * checks/lints/rust-lint-scan-deadcode.h: Likewise. * lex/rust-lex.cc (Lexer::parse_partial_unicode_escape): Likewise. (Lexer::parse_raw_byte_string): Likewise. * lex/rust-token.cc (Token::get_str): Likewise. * metadata/rust-export-metadata.cc (PublicInterface::write_to_path): Likewise. * parse/rust-parse.cc (peculiar_fragment_match_compatible_fragment): Likewise. (peculiar_fragment_match_compatible): Likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. * rust-session-manager.cc (validate_crate_name): Likewise. (Session::load_extern_crate): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_fn_trait_call): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItemWithTrait::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::validate_trait_impl_block): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): Likewise. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise. * typecheck/rust-tyty.cc (BaseType::bounds_compatible): Likewise. * typecheck/rust-unify.cc (UnifyRules::emit_abi_mismatch): Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. libcpp/ChangeLog: PR c/104896 * pch.cc (cpp_valid_state): Replace "%<%s%>" with "%qs" in message wording. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-08-01gccrs: backend: Use new name resolver where necessaryArthur Cohen1-5/+17
gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Use new ImmutableNrCtx. * backend/rust-compile-context.h: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-item.cc: Likewise.
2024-08-01gccrs: lang-items: Make lang items enum stronger, rename class, cleanup ns.Arthur Cohen1-13/+11
gcc/rust/ChangeLog: * util/rust-lang-item.h (class RustLangItem): Renamed to... (class LangItem): ...this. Rename ItemType enum to Kind * util/rust-lang-item.cc: Rename methods to use new class name. * backend/rust-compile-expr.cc (CompileExpr::visit): Use new lang-item API. (CompileExpr::resolve_operator_overload): Likewise. * backend/rust-compile-expr.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Likewise. * typecheck/rust-autoderef.cc (Adjuster::try_deref_type): Likewise. (AutoderefCycle::cycle): Likewise. * typecheck/rust-autoderef.h: Likewise. * typecheck/rust-hir-type-bounds.h: Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): Likewise. * typecheck/rust-hir-type-check-base.h: Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise. * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise. * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): Likewise. (TypeBoundsProbe::assemble_builtin_candidate): Likewise. (TypeCheckBase::get_predicate_from_bound): Likewise. * typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise. * util/rust-hir-map.cc (Mappings::get_lang_item): Likewise. (Mappings::lookup_trait_item_lang_item): Likewise. * util/rust-hir-map.h: Likewise.
2024-01-30gccrs: TyTy: Refactor FnType deprecated APIJakub Dupak1-1/+1
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Use new API. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Use new API. * typecheck/rust-tyty-cmp.h: Remove old API. * typecheck/rust-tyty.cc (FnPtr::is_equal): Use new API. * typecheck/rust-tyty.h: Remove old API. * typecheck/rust-unify.cc (UnifyRules::expect_fnptr): Use new API. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-30gccrs: Remove backend dependancy on resolution rib informationPhilip Herron1-4/+1
When making more desugaring for the HIR we can need to add new Let bindings which will require namesolution information but also rib information for which block the let binding is associated which was very unnessecary. This patch simply updates the BLOCK_CONTEXT of the current scope as we are compiling and encounter HIR::LetStmts instead of trying to do it all upfront which lots of wierd checks gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_locals_for_block): removed * backend/rust-compile-base.h: update header * backend/rust-compile-block.cc (CompileBlock::visit): remove old logic * backend/rust-compile-expr.cc (CompileExpr::generate_closure_function): likewise * backend/rust-compile-stmt.cc (CompileStmt::visit): likewise * backend/rust-compile-var-decl.h: ensure we setup tuple bindings correctly Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: v0-mangle closuresRaiki Tamura1-1/+5
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::generate_closure_function): Fix reference to node. * backend/rust-mangle.cc (struct V0Path): Modified to accept closures. (v0_crate_path): Modified to accept closures. (v0_closure): New function to mangle closures. (v0_path): Modified to accept closures * util/rust-mapping-common.h (UNKNOWN_NODEID): Change to UINT32_MAX. (UNKNOWN_HIRID): Change to UINT32_MAX. gcc/testsuite/ChangeLog: * rust/compile/v0-mangle2.rs: New test. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: Compile pattern match statements into conditional statementsOwen Avery1-458/+36
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (patterns_mergeable): Remove. (struct PatternMerge): Remove. (sort_tuple_patterns): Remove. (simplify_tuple_match): Remove. (CompileExpr::visit): Modify compilation of MatchExpr. * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Replace with... (CompilePatternCheckExpr::visit): ...this. * backend/rust-compile-pattern.h (class CompilePatternCaseLabelExpr): Replace with... (class CompilePatternCheckExpr): ...this. * backend/rust-compile-type.cc (TyTyResolveCompile::get_implicit_enumeral_node_type): Make enumeral type equivalent to isize. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: hir: Rename ComoundAssignment gettersJakub Dupak1-4/+4
Use more a consistent name. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Rename method. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Rename method. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Rename method. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Rename method. * hir/rust-hir-dump.cc (Dump::visit): Rename method. * hir/tree/rust-hir-expr.h: Rename method. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Rename method. * typecheck/rust-tyty.h: Rename method.
2024-01-16gccrs: hir: Rename get_pattern_mappings methodJakub Dupak1-1/+1
Unify with the name used in Expr to allow convenient template over everything that has mappings. gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Rename method. * backend/rust-compile-expr.cc (sort_tuple_patterns): Rename method. * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Rename method. (CompilePatternBindings::visit): Rename method. (CompilePatternLet::visit): Rename method. * backend/rust-compile-stmt.cc (CompileStmt::visit): Rename method. * backend/rust-compile-var-decl.h: Rename method. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Rename method. * hir/rust-hir-dump.cc (Dump::visit): Rename method. * hir/tree/rust-hir-path.h: Rename method. * hir/tree/rust-hir-pattern.h: Rename method. * hir/tree/rust-hir.h: Rename method. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::Resolve): Rename method. (TypeCheckPattern::visit): Rename method. (ClosureParamInfer::visit): Rename method. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Rename method. * util/rust-hir-map.cc (Mappings::insert_hir_pattern): Rename method. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: compile: bail on labelled blockJakub Dupak1-0/+6
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Bail on labelled block. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Adjust methods for TuplePatternItems to match TupleStructItemsOwen Avery1-1/+1
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (TuplePatternItems::get_pattern_type): Rename to... (TuplePatternItems::get_item_type): ...here. (TuplePatternItemsMultiple::get_pattern_type): Rename to... (TuplePatternItemsMultiple::get_item_type): ...here. (TuplePatternItemsRanged::get_pattern_type): Rename to... (TuplePatternItemsRanged::get_item_type): ...here. * backend/rust-compile-expr.cc: Adjust calls to renamed methods. * backend/rust-compile-pattern.cc: Likewise. * typecheck/rust-hir-type-check-pattern.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: minor changes (typo and minor refactor)Marc Poulhiès1-6/+2
Fix a typo and merge 2 if clauses using the same condition. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Merge 2 if clauses. * backend/rust-compile-extern.h: Fix typo in comment. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Fix spellingOwen Avery1-2/+2
gcc/rust/ChangeLog: * ast/rust-expr.h: Fix spelling of "doesn't". * backend/rust-compile-expr.cc: Fix spelling of "accessors". * backend/rust-compile-implitem.h: Fix spelling of "normal". * backend/rust-constexpr.cc: Fix spelling of "actual". Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Minor typo fixMarc Poulhiès1-3/+3
Fix varadic -> variadic gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Fix typo in varIadic. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. * rust-backend.h (function_type_varadic): Rename into ... (function_type_variadic): ... this. * rust-gcc.cc (function_type_varadic): Rename into ... (function_type_variadic): ... this. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise. * typecheck/rust-tyty.h (is_varadic): Renamed into ... (is_variadic): ... this. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Convert class Backend into namespaceOwen Avery1-217/+176
gcc/rust/ChangeLog: * rust-backend.h (class Backend): Convert to ... (namespace Backend): ... namespace. * rust-gcc.cc (Backend::Backend): Rename to ... (Backend::init): ... here. (rust_get_backend): Remove. * rust-session-manager.cc (rust_get_backend): Remove. (Session::init): Use Backend::init instead of rust_get_backend. (Session::compile_crate): Initialize Context without pointer to Backend. * rust-session-manager.h (Session::backend): Remove. * backend/rust-compile-context.cc (Context::Context): Remove pointer to Backend. * backend/rust-compile-context.h (class Context): Remove pointer to Backend, update function calls. * backend/rust-compile-base.cc: Update function calls. * backend/rust-compile-block.cc: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-fnparam.cc: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-item.cc: Likewise. * backend/rust-compile-pattern.cc: Likewise. * backend/rust-compile-resolve-path.cc: Likewise. * backend/rust-compile-type.cc: Likewise. * backend/rust-compile-var-decl.h: Likewise. * backend/rust-compile.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Fix match-expression code-genPhilip Herron1-1/+15
We were massing the match scruitinee expression as a way to access the result of the expression. This is wrong and needs to be stored in a temporary otherwise it will cause the code to be regnerated for each time it is used. This is not an issue in the case where the expression is only used once. Fixes #1895 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): use a temp for the value gcc/testsuite/ChangeLog: * rust/execute/torture/iter1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Continue to replace usages of Location with location_tOwen Avery1-1/+1
gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Replace Location with location_t. * backend/rust-compile-base.h: Likewise. * backend/rust-compile-expr.cc: Likewise. * lex/rust-token.h: Likewise. * metadata/rust-import-archive.cc: Likewise. * metadata/rust-imports.cc: Likewise. * metadata/rust-imports.h: Likewise. * rust-backend.h: Likewise. * rust-diagnostics.cc: Likewise. * rust-diagnostics.h: Likewise. * rust-gcc.cc: Likewise. * rust-linemap.cc: Likewise. * util/rust-token-converter.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Replace Location with location_t in gccrs backendOwen Avery1-21/+21
gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Replace Location with location_t. * backend/rust-compile-base.h: Likewise. * backend/rust-compile-block.cc: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-expr.h: 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-pattern.h: Likewise. * backend/rust-compile-resolve-path.cc: Likewise. * backend/rust-compile-stmt.cc: Likewise. * backend/rust-compile-type.cc: Likewise. * backend/rust-compile.cc: Likewise. * backend/rust-constexpr.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Replace some usages of Location with location_tOwen Avery1-6/+6
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc: Replace Location with location_t. * ast/rust-ast.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.cc: Likewise. * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. * ast/rust-stmt.h: Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-base.cc: Likewise. * backend/rust-compile-base.h: Likewise. * backend/rust-compile-block.cc: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-expr.h: Likewise. * backend/rust-compile-fnparam.cc: Likewise. * backend/rust-compile-fnparam.h: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-pattern.cc: Likewise. * backend/rust-compile-resolve-path.h: Likewise. * backend/rust-compile.cc: Likewise. * checks/errors/rust-const-checker.cc: Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-unsafe-checker.cc: Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * expand/rust-macro-builtins.cc: Likewise. * expand/rust-macro-expand.h: Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-implitem.h: Likewise. * hir/rust-ast-lower-item.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-pattern.h: Likewise. * hir/tree/rust-hir-stmt.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.cc: Likewise. * hir/tree/rust-hir.h: Likewise. * lex/rust-token.h: Likewise. * metadata/rust-extern-crate.cc: Likewise. * metadata/rust-extern-crate.h: Likewise. * parse/rust-parse-impl.h: Likewise. * parse/rust-parse.h: Likewise. * resolve/rust-ast-resolve-expr.cc: Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-pattern.h: Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-name-resolver.cc: Likewise. * resolve/rust-name-resolver.h: Likewise. * rust-diagnostics.cc: Likewise. * rust-diagnostics.h: Likewise. * rust-gcc.cc: Likewise. * rust-session-manager.cc: Likewise. * rust-session-manager.h: Likewise. * typecheck/rust-casts.cc: Likewise. * typecheck/rust-casts.h: Likewise. * typecheck/rust-coercion.cc: Likewise. * typecheck/rust-coercion.h: Likewise. * typecheck/rust-hir-path-probe.cc: Likewise. * typecheck/rust-hir-path-probe.h: Likewise. * typecheck/rust-hir-trait-reference.cc: Likewise. * typecheck/rust-hir-trait-reference.h: Likewise. * typecheck/rust-hir-trait-resolve.cc: Likewise. * typecheck/rust-hir-type-check-base.cc: Likewise. * typecheck/rust-hir-type-check-base.h: Likewise. * typecheck/rust-hir-type-check-item.cc: Likewise. * typecheck/rust-hir-type-check-item.h: Likewise. * typecheck/rust-hir-type-check-path.cc: Likewise. * typecheck/rust-hir-type-check-pattern.cc: Likewise. * typecheck/rust-hir-type-check-pattern.h: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-hir-type-check-type.h: Likewise. * typecheck/rust-hir-type-check.cc: Likewise. * typecheck/rust-hir-type-check.h: Likewise. * typecheck/rust-substitution-mapper.cc: Likewise. * typecheck/rust-substitution-mapper.h: Likewise. * typecheck/rust-type-util.cc: Likewise. * typecheck/rust-typecheck-context.cc: Likewise. * typecheck/rust-tyty-bounds.cc: Likewise. * typecheck/rust-tyty-call.h: Likewise. * typecheck/rust-tyty-subst.cc: Likewise. * typecheck/rust-tyty-subst.h: Likewise. * typecheck/rust-tyty-util.cc: Likewise. * typecheck/rust-tyty-util.h: Likewise. * typecheck/rust-tyty.cc: Likewise. * typecheck/rust-tyty.h: Likewise. * typecheck/rust-unify.cc: Likewise. * typecheck/rust-unify.h: Likewise. * util/rust-hir-map.cc: Likewise. * util/rust-hir-map.h: Likewise. * util/rust-identifier.h: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: rust-unreachable: Add specific behavior for rust_unreachableArthur Cohen1-6/+6
As discussed during the community call, rust_unreachable() should always trigger an internal compiler error and should not offer the behavior of __builtin_unreachable when asserts are disabled, unlike gcc_unreachable(). gcc/rust/ChangeLog: * rust-system.h (rust_unreachable): Change definition to fancy_abort * ast/rust-ast-collector.cc (TokenCollector::visit): Use rust_unreachable instead of gcc_unreachable. (get_delimiters): Likewise. * ast/rust-ast-dump.h: Likewise. * ast/rust-ast-formatting.cc (get_string_in_delims): Likewise. (get_mode_dump_desc): Likewise. * ast/rust-ast.cc (Visibility::as_string): Likewise. (UseTreeGlob::as_string): Likewise. * ast/rust-ast.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * backend/rust-compile-expr.cc (sort_tuple_patterns): Likewise. (CompileExpr::visit): Likewise. (CompileExpr::generate_closure_fntype): Likewise. * backend/rust-compile-intrinsic.cc (op_with_overflow_inner): Likewise. * backend/rust-compile-pattern.cc (CompilePatternBindings::visit): Likewise. (CompilePatternLet::visit): Likewise. * backend/rust-constexpr.cc (base_field_constructor_elt): Likewise. (eval_array_reference): Likewise. (label_matches): Likewise. (eval_store_expression): Likewise. (eval_call_expression): Likewise. (build_data_member_initialization): Likewise. (array_index_cmp): Likewise. (get_array_or_vector_nelts): Likewise. (eval_bit_field_ref): Likewise. (eval_loop_expr): Likewise. (potential_constant_expression_1): Likewise. * backend/rust-mangle.cc (v0_simple_type_prefix): Likewise. (v0_type_prefix): Likewise. (v0_mangle_item): Likewise. (Mangler::mangle_item): Likewise. * backend/rust-tree.cc (convert_to_void): Likewise. (type_memfn_quals): Likewise. (rs_tree_equal): Likewise. (fold_offsetof): Likewise. (fold_builtin_source_location): Likewise. (lvalue_error): Likewise. * backend/rust-tree.h (struct named_decl_hash): Likewise. (struct named_label_hash): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_visibility): Likewise. (VisibilityResolver::visit): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::ctx_to_str): Likewise. * checks/errors/rust-feature.cc (Feature::create): Likewise. * expand/rust-expand-visitor.cc (get_traits_to_derive): Likewise. (derive_item): Likewise. (expand_item_attribute): Likewise. (expand_stmt_attribute): Likewise. * expand/rust-macro-expand.cc (MacroExpander::match_matcher): Likewise. (MacroExpander::match_repetition): Likewise. (transcribe_context): Likewise. (MacroExpander::import_proc_macros): Likewise. (MacroExpander::parse_proc_macro_output): Likewise. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-invoc-lexer.h: Likewise. * expand/rust-macro-substitute-ctx.cc (SubstituteCtx::substitute_token): Likewise. * expand/rust-proc-macro-invoc-lexer.h: Likewise. * expand/rust-proc-macro.cc (load_macros): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_generic_args): Likewise. (ASTLoweringBase::lower_literal): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower-type.cc (ASTLoweringType::visit): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/tree/rust-hir.cc (get_string_in_delims): Likewise. (Visibility::as_string): Likewise. (UseTreeGlob::as_string): Likewise. (CompoundAssignmentExpr::as_string): Likewise. (ArithmeticOrLogicalExpr::as_string): Likewise. * lex/rust-lex.cc (Lexer::parse_byte_string): Likewise. (Lexer::parse_string): Likewise. * lex/rust-token.cc (RS_TOKEN): Likewise. * parse/rust-parse-impl.h (Parser::parse_simple_path_segment): Likewise. (Parser::parse_path_ident_segment): Likewise. (Parser::parse_attr_input): Likewise. (Parser::parse_inherent_impl_item): Likewise. (Parser::parse_trait_impl_item): Likewise. (Parser::parse_type_path_segment): Likewise. (Parser::parse_reference_type): Likewise. (get_lbp_for_comparison_expr): Likewise. * parse/rust-parse.cc (peculiar_fragment_match_compatible): Likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. (ResolveTypeToCanonicalPath::visit): Likewise. (ResolveGenericArgs::resolve_disambiguated_generic): Likewise. * rust-gcc.cc (operator_to_tree_code): Likewise. (fetch_overflow_builtins): Likewise. (Gcc_backend::non_zero_size_type): Likewise. (Gcc_backend::convert_tree): Likewise. * rust-lang.cc (grs_langhook_type_for_mode): Likewise. (grs_langhook_global_bindings_p): Likewise. (grs_langhook_pushdecl): Likewise. (grs_langhook_getdecls): Likewise. (convert): Likewise. * typecheck/rust-autoderef.h: Likewise. * typecheck/rust-hir-path-probe.cc: Likewise. * typecheck/rust-hir-trait-reference.cc (TraitItemReference::get_tyty): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): Likewise. * typecheck/rust-hir-type-check-expr.cc: Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise. * typecheck/rust-hir-type-check-stmt.h: Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-substitution-mapper.h: Likewise. * typecheck/rust-typecheck-context.cc (TypeCheckContextItem::get_context_type): Likewise. * typecheck/rust-tyty-call.h: Likewise. * typecheck/rust-tyty.cc (TypeKindFormat::to_string): Likewise. (BaseType::monomorphized_clone): Likewise. (VariantDef::variant_type_string): Likewise. (ClosureType::handle_substitions): Likewise. (IntType::as_string): Likewise. (UintType::as_string): Likewise. (FloatType::as_string): Likewise. * typecheck/rust-unify.cc (UnifyRules::expect_projection): Likewise. * util/rust-token-converter.cc (convert): Likewise. (from_literal): Likewise. (from_group): Likewise. (from_tokentree): Likewise.
2024-01-16gccrs: Replace value initialization of Location with UNDEF_LOCATIONOwen Avery1-1/+1
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 <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Change class Location into typedefOwen Avery1-18/+15
gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::address_expression): Remove gcc_location method call. (HIRCompileBase::indirect_expression): Likewise. (HIRCompileBase::compile_constant_item): Likewise. (HIRCompileBase::named_constant_expression): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Remove gcc_location method call, use UNKNOWN_LOCATION to initialize. (CompileExpr::get_fn_addr_from_dyn): Remove gcc_location method call. (CompileExpr::type_cast_expression): Likewise. * backend/rust-compile-intrinsic.cc (transmute_handler): Replace "Location ().gcc_location ()" with UNKNOWN_LOCATION. (copy_nonoverlapping_handler): Likewise. (prefetch_data_handler): Likewise. (atomic_store_handler_inner): Likewise. (atomic_load_handler_inner): Likewise. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Remove gcc_location method call. * rust-diagnostics.cc (rust_be_error_at): Likewise. (rust_be_warning_at): Likewise. (rust_be_fatal_error): Likewise. (rust_be_inform): Likewise. * rust-diagnostics.h (rust_sorry_at): Likewise. * rust-gcc.cc (Bvariable::get_tree): Likewise. (Gcc_backend::fill_in_fields): Likewise. (Gcc_backend::named_type): Likewise. (Gcc_backend::real_part_expression): Likewise. (Gcc_backend::imag_part_expression): Likewise. (Gcc_backend::complex_expression): Likewise. (Gcc_backend::convert_expression): Likewise. (Gcc_backend::struct_field_expression): Likewise. (Gcc_backend::compound_expression): Likewise. (Gcc_backend::conditional_expression): Likewise. (Gcc_backend::negation_expression): Likewise. (Gcc_backend::arithmetic_or_logical_expression): Likewise. (Gcc_backend::arithmetic_or_logical_expression_checked): Likewise. (Gcc_backend::comparison_expression): Likewise. (Gcc_backend::lazy_boolean_expression): Likewise. (Gcc_backend::constructor_expression): Likewise. (Gcc_backend::array_constructor_expression): Likewise. (Gcc_backend::array_initializer): Likewise. (Gcc_backend::array_index_expression): Likewise. (Gcc_backend::call_expression): Likewise. (Gcc_backend::assignment_statement): Likewise. (Gcc_backend::return_statement): Likewise. (Gcc_backend::exception_handler_statement): Likewise. (Gcc_backend::if_statement): Likewise. (Gcc_backend::loop_expression): Likewise. (Gcc_backend::exit_expression): Likewise. (Gcc_backend::block): Likewise. (Gcc_backend::convert_tree): Likewise. (Gcc_backend::global_variable): Likewise. (Gcc_backend::local_variable): Likewise. (Gcc_backend::parameter_variable): Likewise. (Gcc_backend::static_chain_variable): Likewise. (Gcc_backend::temporary_variable): Likewise. (Gcc_backend::label): Likewise. (Gcc_backend::goto_statement): Likewise. (Gcc_backend::label_address): Likewise. (Gcc_backend::function): Likewise. * rust-linemap.cc (Gcc_linemap::to_string): Likewise. (Gcc_linemap::location_file): Likewise. (Gcc_linemap::location_line): Likewise. (Gcc_linemap::location_column): Likewise. (Gcc_linemap::is_predeclared): Likewise. (Gcc_linemap::is_unknown): Likewise. (RichLocation::RichLocation): Likewise. (RichLocation::add_range): Likewise. (RichLocation::add_fixit_insert_before): Likewise. (RichLocation::add_fixit_insert_after): Likewise. * rust-location.h (class Location): Replace with typedef. (operator<): Remove. (operator==): Remove. (operator+): Remove. (operator-): Remove. * typecheck/rust-hir-trait-resolve.cc (AssociatedImplTrait::setup_associated_types): Initialize Location with UNKNOWN_LOCATION. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. * util/rust-token-converter.cc (convert): Remove gcc_location method call. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: HIR cleanupMarc Poulhiès1-4/+6
Some more HIR cleanup. gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h (BorrowExpr::is_double_borrow): New. (ArrayElemsCopied::get_elem_to_copy) (ArrayElemsCopied::get_num_copies_expr): Return unique_ptr. (CallExpr::get_fnexpr): Likewise. (ReturnExpr::get_expr): Likewise. (StructExprStructFields::get_struct_base): New. (MethodCallExpr::has_params): New. (ClosureExpr::has_params): New. (BlockExpr::get_inner_attrs): New. (WhileLoopExpr::get_patterns): New. (ForLoopExpr::get_pattern): New. (IfLetExpr::get_if_block): Return ref to unique_ptr. (IfLetExprConseqElse::get_else_block): Likewise. (MatchExpr::get_inner_attrs): New. * hir/tree/rust-hir-item.h (Module::get_module_name): New. (ExternCrate::get_referenced_crate) (ExternCrate::get_as_clause_name): New. (UseTreeGlob::get_glob_type, UseTreeGlob::get_path): New. (UseTreeList::get_path_type, UseTreeList::get_path) (UseTreeList::get_trees): New. (TraitItemKind::get_expr): Remove assert. unique_ptr can be "empty". Must be checked in caller. * hir/tree/rust-hir-pattern.h (IdentifierPattern::get_is_ref) (IdentifierPattern::get_to_bind): New. (RangePatternBoundType::get_has_minus): New. (RangePattern::get_has_ellipsis_syntax): New. (StructPatternField::get_outer_attrs): New. (StructPatternFieldTuplePat::get_index) (StructPatternFieldTuplePat::get_tuple_pattern): New. (StructPatternFieldIdent::get_has_ref): New. * hir/tree/rust-hir-stmt.h (LetStmt::get_outer_attrs): New. (LetStmt::get_type) (LetStmt::get_init_expr, LetStmt::get_pattern): Return unique_ptr. (ExprStmt::get_expr): Likewise. * hir/tree/rust-hir-type.h (TraitBound::get_for_lifetimes): New. (TraitBound::get_in_params): New. (TraitBound::get_opening_question_mark): New. (ImplTraitType::get_type_param_bounds): New. (TraitObjectType::get_has_dyn): New. (TraitBound::get_type_in_parens): New. (ImplTraitTypeOneBound::get_trait_bound): New. (BareFunctionType::get_for_lifetimes) (BareFunctionType::get_is_variadic) (BareFunctionType::get_function_qualifiers): New. * hir/tree/rust-hir.h (class Expr): Virtual inherit from FullVisitable. (class Pattern): Likewise. (ConstGenericParam::get_name): New. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Adjust call. (TypeCheckExpr::resolve_fn_trait_call): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Adjust call. (CompileExpr::array_copied_expr): Likewise. (CompileExpr::generate_possible_fn_trait_call): Likewise. * backend/rust-compile-stmt.cc (CompileStmt::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: fix ICE with inserting autoderef mappingsPhilip Herron1-1/+2
We were using the call-expr id for the autoderef mappings but this doesn't work when the call expression itself is part of a coercion-site so this changes the code to use the call-expression function path expression for the id instead which will not be duplicated again. Addresses #2105 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::generate_possible_fn_trait_call): use fnexpr * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::resolve_fn_trait_call): likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: cleanup getters to return &unique_ptr instead of pointerMarc Poulhiès1-13/+15
Make all getter methods in HIR classes return a unique_ptr reference instead of a pointer and adjust all callers. gcc/rust/ChangeLog: * hir/tree/rust-hir-type.h (ArrayType::get_element_type): Returns unique_ptr. * hir/tree/rust-hir-expr.h (ArithmeticOrLogicalExpr::get_lhs) (ArithmeticOrLogicalExpr::get_rhs): Likewise. (ComparisonExpr::get_lhs, ComparisonExpr::get_rhs): Likewise. (LazyBooleanExpr::get_lhs, LazyBooleanExpr::get_rhs): Likewise. (AssignmentExpr::get_lhs, AssignmentExpr::get_rhs): Likewise. (ArrayExpr::get_internal_elements): Likewise. (ArrayIndexExpr::get_index_expr, ArrayIndexExpr::get_array_expr): Likewise. (StructExprFieldWithVal::get_value): Likewise. (IfExpr::get_if_condition, IfExpr::get_if_block): Likewise. (ExprWithBlock::get_else_block): Likewise. * hir/tree/rust-hir-item.h (FunctionParam::get_param_name) (FunctionParam::get_type): Likewise. (ConstantItem::get_type, ConstantItem::get_expr): Likewise. (StaticItem::get_expr, StaticItem::get_type): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Adjust for previous change. * backend/rust-compile-block.cc (CompileConditionalBlocks::visit): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-struct-field-expr.cc (CompileStructExprField::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: ast: Change Identifier definitionPierre-Emmanuel Patry1-4/+4
Change Identifier type definition from a simple typedef to a whole class with it's own node id. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Change with call to getter. * ast/rust-ast.cc (Module::as_string): Likewise. (StaticItem::as_string): Likewise. (TupleStruct::as_string): Likewise. (Method::as_string): Likewise. (StructStruct::as_string): Likewise. (UseTreeRebind::as_string): Likewise. (Enum::as_string): Likewise. (Trait::as_string): Likewise. (Union::as_string): Likewise. (Function::as_string): Likewise. (TypeAlias::as_string): Likewise. (MacroRulesDefinition::as_string): Likewise. (FieldAccessExpr::as_string): Likewise. (MacroMatchFragment::as_string): Likewise. (TypeParam::as_string): Likewise. (StructExprFieldIdentifierValue::as_string): Likewise. (EnumItem::as_string): Likewise. (StructField::as_string): Likewise. (ExternalTypeItem::as_string): Likewise. (ExternalStaticItem::as_string): Likewise. (ExternalFunctionItem::as_string): Likewise. (TraitFunctionDecl::as_string): Likewise. (TraitMethodDecl::as_string): Likewise. (TraitItemConst::as_string): Likewise. (TraitItemType::as_string): Likewise. (MaybeNamedParam::as_string): Likewise. (MetaListPaths::as_string): Likewise. (MetaListNameValueStr::as_string): Likewise. (Module::process_file_path): Likewise. (MetaListNameValueStr::check_cfg_predicate): Likewise. (MetaListPaths::check_cfg_predicate): Likewise. (MetaWord::check_cfg_predicate): Likewise. (MetaNameValueStr::check_cfg_predicate): Likewise. (MetaNameValueStr::to_attribute): Likewise. (MetaWord::to_attribute): Likewise. (MetaListPaths::to_attribute): Likewise. (MetaListNameValueStr::to_attribute): Likewise. (operator<<): Change Identifier class << operator overload for standard output stream. * ast/rust-ast.h (class Identifier): Change typedef to proper class definition. (operator<<): Add prototype for operator overload. (class Token): Change getter identifier. (class MetaListNameValueStr): Likewise. (class PathExpr): Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.cc (GenericArg::disambiguate_to_type): Likewise. (GenericArgsBinding::as_string): Likewise. (ConstGenericParam::as_string): Likewise. * ast/rust-path.h: Likewise. * ast/rust-pattern.cc (IdentifierPattern::as_string): Likewise. (StructPatternFieldIdentPat::as_string): Likewise. (StructPatternFieldIdent::as_string): Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-base.cc: Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-fnparam.cc (CompileFnParam::visit): Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-pattern.cc (CompilePatternBindings::visit): Likewise. * backend/rust-compile-struct-field-expr.cc (CompileStructExprField::visit): Likewise. * backend/rust-compile-var-decl.h: Likewise. * backend/rust-compile.cc: Likewise. * checks/errors/rust-unsafe-checker.cc (check_extern_call): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::visit): Likewise. * checks/lints/rust-lint-scan-deadcode.h: Likewise. * expand/rust-derive-clone.cc (DeriveClone::clone_fn): Likewise. (DeriveClone::visit_tuple): Likewise. (DeriveClone::visit_struct): Likewise. (DeriveClone::visit_union): Likewise. * expand/rust-derive-copy.cc (DeriveCopy::visit_struct): Likewise. (DeriveCopy::visit_tuple): Likewise. (DeriveCopy::visit_enum): Likewise. (DeriveCopy::visit_union): Likewise. * expand/rust-macro-expand.cc (MacroExpander::match_matcher): Likewise. (MacroExpander::match_n_matches): Likewise. (MacroExpander::match_repetition): Likewise. (MacroExpander::match_repetition_skipped_metavars): Likewise. * hir/rust-ast-lower-base.cc (struct_field_name_exists): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Likewise. * hir/rust-hir-dump.cc (Dump::visit): 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.cc (Module::as_string): Likewise. (StaticItem::as_string): Likewise. (TupleStruct::as_string): Likewise. (ConstantItem::as_string): Likewise. (StructStruct::as_string): Likewise. (UseTreeRebind::as_string): Likewise. (Enum::as_string): Likewise. (Trait::as_string): Likewise. (Union::as_string): Likewise. (Function::as_string): Likewise. (TypeAlias::as_string): Likewise. (FieldAccessExpr::as_string): Likewise. (TypeParam::as_string): Likewise. (GenericArgsBinding::as_string): Likewise. (StructPatternFieldIdent::as_string): Likewise. (StructPatternFieldIdentPat::as_string): Likewise. (IdentifierPattern::as_string): Likewise. (StructExprFieldIdentifierValue::as_string): Likewise. (EnumItem::as_string): Likewise. (StructField::as_string): Likewise. (ExternalStaticItem::as_string): Likewise. (ExternalFunctionItem::as_string): Likewise. (NamedFunctionParam::as_string): Likewise. (TraitFunctionDecl::as_string): Likewise. (TraitItemConst::as_string): Likewise. (TraitItemType::as_string): Likewise. (MaybeNamedParam::as_string): Likewise. * hir/tree/rust-hir.h: Likewise. * parse/rust-parse-impl.h (Parser::parse_macro_match_fragment): Likewise. (Parser::parse_module): Likewise. (Parser::parse_use_tree): Likewise. (Parser::parse_maybe_named_param): Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::visit): Likewise. (flatten_rebind): Likewise. (ResolveExternItem::visit): Likewise. (rust_flatten_rebind): Likewise. (rust_flatten_rebind_nested): Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go): Likewise. (PatternDeclaration::visit): Likewise. (PatternDeclaration::add_new_binding): Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * typecheck/rust-autoderef.cc: Likewise. * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): Likewise. * typecheck/rust-hir-path-probe.cc (PathProbeType::visit): Likewise. * typecheck/rust-hir-trait-reference.cc (TraitReference::get_name): Likewise. * typecheck/rust-hir-trait-resolve.cc (ResolveTraitItemToRef::visit): Likewise. (TraitResolver::resolve_trait): Likewise. (TraitItemReference::resolve_item): Likewise. (AssociatedImplTrait::setup_raw_associated_types): Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::visit): Likewise. (TypeCheckImplItemWithTrait::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-tyty-subst.cc (SubstitutionRef::get_mappings_from_generic_args): Likewise. * util/rust-attributes.cc (check_doc_attribute): Likewise. * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Fix ICE for reference patterns in match statementsDave Evans1-1/+8
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (check_match_scrutinee): Add REF type to rust_assert. (CompileExpr::visit): Add REF type for scrutinee_kind in MatchExpr visitor. gcc/testsuite/ChangeLog: * rust/compile/issue-1813.rs: New test. Signed-off-by: Dave Evans <dave@dmetwo.org>
2024-01-16gccrs: remove useless lookup to NodeIdPhilip Herron1-30/+3
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): remove unused Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: support deref cycles to resolve to trait itemsPhilip Herron1-9/+2
Fixes #2190 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (HIRCompileBase::resolve_deref_adjustment): reuse op overload code * typecheck/rust-autoderef.cc (Adjuster::try_deref_type): update (Adjuster::try_raw_deref_type): likewise * typecheck/rust-autoderef.h: likewise * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): improve debug loging gcc/testsuite/ChangeLog: * rust/compile/issue-2190-1.rs: New test. * rust/compile/issue-2190-2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: refactor resolve_method_address to be more genericPhilip Herron1-6/+2
We can reuse the DefId to lookup the mappings to Items or Trait Items instead of the HirId this is more generic and can then be reused for the deref operator overload during autoderef cycles. Addresses #2190 gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address): refactor * backend/rust-compile-base.h: likewise * backend/rust-compile-expr.cc (CompileExpr::visit): likewise * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Add missing coercion site logic to return expressionsPhilip Herron1-1/+20
gcc/rust/ChangeLog: * backend/rust-compile-base.cc: track return type in fncontext * backend/rust-compile-context.h (struct fncontext): likewise * backend/rust-compile-expr.cc (CompileExpr::visit): apply coercion site (CompileExpr::generate_closure_function): update push_context * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise gcc/testsuite/ChangeLog: * rust/execute/torture/coercion3.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: unify how we handle DST'sPhilip Herron1-18/+9
DST's are not truely reference types they are "unsized types" so the exact size of them is not known at compile time. We actually achieve this by pretending they are a reference but really its struct we pass around. Fixes #2180 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): refactr (CompileExpr::get_fn_addr_from_dyn): likewise (CompileExpr::get_receiver_from_dyn): likewise (CompileExpr::type_cast_expression): likewise * backend/rust-compile-type.cc (TyTyResolveCompile::visit): likewise (TyTyResolveCompile::create_dyn_obj_record): likewise (TyTyResolveCompile::create_slice_type_record): likewise (TyTyResolveCompile::create_str_type_record): likewise * backend/rust-compile-type.h: likewise * backend/rust-compile.cc (HIRCompileBase::coercion_site1): likewise (HIRCompileBase::coerce_to_dyn_object): refactor * backend/rust-tree.h (SLICE_FLAG): removed (SLICE_TYPE_P): removed (RS_DST_FLAG): new flag (RS_DST_FLAG_P): new predicate * typecheck/rust-tyty.cc (ReferenceType::is_dyn_object): new helper (ReferenceType::is_dyn_obj_type): likewise (PointerType::is_dyn_object): likewise (PointerType::is_dyn_obj_type): likewise * typecheck/rust-tyty.h (class DynamicObjectType): moved up gcc/testsuite/ChangeLog: * rust/execute/torture/issue-2180.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>