aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-session-manager.cc
AgeCommit message (Collapse)AuthorFilesLines
2025-08-05gccrs: desugar: Add for-loop desugar to ExpressionYeastArthur Cohen1-1/+0
gcc/rust/ChangeLog: * ast/rust-desugar-for-loops.h: Adapt API and remove visitor. * ast/rust-desugar-for-loops.cc: Likewise. * ast/rust-expression-yeast.cc: Call DesugarForLoop. * ast/rust-expression-yeast.h: Declare dispatch_loops function. * rust-session-manager.cc (Session::expansion): Do not call for-loop desugar.
2025-08-05gccrs: desugar: Add desugar dispatch for all desugarsArthur Cohen1-1/+3
Since we are doing more and more "external" desugars, as in desugars that take a pointer and replace it with another one, rather than modifying it from within, having an external visitor dispatch to the proper desugar helps with code clarity. gcc/rust/ChangeLog: * Make-lang.in: Compile it. * rust-session-manager.cc: Call the expression desugar dispatcher. * ast/rust-desugar-question-mark.cc: Rework class API. * ast/rust-desugar-question-mark.h: Likewise. * ast/rust-expression-yeast.cc: New file. * ast/rust-expression-yeast.h: New file.
2025-08-05gccrs: Do proper const folding during typechecking for array capacitiesPhilip Herron1-5/+5
This patch adds proper folding to the const expression for array capacity we already have the const folding mechanics and the query system needed to handle cases where the capacity is a function call in a const context. This leverages and pulls the gcc tree capacity into the TyTy::ArrayType so it can be used for more typechecking and eventually doing more const generics work. Addresses Rust-GCC#3885 Fixes Rust-GCC#3882 gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::query_compile_const_expr): new wrapper * backend/rust-compile-base.h: add prototype * backend/rust-compile-context.cc (Context::get): singleton helper * backend/rust-compile-context.h: likewise * backend/rust-compile-type.cc (TyTyResolveCompile::visit): handle infer's that can default * rust-session-manager.cc (Session::compile_crate): create the gcc context earlier for tychk * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): const fold it * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise * typecheck/rust-tyty.cc (BaseType::monomorphized_clone): fix constructor call (ArrayType::as_string): print capacity (ArrayType::clone): fix constructor call * typecheck/rust-tyty.h: track capacity * typecheck/rust-unify.cc (UnifyRules::expect_array): check the capacities gcc/testsuite/ChangeLog: * rust/compile/all-cast.rs: shows array capacity now * rust/compile/arrays2.rs: likewise * rust/compile/const3.rs: fix error message * rust/compile/const_generics_3.rs: disable until typecheck we get proper errors now! * rust/compile/usize1.rs: proper capacity error message Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: nr2.0: Adjust resolution of external cratesOwen Avery1-2/+7
This ensures Session::load_extern_crate doesn't try to use the old name resolver when nr2.0 is enabled, while also ensuring that nr2.0 handles external crates. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit_extern_crate): New function. (DefaultResolver::visit): New visitor function for ExternCrate. * resolve/rust-default-resolver.h (DefaultResolver::visit_extern_crate): New function. (DefaultResolver::visit): New visitor function for ExternCrate. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Adjust ExternCrate visitor and rename to... (TopLevel::visit_extern_crate): ...here. * resolve/rust-toplevel-name-resolver-2.0.h (TopLevel::visit): Remove ExternCrate visitor override. (TopLevel::visit_extern_crate): New function. * rust-session-manager.cc (Session::load_extern_crate): Only run name resolution 1.0 if name resolution 2.0 is disabled. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Move AST desugaring into expansion phaseOwen Avery1-4/+14
This fixes some issues with name resolution 2.0. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Move AST desugaring to... (Session::expansion): ...here and add a final TopLevel pass afterwards. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Adjust external crate lowering and type checkingOwen Avery1-8/+0
The 2.0 name resolver is provided through ImmutableNameResolutionContext after it is done being mutated. The typechecker attempts to use ImmutableNameResolutionContext, so it needs to be run after ImmutableNameResolutionContext has been initialized (after all name resolution has been completed). Additionally, although I haven't seen any issues with lowering AST to HIR before name resolution 2.0 is complete, it makes sense to perform all lowering in lockstep as well. gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Add visitor for ExternCrate. * hir/rust-ast-lower-item.h (ASTLoweringItem::visit): Likewise. * rust-session-manager.cc (Session::load_extern_crate): Avoid lowering or type resolving external crates here. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Add visitor for ExternCrate. * typecheck/rust-hir-type-check-item.h (TypeCheckItem::visit): Replace empty definition with a declaration. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Reindent using last clang-format configurationMarc Poulhiès1-12/+12
It changes declaration and switch case indentation to follow GNU coding style. gcc/rust/ChangeLog: * ast/rust-ast-builder-type.cc (ASTTypeBuilder::visit): Reindent. * ast/rust-ast-builder.cc (Builder::new_generic_args): Likewise. * ast/rust-ast-collector.cc (TokenCollector::visit): Likewise. * ast/rust-ast-dump.h (debug): Likewise. * ast/rust-ast-formatting.h (indent_spaces): Likewise. (get_string_in_delims): Likewise. (get_mode_dump_desc): Likewise. (append_attributes): Likewise. (unquote_string): Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast.cc (Attribute::get_traits_to_derive): Likewise. (UseTreeGlob::as_string): Likewise. (UseTreeList::as_string): Likewise. (AttributeParser::parse_path_meta_item): Likewise. (FormatArgs::set_outer_attrs): Likewise. * ast/rust-ast.h (operator<<): Likewise. * ast/rust-cond-compilation.h: Likewise. * ast/rust-desugar-apit.cc: Likewise. * ast/rust-fmt.h (collect_pieces): Likewise. (clone_pieces): Likewise. * ast/rust-pattern.h (tokenid_to_rangekind): Likewise. * backend/rust-compile-context.cc (Context::type_hasher): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-intrinsic.cc (get_identifier): Likewise. (offset_handler): Likewise. (sizeof_handler): Likewise. (transmute_handler): Likewise. (rotate_handler): Likewise. (wrapping_op_handler_inner): Likewise. (op_with_overflow_inner): Likewise. (uninit_handler): Likewise. (move_val_init_handler): Likewise. (assume_handler): Likewise. (discriminant_value_handler): Likewise. (variant_count_handler): Likewise. (prefetch_data_handler): Likewise. (atomic_store_handler_inner): Likewise. (atomic_load_handler_inner): Likewise. (unchecked_op_inner): Likewise. (copy_handler_inner): Likewise. (expect_handler_inner): Likewise. (try_handler_inner): Likewise. * backend/rust-compile-pattern.cc (compile_range_pattern_bound): Likewise. (CompilePatternCheckExpr::visit): Likewise. (CompilePatternBindings::visit): Likewise. (CompilePatternLet::visit): Likewise. * backend/rust-compile-var-decl.h: Likewise. * backend/rust-constexpr.cc (verify_constant): Likewise. (find_array_ctor_elt): Likewise. (array_index_cmp): Likewise. (potential_constant_expression_1): Likewise. (unshare_constructor): Likewise. (maybe_save_constexpr_fundef): Likewise. (returns): Likewise. (breaks): Likewise. (continues): Likewise. (switches): Likewise. (constant_value_1): Likewise. (decl_constant_value): Likewise. (non_const_var_error): Likewise. (eval_constant_expression): Likewise. (constexpr_fn_retval): Likewise. (eval_store_expression): Likewise. (eval_call_expression): Likewise. (eval_binary_expression): Likewise. (get_function_named_in_call): Likewise. (eval_statement_list): Likewise. (extract_string_elt): Likewise. (eval_conditional_expression): Likewise. (eval_bit_field_ref): Likewise. (eval_loop_expr): Likewise. (eval_switch_expr): Likewise. (eval_unary_expression): Likewise. (get_or_insert_ctor_field): Likewise. (eval_and_check_array_index): Likewise. * backend/rust-constexpr.h (maybe_save_constexpr_fundef): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. (v0_complex_type_prefix): Likewise. * backend/rust-mangle.h (legacy_mangle_item): Likewise. (v0_mangle_item): Likewise. * backend/rust-tree.cc (convert_to_void): Likewise. (find_parameter_packs_r): Likewise. (rs_tree_equal): Likewise. (publicly_uniquely_derived_p): Likewise. (instantiation_dependent_expression_p): Likewise. (type_has_nontrivial_copy_init): Likewise. (is_normal_capture_proxy): Likewise. (is_bitfield_expr_with_lowered_type): Likewise. (undeduced_auto_decl): Likewise. (require_deduced_type): Likewise. (gt_pch_nx): Likewise. (lvalue_kind): Likewise. * backend/rust-tree.h (LANG_DECL_MIN_CHECK): Likewise. (LANG_DECL_FN_CHECK): Likewise. (LANG_DECL_NS_CHECK): Likewise. (LANG_DECL_PARM_CHECK): Likewise. (LANG_DECL_DECOMP_CHECK): Likewise. (resort_type_member_vec): Likewise. (convert_to_void): Likewise. (mark_discarded_use): Likewise. (mark_exp_read): Likewise. (mark_use): Likewise. (mark_rvalue_use): Likewise. (mark_lvalue_use): Likewise. (mark_lvalue_use_nonread): Likewise. (convert_from_reference): Likewise. (maybe_warn_nodiscard): Likewise. (expr_loc_or_loc): Likewise. (expr_loc_or_input_loc): Likewise. (get_fndecl_from_callee): Likewise. (pointer_offset_expression): Likewise. (is_empty_class): Likewise. (is_really_empty_class): Likewise. (rs_type_quals): Likewise. (init_modules): Likewise. (lookup_add): Likewise. (ovl_make): Likewise. (struct c_fileinfo): Likewise. (get_fileinfo): Likewise. (cxx_make_type): Likewise. (build_cplus_array_type): Likewise. (comptypes): Likewise. (rs_build_qualified_type_real): Likewise. (vector_targets_convertible_p): Likewise. (get_class_binding_direct): Likewise. (lang_check_failed): Likewise. (check_for_uninitialized_const_var): Likewise. (cp_fold_maybe_rvalue): Likewise. (fold_offsetof): Likewise. (fold_non_dependent_expr): Likewise. (in_immediate_context): Likewise. (cxx_mark_addressable): Likewise. (decl_constant_value): Likewise. (is_class_type): Likewise. (fold_builtin_is_pointer_inverconvertible_with_class): Likewise. (c_common_type_for_mode): Likewise. (next_common_initial_seqence): Likewise. (fold_builtin_is_corresponding_member): Likewise. (maybe_constant_value): Likewise. (rs_walk_subtrees): Likewise. (make_tree_vector): Likewise. (release_tree_vector): Likewise. (location_of): Likewise. (maybe_constant_init): Likewise. (explain_invalid_constexpr_fn): Likewise. (literal_type_p): Likewise. (maybe_constexpr_fn): Likewise. (fold_non_dependent_init): Likewise. * checks/errors/borrowck/polonius/rust-polonius.h (polonius_run): Likewise. (FFIVector__new): Likewise. (FFIVector__new_vec_pair): Likewise. (FFIVector__new_vec_triple): Likewise. (FFIVector__push): Likewise. (FFIVector__push_vec_triple): Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise. * checks/errors/borrowck/rust-bir-builder-pattern.cc (PatternBindingBuilder::visit): Likewise. * checks/errors/borrowck/rust-bir-dump.cc (Dump::visit): Likewise. * checks/errors/borrowck/rust-bir-fact-collector.h (points): Likewise. * checks/errors/borrowck/rust-bir-place.h: Likewise. * checks/errors/borrowck/rust-bir-visitor.h: Likewise. * checks/errors/privacy/rust-privacy-check.cc (saw_errors): Likewise. * checks/errors/privacy/rust-privacy-ctx.h (rust_privacy_ctx_test): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_for_privacy_violation): Likewise. (PrivacyReporter::check_base_type_privacy): Likewise. (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_visibility): Likewise. * checks/errors/rust-hir-pattern-analysis.cc (Constructor::is_covered_by): Likewise. (PlaceInfo::specialize): Likewise. (WitnessPat::to_string): Likewise. (WitnessMatrix::apply_constructor): Likewise. (lower_pattern): Likewise. (lower_tuple_pattern): Likewise. (lower_struct_pattern): Likewise. * checks/errors/rust-hir-pattern-analysis.h (check_match_usefulness): Likewise. * expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_generic_args): Likewise. * expand/rust-derive-eq.cc (DeriveEq::visit_enum): Likewise. * expand/rust-derive.cc: Likewise. * expand/rust-expand-format-args.cc (expand_format_args): Likewise. * expand/rust-expand-visitor.h (is_derive): Likewise. (is_builtin): Likewise. * expand/rust-macro-builtins-asm.cc (expand_inline_asm_strings): Likewise. * expand/rust-macro-builtins-asm.h (parse_asm): Likewise. (check_identifier): Likewise. (check_and_set): Likewise. (parse_label): Likewise. (parse_llvm_outputs): Likewise. (parse_llvm_inputs): Likewise. (parse_llvm_clobbers): Likewise. (parse_llvm_options): Likewise. * expand/rust-macro-builtins-helpers.h (make_macro_path_str): Likewise. (make_token): Likewise. (make_string): Likewise. (macro_end_token): Likewise. (parse_single_string_literal): Likewise. (source_relative_path): Likewise. (load_file_bytes): Likewise. * expand/rust-macro-expand.cc (MacroExpander::match_fragment): Likewise. (MacroExpander::match_matcher): Likewise. (MacroExpander::match_n_matches): Likewise. * expand/rust-macro-substitute-ctx.cc (SubstituteCtx::substitute_token): Likewise. * expand/rust-proc-macro.h (load_macros): Likewise. (generate_proc_macro_decls_symbol): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_generic_args): Likewise. (ASTLoweringBase::lower_range_pattern_bound): Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower.h (struct_field_name_exists): Likewise. (translate_visibility): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/rust-hir-dump.h (debug): Likewise. * hir/tree/rust-hir.cc (UseTreeGlob::as_string): Likewise. (UseTreeList::as_string): Likewise. * lex/rust-lex.cc (Lexer::parse_escape): Likewise. (Lexer::parse_utf8_escape): Likewise. * lex/rust-lex.h (rust_input_source_test): Likewise. * lex/rust-token.cc (RS_TOKEN_KEYWORD_2015): Likewise. * lex/rust-token.h (get_token_description): Likewise. (token_id_to_str): Likewise. (token_id_is_keyword): Likewise. (token_id_keyword_string): Likewise. (get_type_hint_string): Likewise. (nfc_normalize_token_string): Likewise. * metadata/rust-export-metadata.cc (PublicInterface::write_to_path): Likewise. * metadata/rust-import-archive.cc: Likewise. * metadata/rust-imports.h (add_search_path): Likewise. * parse/rust-cfg-parser.h (parse_cfg_option): Likewise. (rust_cfg_parser_test): Likewise. * parse/rust-parse-impl.h (Parser::skip_generics_right_angle): Likewise. (Parser::parse_attr_input): Likewise. (Parser::parse_macro_match): Likewise. (Parser::parse_visibility): Likewise. (Parser::parse_module): Likewise. (Parser::parse_use_tree): Likewise. (Parser::parse_generic_param): Likewise. (Parser::parse_struct): Likewise. (Parser::parse_enum_item): Likewise. (Parser::parse_inherent_impl_item): Likewise. (Parser::parse_external_item): Likewise. (Parser::parse_generic_arg): Likewise. (Parser::parse_type_path_segment): Likewise. (Parser::parse_expr_stmt): Likewise. (Parser::parse_if_expr): Likewise. (Parser::parse_if_let_expr): Likewise. (Parser::parse_type): Likewise. (Parser::parse_for_prefixed_type): Likewise. (Parser::parse_slice_or_array_type): Likewise. (Parser::parse_type_no_bounds): Likewise. (Parser::parse_range_pattern_bound): Likewise. (Parser::parse_pattern_no_alt): Likewise. (Parser::parse_grouped_or_tuple_pattern): Likewise. (Parser::parse_ident_leading_pattern): Likewise. (Parser::parse_tuple_struct_items): Likewise. (Parser::parse_stmt_or_expr): Likewise. (Parser::parse_struct_expr_field): Likewise. (Parser::null_denotation): Likewise. (Parser::left_denotation): Likewise. (Parser::parse_closure_expr_pratt): Likewise. * parse/rust-parse.cc (peculiar_fragment_match_compatible): Likewise. (is_match_compatible): Likewise. * parse/rust-parse.h (extract_module_path): Likewise. (is_match_compatible): Likewise. * resolve/rust-ast-resolve-expr.cc (translate_operand): Likewise. * resolve/rust-ast-resolve-item.cc (flatten_glob): Likewise. (flatten_rebind): Likewise. (flatten_list): Likewise. (flatten): Likewise. * resolve/rust-ast-resolve-item.h (rust_simple_path_resolve_test): Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise. (resolve_range_pattern_bound): Likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. (ResolveTypeToCanonicalPath::visit): Likewise. * resolve/rust-ast-resolve.cc (saw_errors): Likewise. * resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import): Likewise. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (flatten_glob): Likewise. * rust-backend.h (init): Likewise. (debug): Likewise. (get_identifier_node): Likewise. (wchar_type): Likewise. (get_pointer_size): Likewise. (raw_str_type): Likewise. (integer_type): Likewise. (float_type): Likewise. (pointer_type): Likewise. (reference_type): Likewise. (immutable_type): Likewise. (function_type): Likewise. (function_type_variadic): Likewise. (function_ptr_type): Likewise. (struct_type): Likewise. (union_type): Likewise. (array_type): Likewise. (named_type): Likewise. (type_field_offset): Likewise. (var_expression): Likewise. (float_constant_expression): Likewise. (string_constant_expression): Likewise. (char_constant_expression): Likewise. (wchar_constant_expression): Likewise. (boolean_constant_expression): Likewise. (convert_expression): Likewise. (struct_field_expression): Likewise. (compound_expression): Likewise. (conditional_expression): Likewise. (negation_expression): Likewise. (arithmetic_or_logical_expression): Likewise. (arithmetic_or_logical_expression_checked): Likewise. (comparison_expression): Likewise. (lazy_boolean_expression): Likewise. (constructor_expression): Likewise. (array_constructor_expression): Likewise. (array_initializer): Likewise. (array_index_expression): Likewise. (call_expression): Likewise. (init_statement): Likewise. (assignment_statement): Likewise. (return_statement): Likewise. (if_statement): Likewise. (loop_expression): Likewise. (exit_expression): Likewise. (statement_list): Likewise. (exception_handler_statement): Likewise. (block): Likewise. (block_add_statements): Likewise. (global_variable): Likewise. (global_variable_set_init): Likewise. (local_variable): Likewise. (parameter_variable): Likewise. (static_chain_variable): Likewise. (temporary_variable): Likewise. (label): Likewise. (function): Likewise. (function_defer_statement): Likewise. (function_set_parameters): Likewise. (write_global_definitions): Likewise. (fill_in_fields): Likewise. * rust-diagnostics.cc (expand_format): Likewise. (expand_message): Likewise. (va_constructor): Likewise. * rust-diagnostics.h (RUST_ATTRIBUTE_GCC_DIAG): Likewise. (rust_open_quote): Likewise. (rust_close_quote): Likewise. (rust_debug_loc): Likewise. * rust-gcc.cc (non_zero_size_type): Likewise. * rust-object-export.h (rust_field_alignment): Likewise. (rust_read_export_data): Likewise. (rust_write_export_data): Likewise. * rust-session-manager.cc (saw_errors): Likewise. (rust_get_linemap): Likewise. (validate_crate_name): Likewise. (Session::load_extern_crate): Likewise. * rust-session-manager.h (rust_crate_name_validation_test): Likewise. * rust-system.h (rust_preserve_from_gc): Likewise. (rust_localize_identifier): Likewise. * rust-target.h (rust_add_target_info): Likewise. * typecheck/rust-autoderef.cc: * typecheck/rust-casts.cc (TypeCastRules::cast_rules): Likewise. * typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Likewise. (TypeCoercionRules::coerce_unsafe_ptr): Likewise. (TypeCoercionRules::coerce_borrowed_pointer): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): Likewise. (TraitItemReference::is_object_safe): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. (typecheck_inline_asm_operand): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. (TypeCheckImplItemWithTrait::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::apply_trait_bounds): Likewise. (ResolveWhereClauseItem::visit): Likewise. * typecheck/rust-hir-type-check.cc (saw_errors): Likewise. (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-type-util.h (query_type): Likewise. (types_compatable): Likewise. (unify_site): Likewise. (unify_site_and): Likewise. (coercion_site): Likewise. (try_coercion): Likewise. (cast_site): Likewise. * typecheck/rust-tyty-bounds.cc: * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise. * typecheck/rust-tyty-cmp.h: * typecheck/rust-tyty-variance-analysis.h (query_field_regions): Likewise. * typecheck/rust-tyty.cc (BaseType::is_unit): Likewise. (BaseType::has_substitutions_defined): Likewise. (BaseType::needs_generic_substitutions): Likewise. (BaseType::get_subst_argument_mappings): Likewise. (InferType::default_type): Likewise. (InferType::apply_primitive_type_hint): Likewise. * typecheck/rust-tyty.h (is_primitive_type_kind): Likewise. * typecheck/rust-unify.cc (UnifyRules::expect_inference_variable): Likewise. (UnifyRules::expect_adt): Likewise. (UnifyRules::expect_str): Likewise. (UnifyRules::expect_reference): Likewise. (UnifyRules::expect_pointer): Likewise. (UnifyRules::expect_param): Likewise. (UnifyRules::expect_array): Likewise. (UnifyRules::expect_slice): Likewise. (UnifyRules::expect_fndef): Likewise. (UnifyRules::expect_fnptr): Likewise. (UnifyRules::expect_tuple): Likewise. (UnifyRules::expect_bool): Likewise. (UnifyRules::expect_char): Likewise. (UnifyRules::expect_int): Likewise. (UnifyRules::expect_uint): Likewise. (UnifyRules::expect_float): Likewise. (UnifyRules::expect_isize): Likewise. (UnifyRules::expect_usize): Likewise. (UnifyRules::expect_never): Likewise. (UnifyRules::expect_placeholder): Likewise. (UnifyRules::expect_projection): Likewise. (UnifyRules::expect_dyn): Likewise. (UnifyRules::expect_closure): Likewise. (UnifyRules::expect_opaque): Likewise. * util/rust-abi.h (get_abi_from_string): Likewise. (get_string_from_abi): Likewise. * util/rust-attributes.cc (check_doc_attribute): Likewise. * util/rust-base62.h (base62_integer): Likewise. * util/rust-dir-owner.h (get_file_subdir): Likewise. * util/rust-edition.h (get_rust_edition): Likewise. * util/rust-punycode.h (encode_punycode): Likewise. (rust_punycode_encode_test): Likewise. * util/rust-token-converter.cc (convert): Likewise. (from_tokenstream): Likewise. * util/rust-token-converter.h (convert): Likewise. (convert_literal): Likewise. * util/rust-unicode.h (is_alphabetic): Likewise. (is_ascii_only): Likewise. (is_numeric): Likewise. (is_nfc_qc_no): Likewise. (is_nfc_qc_maybe): Likewise. (nfc_quick_check): Likewise. (rust_nfc_qc_test): Likewise. (rust_utf8_normalize_test): Likewise. (rust_utf8_property_test): Likewise. * util/rust-unwrap-segment.h (unwrap_segment_node_id): Likewise. libgrust/ChangeLog: * libproc_macro_internal/ffistring.h (FFIString__new): Likewise. (FFIString__drop): Likewise. * libproc_macro_internal/ident.h (Ident__new): Likewise. (Ident__new_raw): Likewise. (Ident__drop): Likewise. (Ident__clone): Likewise. * libproc_macro_internal/literal.h (Literal__from_string): Likewise. * libproc_macro_internal/proc_macro.h (bridge_is_available): Likewise. * libproc_macro_internal/tokenstream.h (TokenStream__new): Likewise. (TokenStream__with_capacity): Likewise. (TokenSream__push): Likewise. (TokenStream__from_string): Likewise. (TokenStream__clone): Likewise. (TokenStream__drop): Likewise.
2025-08-05gccrs: desugar APIT impl traitsPhilip Herron1-0/+2
Argument position impl traits are simply syntatic sugar for generics. This adds a new desugar pass to do this. So for example: fn foo(a: impl Value, b: impl Value) -> i32 Is desugared into: fn foo<T: Value, U: Value> (a: T, b: U) -> i32 So it just works like any normal generic function. There are more complex cases such as: fn foo(_value: impl Bar<Baz = impl Foo>) -> i32 Which has a generic argument binding which needs to be turned into a where constraint: fn foo<T, U>(_value: T) -> i32 where T: Bar<Baz = U>, U: Foo, Fixes Rust-GCC#2015 Fixes Rust-GCC#1487 Fixes Rust-GCC#3454 Fixes Rust-GCC#1482 gcc/rust/ChangeLog: * Make-lang.in: new desugar file * ast/rust-ast.cc (ImplTraitTypeOneBound::as_string): its a unique_ptr now (FormatArgs::set_outer_attrs): reformat * ast/rust-path.h: remove has_generic_args assertion (can be empty because of desugar) * ast/rust-type.h (class ImplTraitTypeOneBound): add copy ctor and use unique_ptr * hir/rust-ast-lower-type.cc (ASTLoweringType::visit): update to use unique_ptr * parse/rust-parse-impl.h (Parser::parse_type): reuse the existing unique_ptr instead (Parser::parse_type_no_bounds): likewise (Parser::parse_pattern): likewise * resolve/rust-ast-resolve-type.cc (ResolveType::visit): its a unique_ptr now * rust-session-manager.cc (Session::compile_crate): call desugar * ast/rust-desugar-apit.cc: New file. * ast/rust-desugar-apit.h: New file. gcc/testsuite/ChangeLog: * rust/compile/issue-2015.rs: fully supported now * rust/compile/nr2/exclude: nr2 cant handle some of these * rust/compile/issue-1487.rs: New test. * rust/compile/issue-3454.rs: New test. * rust/execute/torture/impl_desugar-2.rs: New test. * rust/execute/torture/impl_desugar.rs: New test. * rust/execute/torture/impl_trait1.rs: New test. * rust/execute/torture/impl_trait2.rs: New test. * rust/execute/torture/impl_trait3.rs: New test. * rust/execute/torture/impl_trait4.rs: New test. * rust/execute/torture/issue-1482.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-14gccrs: session: Desugar question mark operator after expansion instead.Arthur Cohen1-1/+1
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call the visitor later in the pipeline.
2025-03-24gccrs: session-manager: Call into DesugarQuestionMarkArthur Cohen1-0/+2
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call DesugarQuestionMark::go().
2025-03-24gccrs: session manager: Call into DesugarForLoopsArthur Cohen1-0/+4
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call the visitor.
2025-03-24gccrs: Infer crate name after file openingDylan Gardner1-28/+33
Fixes #3129. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::handle_crate_name): Remove crate name inference (Session::compile_crate): Add crate name inference and error if inferred name is empty. Remove CompileOptions::get_instance () that returned a local copy of the options. Rename crate_name_changed to crate_name_found to match semantics. (rust_crate_name_validation_test): Test inferring ".rs" name * rust-session-manager.h: Modify handle_crate_name definition to include filename.
2025-03-21gccrs: rust/intrinsic: add try intrinsic and panic strategy optionsliushuyu1-0/+3
gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: add `try` intrinsic handler. * lang.opt: add `-frust-panic` option. * rust-lang.cc: enable exception handler code generation. * rust-session-manager.cc: add getter and setter for panic strategy option. * rust-session-manager.h: Likewise. Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2025-03-21gccrs: lang-items: Add lang-items AST collectorArthur Cohen1-0/+3
gcc/rust/ChangeLog: * Make-lang.in: Add new object file. * rust-session-manager.cc (Session::compile_crate): Call CollectLangItems. * ast/rust-collect-lang-items.cc: New file. * ast/rust-collect-lang-items.h: New file.
2025-03-19gccrs: Postpone break on error after name resolutionPierre-Emmanuel Patry1-3/+3
We need the top level to run at least once before breaking because it will be required by the other name resolution steps. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::expansion): Break on error after top level name resolution. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-19gccrs: Loop on expansion if a new export has been definedPierre-Emmanuel Patry1-1/+4
When a use statement requires a reexported item it cannot find it in the same pass, an additional pass shall be performed. This means we need to detect whether a new item has been reexported and resolve until the end. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::Early): Add dirty flag initialization. (Early::go): Set dirty flag using top level resolver. * resolve/rust-early-name-resolver-2.0.h: Add dirty flag. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::TopLevel): Initialize dirty flag. (TopLevel::insert_or_error_out): Set dirty flag on successful namespace modification. * resolve/rust-toplevel-name-resolver-2.0.h: Add dirty flag. * rust-session-manager.cc (Session::expansion): Modify fixed point condition to include name resolution modifications. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-19gccrs: session-manager: Fix typos in -frust-incomplete messageArthur Cohen1-4/+5
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Use less repetition, fix a typo in `reports`, fix word order.
2025-03-19gccrs: Implement initial pattern analysis pass.Raiki Tamura1-0/+6
gcc/rust/ChangeLog: * Make-lang.in: Add rust-hir-pattern-analysis.o. * rust-session-manager.cc (Session::compile_crate): Add pattern analysis pass. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Do typecheck for subpatterns. * checks/errors/rust-hir-pattern-analysis.cc: New file. * checks/errors/rust-hir-pattern-analysis.h: New file. gcc/testsuite/ChangeLog: * rust/compile/exhaustiveness1.rs: New test. * rust/compile/exhaustiveness2.rs: New test. * rust/compile/exhaustiveness3.rs: New test. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2025-03-17gccrs: Change crate_num_to_nodeid return typePierre-Emmanuel Patry1-5/+3
Change the function's return type to an optional. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new return type. * rust-session-manager.cc (Session::load_extern_crate): Likewise. * util/rust-hir-map.cc (Mappings::crate_num_to_nodeid): Change the return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-17gccrs: Change return type of lookup_crate_namePierre-Emmanuel Patry1-4/+2
Change the function's return type to use an optional. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new return type. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. * rust-session-manager.cc (Session::load_extern_crate): Likewise. * util/rust-hir-map.cc (Mappings::lookup_crate_name): Change the return type to an optional. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-17gccrs: Change singleton returned type to a referencePierre-Emmanuel Patry1-20/+20
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-01-02Update copyright years.Jakub Jelinek1-1/+1
2024-11-27diagnostics: replace %<%s%> with %qs [PR104896]David Malcolm1-3/+3
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: session manager: Init Immutable name resolver.Arthur Cohen1-0/+4
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Create an immutable view of the name resolution context.
2024-08-01gccrs: session-manager: Dump name resolution pass.Arthur Cohen1-3/+27
gcc/rust/ChangeLog: * rust-session-manager.cc: Add files for dumping name resolution, call name resolution dump function. (Session::dump_name_resolution): New. * rust-session-manager.h: New declaration.
2024-08-01gccrs: sesh: Add late name resolution 2.0Arthur Cohen1-5/+9
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Create name resolution context for Session::expansion and subsequent name resolution passes. (Session::expansion): Take name resolution context as a parameter instead. * rust-session-manager.h (Session::expansion): Fix declaration.
2024-08-01gccrs: TyTy: Variance analysis moduleJakub Dupak1-0/+3
gcc/rust/ChangeLog: * Make-lang.in: Add new .cc file. * rust-session-manager.cc (Session::compile_crate): Run analysis. * typecheck/rust-tyty-variance-analysis-private.h: New file. * typecheck/rust-tyty-variance-analysis.cc: New file. * typecheck/rust-tyty-variance-analysis.h: New file. * typecheck/rust-typecheck-context.cc (TypeCheckContext::get_variance_analysis_ctx): Variance analysis context. * typecheck/rust-hir-type-check.h (TypeCheckItem::visit): Variance analysis context. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Add call to ast validation checkerPierre-Emmanuel Patry1-0/+9
Add call to ast validation check, also add appropriate step to this pass and the feature gating. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Add call to ast validation. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: borrowck: Create BIR builders (visitors)Jakub Dupak1-628/+774
gcc/rust/ChangeLog: * Make-lang.in: Compile BIR expr visitor. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Use BIR builder. * rust-session-manager.cc (Session::compile_crate): Run borrow checker. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc: New file. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: New file. * checks/errors/borrowck/rust-bir-builder-internal.h: New file. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: New file. * checks/errors/borrowck/rust-bir-builder-pattern.h: New file. * checks/errors/borrowck/rust-bir-builder-struct.h: New file. * checks/errors/borrowck/rust-bir-builder.h: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Execute only with CLI flagJakub Dupak1-3/+5
gcc/rust/ChangeLog: * lang.opt: CLI flag. * rust-session-manager.cc (Session::compile_crate): Guard execution. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Add CLI option for borrowckJakub Dupak1-763/+630
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::BorrowChecker): Opt dump. (BorrowChecker::go): Opt dump. * checks/errors/borrowck/rust-borrow-checker.h (class BorrowChecker): Opt dump. * lang.opt: Add compile until borrowcheck. * rust-session-manager.cc (Session::enable_dump): Add BIR. (Session::compile_crate): Handle new options. * rust-session-manager.h (struct CompileOptions): Add BIR. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Fix ICE when emitting an error during cfg stripPierre-Emmanuel Patry1-0/+3
When an error was emitted during the cfg strip pass by the crate loader, it was ignored and the error state propagated until another pass (name resolver). gcc/rust/ChangeLog: * rust-session-manager.cc (Session::expansion): Add early break on error. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: port over readonly_error from c-family for lvalue assignment checksPhilip Herron1-2/+2
Fixes #2391 gcc/rust/ChangeLog: * Make-lang.in: fixup formatting * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): remove old check * rust-session-manager.cc (Session::compile_crate): call new lint * resolve/rust-ast-verify-assignee.h: Removed. * checks/errors/rust-readonly-check.cc: New file. * checks/errors/rust-readonly-check.h: New file. gcc/testsuite/ChangeLog: * rust/compile/wrong_lhs_assignment.rs: update error message * rust/compile/issue-2391.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Convert class Backend into namespaceOwen Avery1-5/+2
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: Unify raw attribute valuesPierre-Emmanuel Patry1-2/+3
Attribute values were used as raw string, this is error prone and makes renaming harder. Using a constexpr instead will leverage the power of the compiler and emit an error when an incorrect builtin attribute value is used. gcc/rust/ChangeLog: * ast/rust-ast.cc (Attribute::check_cfg_predicate): Change raw string to constexpr call. (Attribute::separate_cfg_attrs): Likewise. * backend/rust-compile-base.cc (should_mangle_item): Likewise. (HIRCompileBase::setup_fndecl): Likewise. (HIRCompileBase::handle_cold_attribute_on_fndecl): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (find_proc_macro_attribute): Likewise. * checks/errors/rust-unsafe-checker.cc (check_target_attr): Likewise. * expand/rust-cfg-strip.cc (fails_cfg): Likewise. (fails_cfg_with_expand): Likewise. (expand_cfg_attrs): Likewise. * expand/rust-macro-builtins.cc: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Likewise. (ASTLoweringBase::lower_macro_definition): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * parse/rust-parse-impl.h (Parser::parse_doc_comment): Likewise. * parse/rust-parse.cc (extract_module_path): Likewise. * resolve/rust-early-name-resolver.cc (is_macro_use_module): Likewise. (EarlyNameResolver::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (is_macro_export): Likwise. * rust-session-manager.cc (Session::injection): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): Likewise. * util/rust-attributes.cc (is_proc_macro_type): Likewise. (AttributeChecker::check_attribute): Likewise. (AttributeChecker::visit): Likewise. * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise. * util/rust-attribute-values.h: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Clarify package import procedurePierre-Emmanuel Patry1-8/+16
This part of the code is a bit tricky as it calls multiple functions with almost the same name and slightly different behaviors. It was even more with a meaningless variable name. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::load_extern_crate): Change variable name, add temporaries and comments. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Move extern crate resolvingPierre-Emmanuel Patry1-6/+11
Move extern crate resolving under the extern crate declaration instead of doing it under the crate's root as extern crates are not resolved by the top level resolver. gcc/rust/ChangeLog: * metadata/rust-extern-crate.cc (ExternCrate::ExternCrate): Update definition to allow Extern crate with no content (pure proc macros). (ExternCrate::ok): Panic on no content. (ExternCrate::load): Likewise. * metadata/rust-extern-crate.h: Update prototypes. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go): Remove macro resolution. (TopLevel::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.h: Add visit prototype for extern crate. * rust-session-manager.cc (Session::load_extern_crate): Adapt content depending on the loaded crate's content. * util/rust-hir-map.cc (Mappings::lookup_derive_proc_macros): Change return type to optional because it is way more convenient. (Mappings::lookup_bang_proc_macros): Likewise. (Mappings::lookup_attribute_proc_macros): Likewise. * util/rust-hir-map.h: Update function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Move proc macro definition to mappingsPierre-Emmanuel Patry1-3/+11
This commit moves the procedural macros loaded definition from outside the AST to the mappings. This means most getters/setters around the mappings had to be changed. This commit also introduces the top level visit of those mappings instead of visiting the Crate ast members. gcc/rust/ChangeLog: * ast/rust-ast.h (class BangProcMacro): Move class from here to rust-proc-macro.h. Also remove related functions. (class AttributeProcMacro): Likewise. (class CustomDeriveProcMacro): Likewise. (struct Crate): Remove proc macro vector members. * expand/rust-macro-expand.h (struct MacroExpander): Change the type to the newly created classes. * expand/rust-proc-macro.cc (BangProcMacro::BangProcMacro): Add constructor implementation. (AttributeProcMacro::AttributeProcMacro): Likewise. (CustomDeriveProcMacro::CustomDeriveProcMacro): Likewise. * expand/rust-proc-macro.h (class BangProcMacro): Move class to here. (class AttributeProcMacro): Likewise. (class CustomDeriveProcMacro): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go): Change top level visitor to check mappings instead * rust-session-manager.cc (Session::load_extern_crate): Add back macro collection to mappings. * util/rust-hir-map.cc (Mappings::insert_derive_proc_macros): Update getter signature with new types. (Mappings::insert_bang_proc_macros): Likewise. (Mappings::insert_attribute_proc_macros): Likewise. (Mappings::lookup_derive_proc_macros): Likewise. (Mappings::lookup_bang_proc_macros): Likewise. (Mappings::lookup_attribute_proc_macros): Likewise. (Mappings::insert_derive_proc_macro_def): Likewise. (Mappings::insert_bang_proc_macro_def): Likewise. (Mappings::insert_attribute_proc_macro_def): Likewise. (Mappings::lookup_derive_proc_macro_def): Likewise. (Mappings::lookup_bang_proc_macro_def): Likewise. (Mappings::lookup_attribute_proc_macro_def): Likewise. (Mappings::insert_derive_proc_macro_invocation): Likewise. (Mappings::lookup_derive_proc_macro_invocation): Likewise. (Mappings::insert_bang_proc_macro_invocation): Likewise. (Mappings::lookup_bang_proc_macro_invocation): Likewise. (Mappings::insert_attribute_proc_macro_invocation): Likewise. (Mappings::lookup_attribute_proc_macro_invocation): Likewise. * util/rust-hir-map.h: Update function prototypes as well as map types. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add proc macro top level discoveryPierre-Emmanuel Patry1-13/+6
Add mechanism to discover proc macros in loaded extern crates. In the top level resolver. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go): Visit crate's newly stored proc macros. * rust-session-manager.cc (Session::load_extern_crate): Store proc macros in the parsed crate instead of a local variable to achieve mappings. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Collect error instance instead of lambda functionsPierre-Emmanuel Patry1-2/+2
Use error object instead of lambda for error collection. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Collect error instead of lambda. * resolve/rust-early-name-resolver-2.0.h (std::function<void): Remove type alias. * rust-diagnostics.h: Change collection type. * rust-session-manager.cc (Session::expansion): Change collection container. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Resolve nested macro definitionPierre-Emmanuel Patry1-1/+10
We need to collect the early resolver's macros error to emit them at a later stage after further expansion in order to retrieve macros defined by other macro invocations. Register some mappings for macro invocations and macro definitions. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Collect error instead of emitting it. Also add invocation registration. * resolve/rust-early-name-resolver-2.0.h (std::function<void): Add type definition for collection. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Register macro rule definition in mappings. * rust-session-manager.cc (Session::expansion): Add macro resolve error collection. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add punycode encoding to v0 manglingRaiki Tamura1-1/+1
gcc/rust/ChangeLog: * backend/rust-mangle.cc (v0_add_identifier): Added punycode encoding (v0_mangle_item): Likewise. * lex/rust-lex.cc (assert_source_content): Change type (test_buffer_input_source): Change type (test_file_input_source): Change type * resolve/rust-ast-resolve-toplevel.h: fix typo * rust-session-manager.cc (Session::load_extern_crate): fix typo * util/rust-canonical-path.h: fix typo * util/rust-hir-map.cc (NodeMapping::get_error): fix typo (Mappings::Mappings): fix typo * util/rust-mapping-common.h (UNKNOWN_CREATENUM): fix typo (UNKNOWN_CRATENUM): Change 0 to UINT32_MAX Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: macro-expand: Keep optional references to last_{def, invoc}Arthur Cohen1-3/+3
This avoids a use-after-free when reaching the recursion limit. gcc/rust/ChangeLog: * expand/rust-macro-expand.h: Keep optional references for last_def and last_invoc. * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Store optional references. * rust-session-manager.cc (Session::expansion): Use tl::optional's APIs for better checking.
2024-01-16gccrs: Normalize all identifier tokensRaiki Tamura1-5/+4
gcc/rust/ChangeLog: * lex/rust-lex.cc (assert_source_content): Fix namespace specifier (test_buffer_input_source): Likewise. (test_file_input_source): Likewise. * lex/rust-lex.h: Move InputSource ... * lex/rust-input-source.h: ... to here. (New file) * lex/rust-token.cc (nfc_normalize_token_string): New function * lex/rust-token.h (nfc_normalize_token_string): New function * rust-lang.cc (run_rust_tests): Modify order of selftests. * rust-session-manager.cc (validate_crate_name): Modify interface of Utf8String. * util/rust-unicode.cc (lookup_cc): Modify codepoint_t typedef. (lookup_recomp): Likewise. (recursive_decomp_cano): Likewise. (decomp_cano): Likewise. (sort_cano): Likewise. (compose_hangul): Likewise. (assert_normalize): Likewise. (Utf8String::nfc_normalize): New function. * util/rust-unicode.h: Modify interface of Utf8String. gcc/testsuite/ChangeLog: * rust/compile/unicode_norm1.rs: New test. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: session-manager: Run name resolution 2.0 if the option is presentArthur Cohen1-1/+11
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::expansion): Use new `Early` name resolution 2.0 pass
2024-01-16gccrs: Add Unicode check for crate_name attributesRaiki Tamura1-10/+24
gcc/rust/ChangeLog: * lex/rust-codepoint.h: Add comment * lex/rust-lex.h: New method to get decoded characters * rust-session-manager.cc (validate_crate_name): Modify unicode check (rust_crate_name_validation_test): Add testcases * util/rust-unicode.h (RUST_UNICODE_H): New class Utf8String. (class Utf8String): New class. * util/rust-unicode.cc (binary_search_sorted_array): Add comment. (recursive_decomp_cano): Add comment. (recomp): Remove dead code. (dump_string): Removed. gcc/testsuite/ChangeLog: * rust/compile/bad-crate-name.rs: Moved to... * rust/compile/bad-crate-name1.rs: ...here. * rust/compile/bad-crate-name2.rs: New test. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: Begin enforcing Sized properly and support anti traits like ?SizedPhilip Herron1-1/+1
Sized is implicitly applied to every generic type parameter apart from the implicit Self type parameter on traits, as that would cause a recursive bound and would make Traits unable to be appied to unsized types. In order to keep everything happy this means we also need to support the anti trait bound '?' so that Sized can be removed properly. The full Sized rules are not completely implemented here. Slice's and Str's are currently marked as Sized but there is a small regression here that looks like a more general bug which should be fixed on its own as part of #2443. There is a big testsuite update here to pull in the Sized lang item. Note this lays the bound's ground work so we can start supporting Drop trait properly which needs tackled very soon. Fixes: #2375 Addresses: #2443 gcc/rust/ChangeLog: * expand/rust-proc-macro.cc (literal_from_string): update Lexer constructor (tokenstream_from_string): likewise * lex/rust-lex.cc (Lexer::Lexer): likewise * lex/rust-lex.h: pass through Linemap * parse/rust-cfg-parser.cc (parse_cfg_option): likewise * rust-session-manager.cc (Session::load_extern_crate): likewise * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): dont apply Sized on self * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): new * typecheck/rust-hir-type-check-base.h: add prototype * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::Resolve): apply Sized (TypeResolveGenericParam::visit): likewise * typecheck/rust-hir-type-check-type.h: update prototypes * typecheck/rust-typecheck-context.cc: remove bad assertions * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): cleanup (TypeCheckBase::get_predicate_from_bound): apply sized rules properly * util/rust-hir-map.cc (Mappings::lookup_trait_item_lang_item): helpers (Mappings::get_lang_item): likewise * util/rust-hir-map.h: likewise * util/rust-token-converter.cc (from_ident): update lexer ctor (from_punct): likewise gcc/testsuite/ChangeLog: * rust/compile/bounds1.rs: Apply sized trait * rust/compile/canonical_paths1.rs: likewise * rust/compile/cast_generics.rs: likewise * rust/compile/closure_no_type_anno.rs: likewise * rust/compile/complex_qualified_path_in_expr.rs: likewise * rust/compile/const-issue1440.rs: likewise * rust/compile/const_generics_1.rs: likewise * rust/compile/const_generics_8.rs: likewise * rust/compile/derive_macro1.rs: likewise * rust/compile/derive_macro3.rs: likewise * rust/compile/derive_macro4.rs: likewise * rust/compile/derive_macro6.rs: likewise * rust/compile/expected_type_args2.rs: likewise * rust/compile/expected_type_args3.rs: likewise * rust/compile/generics1.rs: likewise * rust/compile/generics11.rs: likewise * rust/compile/generics12.rs: likewise * rust/compile/generics2.rs: likewise * rust/compile/generics3.rs: likewise * rust/compile/generics4.rs: likewise * rust/compile/generics6.rs: likewise * rust/compile/generics7.rs: likewise * rust/compile/generics8.rs: likewise * rust/compile/if_let_expr.rs: likewise * rust/compile/issue-1005.rs: likewise * rust/compile/issue-1019.rs: likewise * rust/compile/issue-1031.rs: likewise * rust/compile/issue-1034.rs: likewise * rust/compile/issue-1128.rs: likewise * rust/compile/issue-1129-2.rs: likewise * rust/compile/issue-1130.rs: likewise * rust/compile/issue-1131.rs: likewise * rust/compile/issue-1165.rs: likewise * rust/compile/issue-1173.rs: likewise * rust/compile/issue-1235.rs: likewise * rust/compile/issue-1237.rs: likewise * rust/compile/issue-1289.rs: likewise * rust/compile/issue-1383.rs: likewise * rust/compile/issue-1447.rs: likewise * rust/compile/issue-1589.rs: likewise * rust/compile/issue-1725-1.rs: likewise * rust/compile/issue-1725-2.rs: likewise * rust/compile/issue-1773.rs: likewise * rust/compile/issue-1786.rs: likewise * rust/compile/issue-1893.rs: likewise * rust/compile/issue-1901.rs: likewise * rust/compile/issue-1930.rs: likewise * rust/compile/issue-1981.rs: likewise * rust/compile/issue-2019-1.rs: likewise * rust/compile/issue-2019-2.rs: likewise * rust/compile/issue-2019-3.rs: likewise * rust/compile/issue-2036.rs: likewise * rust/compile/issue-2037.rs: likewise * rust/compile/issue-2070.rs: likewise * rust/compile/issue-2105.rs: likewise * rust/compile/issue-2106.rs: likewise * rust/compile/issue-2135.rs: likewise * rust/compile/issue-2136-1.rs: likewise * rust/compile/issue-2136-2.rs: likewise * rust/compile/issue-2139.rs: likewise * rust/compile/issue-2142.rs: likewise * rust/compile/issue-2165.rs: likewise * rust/compile/issue-2166.rs: likewise * rust/compile/issue-2190-1.rs: likewise * rust/compile/issue-2190-2.rs: likewise * rust/compile/issue-2195.rs: likewise * rust/compile/issue-2238.rs: likewise * rust/compile/issue-2304.rs: likewise * rust/compile/issue-850.rs: likewise * rust/compile/issue-855.rs: likewise * rust/compile/issue-925.rs: likewise * rust/compile/macro-issue1400.rs: likewise * rust/compile/macro20.rs: likewise * rust/compile/macro23.rs: likewise * rust/compile/macro40.rs: likewise * rust/compile/macro54.rs: likewise * rust/compile/name_resolution2.rs: likewise * rust/compile/name_resolution4.rs: likewise * rust/compile/nested_generic.rs: likewise * rust/compile/parse_associated_type_as_generic_arg.rs: likewise * rust/compile/parse_associated_type_as_generic_arg2.rs: likewise * rust/compile/parse_associated_type_as_generic_arg3.rs: likewise * rust/compile/parse_complex_generic_application.rs: likewise * rust/compile/parse_complex_generic_application2.rs: likewise * rust/compile/path_as_generic_arg.rs: likewise * rust/compile/privacy4.rs: likewise * rust/compile/privacy6.rs: likewise * rust/compile/sizeof-stray-infer-var-bug.rs: likewise * rust/compile/stmt_with_block_dot.rs: likewise * rust/compile/torture/associated_types1.rs: likewise * rust/compile/torture/forward_decl_5.rs: likewise * rust/compile/torture/generics1.rs: likewise * rust/compile/torture/generics10.rs: likewise * rust/compile/torture/generics11.rs: likewise * rust/compile/torture/generics12.rs: likewise * rust/compile/torture/generics13.rs: likewise * rust/compile/torture/generics14.rs: likewise * rust/compile/torture/generics15.rs: likewise * rust/compile/torture/generics16.rs: likewise * rust/compile/torture/generics17.rs: likewise * rust/compile/torture/generics18.rs: likewise * rust/compile/torture/generics19.rs: likewise * rust/compile/torture/generics2.rs: likewise * rust/compile/torture/generics20.rs: likewise * rust/compile/torture/generics21.rs: likewise * rust/compile/torture/generics22.rs: likewise * rust/compile/torture/generics23.rs: likewise * rust/compile/torture/generics24.rs: likewise * rust/compile/torture/generics25.rs: likewise * rust/compile/torture/generics26.rs: likewise * rust/compile/torture/generics27.rs: likewise * rust/compile/torture/generics28.rs: likewise * rust/compile/torture/generics29.rs: likewise * rust/compile/torture/generics3.rs: likewise * rust/compile/torture/generics30.rs: likewise * rust/compile/torture/generics31.rs: likewise * rust/compile/torture/generics32.rs: likewise * rust/compile/torture/generics4.rs: likewise * rust/compile/torture/generics5.rs: likewise * rust/compile/torture/generics6.rs: likewise * rust/compile/torture/generics7.rs: likewise * rust/compile/torture/generics8.rs: likewise * rust/compile/torture/generics9.rs: likewise * rust/compile/torture/intrinsics-2.rs: likewise * rust/compile/torture/intrinsics-6.rs: likewise * rust/compile/torture/intrinsics-7.rs: likewise * rust/compile/torture/intrinsics-8.rs: likewise * rust/compile/torture/issue-1024.rs: likewise * rust/compile/torture/issue-1075.rs: likewise * rust/compile/torture/issue-1432.rs: likewise * rust/compile/torture/issue-1555.rs: likewise * rust/compile/torture/issue-368.rs: likewise * rust/compile/torture/issue-808.rs: likewise * rust/compile/torture/issue-862.rs: likewise * rust/compile/torture/issue-893-2.rs: likewise * rust/compile/torture/issue-893.rs: likewise * rust/compile/torture/must_use2.rs: likewise * rust/compile/torture/nested_fn2.rs: likewise * rust/compile/torture/phantom_data.rs: likewise * rust/compile/torture/range-lang-item1.rs: likewise * rust/compile/torture/traits1.rs: likewise * rust/compile/torture/traits11.rs: likewise * rust/compile/torture/traits12.rs: likewise * rust/compile/torture/traits13.rs: likewise * rust/compile/torture/traits14.rs: likewise * rust/compile/torture/traits15.rs: likewise * rust/compile/torture/traits16.rs: likewise * rust/compile/torture/traits17.rs: likewise * rust/compile/torture/traits18.rs: likewise * rust/compile/torture/traits19.rs: likewise * rust/compile/torture/traits2.rs: likewise * rust/compile/torture/traits3.rs: likewise * rust/compile/torture/traits4.rs: likewise * rust/compile/torture/traits5.rs: likewise * rust/compile/torture/traits6.rs: likewise * rust/compile/torture/traits7.rs: likewise * rust/compile/torture/traits8.rs: likewise * rust/compile/torture/traits9.rs: likewise * rust/compile/torture/transmute-size-check-1.rs: likewise * rust/compile/torture/transmute1.rs: likewise * rust/compile/torture/uninit-intrinsic-1.rs: likewise * rust/compile/torture/utf8_identifiers.rs: likewise * rust/compile/traits1.rs: likewise * rust/compile/traits10.rs: likewise * rust/compile/traits11.rs: likewise * rust/compile/traits12.rs: likewise * rust/compile/traits2.rs: likewise * rust/compile/traits3.rs: likewise * rust/compile/traits4.rs: likewise * rust/compile/traits5.rs: likewise * rust/compile/traits6.rs: likewise * rust/compile/traits7.rs: likewise * rust/compile/traits8.rs: likewise * rust/compile/traits9.rs: likewise * rust/compile/type-bindings1.rs: likewise * rust/compile/unconstrained_type_param.rs: likewise * rust/compile/unsafe10.rs: likewise * rust/execute/torture/closure1.rs: likewise * rust/execute/torture/closure2.rs: likewise * rust/execute/torture/closure3.rs: likewise * rust/execute/torture/closure4.rs: likewise * rust/execute/torture/coercion1.rs: likewise * rust/execute/torture/coercion2.rs: likewise * rust/execute/torture/coercion3.rs: likewise * rust/execute/torture/copy_nonoverlapping1.rs: likewise * rust/execute/torture/derive_macro1.rs: likewise * rust/execute/torture/derive_macro3.rs: likewise * rust/execute/torture/derive_macro4.rs: likewise * rust/execute/torture/index1.rs: likewise * rust/execute/torture/issue-1120.rs: likewise * rust/execute/torture/issue-1133.rs: likewise * rust/execute/torture/issue-1198.rs: likewise * rust/execute/torture/issue-1232.rs: likewise * rust/execute/torture/issue-1249.rs: likewise * rust/execute/torture/issue-1436.rs: likewise * rust/execute/torture/issue-1496.rs: likewise * rust/execute/torture/issue-1720-2.rs: likewise * rust/execute/torture/issue-1720.rs: likewise * rust/execute/torture/issue-2052.rs: likewise * rust/execute/torture/issue-2179.rs: likewise * rust/execute/torture/issue-2180.rs: likewise * rust/execute/torture/issue-2236.rs: likewise * rust/execute/torture/issue-647.rs: likewise * rust/execute/torture/issue-845.rs: likewise * rust/execute/torture/issue-851.rs: likewise * rust/execute/torture/issue-858.rs: likewise * rust/execute/torture/macros23.rs: likewise * rust/execute/torture/macros28.rs: likewise * rust/execute/torture/method2.rs: likewise * rust/execute/torture/method3.rs: likewise * rust/execute/torture/method4.rs: likewise * rust/execute/torture/operator_overload_1.rs: likewise * rust/execute/torture/operator_overload_10.rs: likewise * rust/execute/torture/operator_overload_11.rs: likewise * rust/execute/torture/operator_overload_12.rs: likewise * rust/execute/torture/operator_overload_2.rs: likewise * rust/execute/torture/operator_overload_3.rs: likewise * rust/execute/torture/operator_overload_4.rs: likewise * rust/execute/torture/operator_overload_5.rs: likewise * rust/execute/torture/operator_overload_6.rs: likewise * rust/execute/torture/operator_overload_7.rs: likewise * rust/execute/torture/operator_overload_8.rs: likewise * rust/execute/torture/operator_overload_9.rs: likewise * rust/execute/torture/prefetch_data.rs: likewise * rust/execute/torture/ref-pattern2.rs: likewise * rust/execute/torture/slice-magic.rs: likewise * rust/execute/torture/slice-magic2.rs: likewise * rust/execute/torture/slice1.rs: likewise * rust/execute/torture/str-layout1.rs: likewise * rust/execute/torture/trait1.rs: likewise * rust/execute/torture/trait10.rs: likewise * rust/execute/torture/trait11.rs: likewise * rust/execute/torture/trait12.rs: likewise * rust/execute/torture/trait13.rs: likewise * rust/execute/torture/trait2.rs: likewise * rust/execute/torture/trait3.rs: likewise * rust/execute/torture/trait4.rs: likewise * rust/execute/torture/trait5.rs: likewise * rust/execute/torture/trait6.rs: likewise * rust/execute/torture/trait7.rs: likewise * rust/execute/torture/trait8.rs: likewise * rust/execute/torture/trait9.rs: likewise * rust/execute/torture/transmute1.rs: likewise * rust/execute/torture/wrapping_op1.rs: likewise * rust/execute/torture/wrapping_op2.rs: likewise * rust/link/generic_function_0.rs: likewise * rust/link/generic_function_1.rs: likewise * rust/compile/issue-2375.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: resolve: Add extern crate proc macro collectionPierre-Emmanuel Patry1-0/+26
Create a mapping for procedural macros with their crate num. gcc/rust/ChangeLog: * metadata/rust-extern-crate.h: Add proc macro getter. * rust-session-manager.cc (Session::load_extern_crate): Collect mappings and create mappings. * util/rust-hir-map.cc: Add insertion and lookup functions for every mapping. * util/rust-hir-map.h: Add function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: import: Change raw pointer to unique_ptrPierre-Emmanuel Patry1-1/+2
Replace Stream raw pointer with a smart pointer. gcc/rust/ChangeLog: * metadata/rust-import-archive.cc (Stream_concatenate::do_peek): Remove deletion. (Stream_concatenate::do_advance): Likewise. (Import::find_archive_export_data): Replace with a smart pointer. * metadata/rust-imports.cc (add_search_path): Change return type to smart pointer. (Import::open_package): Likewise. (Import::try_package_in_directory): Likewise. (Import::find_export_data): Likewise. (Import::find_object_export_data): Likewise. (Import::Import): Change constructor to accept unique_ptr. * metadata/rust-imports.h: Change constructor prototype. * rust-session-manager.cc (Session::load_extern_crate): Change pointer to smart pointer. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: import: Store procedural macros in extern cratePierre-Emmanuel Patry1-1/+1
Store procedural macro data in extern crate node. gcc/rust/ChangeLog: * metadata/rust-extern-crate.cc (ExternCrate::ExternCrate): Change constructor to accept procedural macro vector. * metadata/rust-extern-crate.h: Add vector of procecural macro in extern crate. * rust-session-manager.cc (Session::load_extern_crate): Add argument to new constructor call. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>