Skip to content

Conversation

@dkm
Copy link
Member

@dkm dkm commented Oct 29, 2025

This is a fake PR, not meant to be merged. It tries to merge commits to upstream with an upstream base branch dkm/upstream-base.
We're only interested by the CI results.
-- gerris 🦀

P-E-P and others added 30 commits October 29, 2025 12:25
Previous code was technically valid since the moved from vector was
empty but explicitly setting it empty with it's own name will help.

gcc/rust/ChangeLog:

	* expand/rust-derive-eq.cc: Use empty vector explicitly.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Renames HIR::TupleItems to PatternItems for better generalization because it will be reused for
SlicePattern in the future. Enum values MULTIPLE/RANGED are renamed to NO_REST/HAS_REST
to reduce misleadingness as it is completely different and separate from the ranged values  `..`
representation. This results in renaming of all related classes and updates to all code that
references them.

gcc/rust/ChangeLog:

	* hir/tree/rust-hir-pattern.h:
		- Rename TupleItems to PatternItems.
		- Rename TuplePatternItemsMultiple/Ranged & TupleStructItemsRange/NoRange to
		TuplePatternItemsNoRest/HasRest and TupleStructItemsNoRest/HasRest.
		- Update enum values to NO_REST/HAS_REST.
		- Rename clone_tuple_items_impl to clone_pattern_items_impl.
	* hir/tree/rust-hir-full-decls.h: Renamed the classes accordingly.
	* hir/tree/rust-hir-visitor.h: Renamed the classes accordingly.
	* hir/tree/rust-hir-visitor.cc: Renamed the classes accordingly.
	* hir/rust-hir-dump.h: Renamed the classes accordingly.
	* hir/rust-hir-dump.cc: Renamed the classes accordingly.
	* hir/tree/rust-hir.cc: Renamed the classes accordingly.
	* hir/rust-ast-lower-base.cc: Renamed the classes accordingly.
	* hir/rust-ast-lower-pattern.cc: Renamed the classes accordingly.
	* backend/rust-compile-pattern.cc: Renamed the classes accordingly.
	* backend/rust-compile-var-decl.h: Renamed the classes accordingly.
	* checks/errors/borrowck/rust-bir-builder-pattern.cc: Renamed the classes accordingly.
	* checks/errors/borrowck/rust-bir-builder-struct.h: Renamed the classes accordingly.
	* checks/errors/borrowck/rust-function-collector.h: Renamed the classes accordingly.
	* checks/errors/rust-const-checker.cc: Renamed the classes accordingly.
	* checks/errors/rust-const-checker.h: Renamed the classes accordingly.
	* checks/errors/rust-hir-pattern-analysis.cc: Renamed the classes accordingly.
	* checks/errors/rust-hir-pattern-analysis.h: Renamed the classes accordingly.
	* checks/errors/rust-unsafe-checker.cc: Renamed the classes accordingly.
	* checks/errors/rust-unsafe-checker.h: Renamed the classes accordingly.
	* checks/errors/rust-readonly-check2.cc: Renamed the classes accordingly.
	* typecheck/rust-hir-type-check-pattern.cc: Update references to renamed classes and enum
	values.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
Also adjusts a few error messages to be more in line with rustc (and
more amenable to extract_string_literal usage).

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (Attributes::extract_string_literal):
	New function definition.
	* util/rust-attributes.h (Attributes::extract_string_literal):
	New function declaration.
	* ast/rust-collect-lang-items.cc (get_lang_item_attr): Use
	extract_string_literal.
	* backend/rust-compile-base.cc: Include "rust-attributes.h".
	(HIRCompileBase::handle_link_section_attribute_on_fndecl):
	Use extract_string_literal.
	(HIRCompileBase::handle_must_use_attribute_on_fndecl): Likewise.
	* hir/rust-ast-lower-base.cc
	(ASTLoweringBase::handle_lang_item_attribute): Likewise.
	* rust-session-manager.cc (Session::handle_crate_name):
	Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Header relied on transitive header inclusion.

gcc/rust/ChangeLog:

	* ast/rust-ast-formatting.h (RUST_AST_FORMATTING_H): Include required
	headers directly.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
CfgAttribute copy constructor did not copy cfg_attrs properly.

gcc/rust/ChangeLog:

	* ast/rust-cond-compilation.h: Copy cfg_attrs

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* ast/rust-pattern.h: Include header directly.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* ast/rust-cond-compilation.h: Move vector instead of passing it by
	value.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* ast/rust-type.h: Update member instead of parameter

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* ast/rust-cond-compilation.h: Delete copy constructor for
	ConfigurationAll and ConfigurationAny.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* checks/lints/rust-lint-marklive-base.h (RUST_HIR_LIVENESS_BASE):
	Remove header includes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* parse/rust-parse.h: Change class to struct for friend qualification.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* util/rust-lang-item.h (RUST_LANG_ITEM_H): Add header guards.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* util/bi-map.h: Add include directive for required declarations.
	* util/fnv-hash.h: Likewise.
	* util/rust-dump.h: Likewise.
	* util/rust-inline-visitor.h: Likewise.
	* util/rust-unwrap-segment.h: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Several place built an object before copying it in a vector. This commit
favorise in place construction and use readily available vector size to
reserve memory beforehand.

gcc/rust/ChangeLog:

	* ast/rust-expr.h (struct TupleClobber): Add constructor.
	* backend/rust-compile-context.h (struct fncontext): Likewise.
	* typecheck/rust-hir-dot-operator.h: Likewise.
	* typecheck/rust-tyty-variance-analysis-private.h (struct Constraint):
	Likewise.
	* typecheck/rust-unify.h: Likewise.
	* ast/rust-ast-builder.cc (Builder::new_lifetime_param): Add memory
	reservation and construct in place.
	(Builder::new_generic_args): Likewise.
	* ast/rust-ast-collector.cc (TokenCollector::newline): Likewise.
	(TokenCollector::indentation): Likewise.
	(TokenCollector::comment): Likewise.
	* ast/rust-desugar-apit.cc: Likewise.
	* ast/rust-path.cc (Path::convert_to_simple_path): Likewise.
	(TypePath::as_simple_path): Likewise.
	* ast/rust-path.h: Likewise.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise.
	(TyTyResolveCompile::create_dyn_obj_record): Likewise.
	* checks/errors/rust-hir-pattern-analysis.cc (Matrix::specialize):
	Likewise.
	(WitnessMatrix::apply_constructor): Likewise.
	(check_match_usefulness): Likewise.
	* expand/rust-derive-clone.cc (DeriveClone::clone_fn): Likewise.
	* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Likewise.
	* expand/rust-macro-expand.cc (MacroExpander::parse_proc_macro_output):
	Likewise.
	* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_generic_args):
	Likewise.
	(ASTLoweringBase::lower_extern_block): Likewise.
	* hir/rust-ast-lower-enumitem.h: Likewise.
	* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
	* hir/rust-ast-lower-extern.h: Likewise.
	* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): Likewise.
	(ASTLowerTraitItem::visit): Likewise.
	* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise.
	* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Likewise.
	* hir/rust-ast-lower.cc (ASTLowering::go): Likewise.
	(ASTLoweringBlock::visit): Likewise.
	(ASTLoweringIfLetBlock::desugar_iflet): Likewise.
	(ASTLoweringExprWithBlock::visit): Likewise.
	(ASTLowerPathInExpression::visit): Likewise.
	(ASTLowerQualPathInExpression::visit): Likewise.
	* hir/tree/rust-hir.cc (PathPattern::convert_to_simple_path): Likewise.
	(TypePath::as_simple_path): Likewise.
	* metadata/rust-export-metadata.cc (ExportContext::emit_function):
	Likewise.
	* parse/rust-parse-impl.h (Parser::parse_decl_macro_def): Likewise.
	(Parser::parse_lifetime_params): Likewise.
	* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
	Likewise.
	(ResolveItem::visit): Likewise.
	(flatten_list): Likewise.
	* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit):
	Likewise.
	* typecheck/rust-autoderef.cc (AutoderefCycle::try_autoderefed):
	Likewise.
	* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsized):
	Likewise.
	* typecheck/rust-hir-dot-operator.cc: Likewise.
	* typecheck/rust-hir-path-probe.cc: Likewise.
	* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait):
	Likewise.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	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-pattern.cc (TypeCheckPattern::visit):
	Likewise.
	* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve):
	Likewise.
	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit):
	Likewise.
	* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn):
	Likewise.
	* typecheck/rust-typecheck-context.cc (TypeCheckContext::push_return_type):
	Likewise.
	(TypeCheckContext::insert_associated_impl_mapping): Likewise.
	* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Likewise.
	(TypeBoundsProbe::add_trait_bound): Likewise.
	(TypeBoundPredicate::operator=): Likewise.
	(TypeBoundPredicateItem::get_tyty_for_receiver): Likewise.
	(TypeBoundPredicate::get_associated_type_items): Likewise.
	* typecheck/rust-tyty-call.cc (TypeCheckMethodCallExpr::go): Likewise.
	* typecheck/rust-tyty-subst.cc (SubstitutionRef::clone_substs):
	Likewise.
	(SubstitutionRef::infer_substitions): Likewise.
	(SubstitutionRef::are_mappings_bound): Likewise.
	* typecheck/rust-tyty-variance-analysis.cc (GenericTyPerCrateCtx::query_generic_variance):
	Likewise.
	(GenericTyVisitorCtx::add_constraint): Likewise.
	* typecheck/rust-tyty.cc (FnPtr::clone): Likewise.
	(DynamicObjectType::get_object_items): Likewise.
	* typecheck/rust-unify.cc (UnifyRules::Resolve): Likewise.
	(UnifyRules::go): Likewise.
	(UnifyRules::expect_tuple): Likewise.
	* util/rust-canonical-path.h: Likewise.
	* util/rust-token-converter.cc (convert): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* expand/rust-macro-expand.cc (transcribe_expression): Parse any
	outer attributes before parsing an expression.
	* parse/rust-parse.h (Parser::parse_outer_attributes): Make
	public.

gcc/testsuite/ChangeLog:

	* rust/compile/attr-macro.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Those tests contains inline assembly which is architecture dependent.

gcc/testsuite/ChangeLog:

	* rust/execute/inline_asm_inout_ident.rs: Add arch filter on test.
	* rust/execute/inline_asm_inout_var.rs: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit):
	Check upper compare operator.
	* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit):
	Handle lowering of exclusive range pattern.
	* hir/tree/rust-hir-pattern.h (class RangePattern):
	Add support for exclusive ranges in HIR representation.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3928.rs: New test.

Signed-off-by: lishin <lishin1008@gmail.com>
This should help detect issues like
#3444.

gcc/rust/ChangeLog:

	* ast/rust-ast.h (Stmt::get_node_id): Make virtual.
	(Type::get_node_id): Likewise.
	(AssociatedItem::get_node_id): New virtual member function.
	* ast/rust-expr.h (TypeCastExpr::get_casted_expr_ptr): New
	member function.
	(TypeCastExpr::get_type_to_cast_to_ptr): Likewise.
	(ClosureExprInner::get_definition_expr_ptr): Likewise.
	* ast/rust-item.h (TypeAlias::get_node_id): New member function
	to override AssociatedItem::get_node_id.
	(ConstantItem::get_node_id): Likewise.
	* expand/rust-expand-visitor.cc
	(ExpandVisitor::maybe_expand_expr): Adjust
	macro_invoc_expect_id.
	(ExpandVisitor::maybe_expand_type): Likewise and add an overload
	for std::unique_ptr<TypeNoBounds>.
	(ExpandVisitor::visit): Check macro_invoc_expect_id and
	generally improve visitors so that the testsuite will still
	pass.
	* expand/rust-expand-visitor.h (ExpandVisitor::ExpandVisitor):
	Initialize member variable macro_invoc_expect_id.
	(ExpandVisitor::maybe_expand_type): Add an overload for
	std::unique_ptr<TypeNoBounds>.
	(ExpandVisitor::expand_macro_children): Adjust
	macro_invoc_expect_id.
	(ExpandVisitor::visit): Add an overload for TypeCastExpr.
	(ExpandVisitor::macro_invoc_expect_id): New member variable.

gcc/testsuite/ChangeLog:

	* rust/compile/macros/mbe/macro49.rs: Add missing lang items.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_asm): Simplify expression.
	(parse_llvm_asm): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Fix #4046 where the inline llvm_asm macro parser did not
expect a comma.

gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_llvm_clobbers): Expect a
	comma between clobbers.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
llvm_asm was never meant to be completely supported since it has been
replaced with the asm macro but we still need it to compile some parts
of libcore, previously the compiler was aborting when an unsupported
llvm_asm construct was found.

gcc/rust/ChangeLog:

	* ast/rust-expr.h: Add const getters to llvm members.
	* hir/rust-ast-lower-expr.cc (check_llvm_asm_support): Check llvm_asm
	usage validity.
	(ASTLoweringExpr::visit): Emit an error message instead of aborting.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import):
	Do not abort on wildcard patterns.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/testsuite/ChangeLog:

	* rust/compile/import_wildcards.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* expand/rust-cfg-strip.cc: Include "rust-macro-expand.h".
	(fails_cfg): Rename to...
	(CfgStrip::fails_cfg): ...here and handle test attributes.
	(fails_cfg_with_expand): Rename to...
	(CfgStrip::fails_cfg_with_expand): ...here and handle test
	attributes.
	* expand/rust-cfg-strip.h (struct ExpansionCfg): Forward
	declare.
	(CfgStrip::fails_cfg): New member function.
	(CfgStrip::fails_cfg_with_expand): Likewise.
	(CfgStrip::CfgStrip): Accept reference to ExpansionCfg.
	(CfgStrip::expansion_cfg): New member variable.
	* rust-session-manager.cc (Session::expansion): Pass
	ExpansionCfg instance to CfgStrip constructor.

gcc/testsuite/ChangeLog:

	* rust/compile/cfg-test.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/ChangeLog:

	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): fix error code

Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-stmt.h:
	Add name resolution processing for discriminant values.
gcc/testsuite/ChangeLog:

	* rust/compile/enum_discriminant3.rs: New test.

Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
Fixes #4054

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h
	(Parser::parse_identifier_or_keyword_token): Record error on
	failure.

gcc/testsuite/ChangeLog:

	* rust/compile/macros/mbe/macro-issue4054.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/ChangeLog:

	* ast/rust-ast.h: Change NodeType to enum class Kind.
	* ast/rust-ast-fragment.cc: Use new names.
	* ast/rust-ast-fragment.h: Likewise.
	* ast/rust-ast.cc (SingleASTNode::SingleASTNode): Likewise.
gcc/rust/ChangeLog:

	* ast/rust-ast-fragment.cc (Fragment::is_pattern_fragment): New function.
	(Fragment::take_pattern_fragment): Likewise.
	(Fragment::assert_single_fragment): Likewise.
	* ast/rust-ast-fragment.h: Declare them.
	* ast/rust-ast.cc (SingleASTNode::SingleASTNode): Add new constructor for pattern
	single AST nodes.
	(SingleASTNode::operator=): Handle patterns.
	(SingleASTNode::accept_vis): Likewise.
	(SingleASTNode::is_error): Likewise.
	(SingleASTNode::as_string): Likewise.
	* ast/rust-ast.h: Add get_pattern_ptr() functions.
	* ast/rust-expr.h: Likewise.
	* ast/rust-item.h: Likewise.
	* ast/rust-pattern.h: Likewise.
	* ast/rust-stmt.h: Likewise.
	* expand/rust-expand-visitor.cc (derive_item): Use new API enum values.
	(expand_item_attribute): Likewise.
	(expand_stmt_attribute): Likewise.
	(ExpandVisitor::maybe_expand_pattern): New function.
	(ExpandVisitor::expand_closure_params): Handle patterns.
	(ExpandVisitor::visit): Add new visitors for patterns and missed exprs.
	* expand/rust-expand-visitor.h: Declare them.
	* expand/rust-macro-expand.cc (transcribe_pattern): New function.
	(transcribe_context): Call it.
	* expand/rust-macro-expand.h (struct MacroExpander): New Context type.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3726.rs: New test.
	* rust/compile/issue-3898.rs: New test.
No check was performed and the value was assumed non null.
Path conversion returned an empty path for "Self" due to a hack in
generics Self injection that prevented any "Self!" macro from beeing
recognized correctly.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_stmt_or_expr): Add null check
	on parse_macro_invocation_partial call.
	* ast/rust-path.cc (Path::convert_to_simple_path): Do not exclude
	capitalized "Self".

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3974.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
P-E-P and others added 26 commits October 29, 2025 22:26
Emitting the errors later means some error could be emitted multiple
times.

gcc/rust/ChangeLog:

	* expand/rust-macro-expand.cc (transcribe_expression): Emit error
	early.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* expand/rust-macro-expand.cc: Forward invocation tree locus to
	substitution context.
	* expand/rust-macro-substitute-ctx.cc: Use origin location for expanded
	tokens.
	* expand/rust-macro-substitute-ctx.h (class SubstituteCtx): Save
	invocation location.

gcc/testsuite/ChangeLog:

	* rust/compile/macros/mbe/macro58.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* expand/rust-expand-visitor.cc: Remove old visitors.
	* expand/rust-expand-visitor.h: Likewise, plus inherit from PointerVisitor.
gcc/rust/ChangeLog:

	* backend/rust-compile-extern.h: Add includes.
	(CompileExternItem::visit): Use get_link_name.
	(CompileExternItem::get_link_name): New static member function.
	* util/rust-attribute-values.h (Attributes::LINK_NAME): New
	static constexpr member variable.
	* util/rust-attributes.cc (__definitions): New entry for
	LINK_NAME.
	* util/rust-ggc.cc: Include "rust-ast.h".
	(Ident::Ident): Add overload for Rust::Identifier.
	* util/rust-ggc.h (class Identifier): Forward declare.
	(Ident::Ident): Add overload for Rust::Identifier.

gcc/testsuite/ChangeLog:

	* rust/execute/torture/link-name.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/ChangeLog:

	* ast/rust-pattern.h (StructPatternElements): Rename has_struct_pattern_etc
	to has_rest_pattern, and has_etc to has_rest to signify presense of rest
	patterns more clearly.
	* ast/rust-pattern.cc (StructPatternElements::as_string): Rename variables
	accordingly.
	* ast/rust-ast-collector.cc: Rename variables accordingly.
	* expand/rust-cfg-strip.cc: Rename variables accordingly.
	* parse/rust-parse-impl.h: Rename variable accordingly.
	* hir/tree/rust-hir-pattern.h (StructPatternElements): Add a boolean to track
	presense of rest pattern.
	* hir/rust-ast-lower-pattern.cc (visit(StructPattern)): Add support for
	lowering rest pattern to HIR.
	* typecheck/rust-hir-type-check-pattern.cc (visit(StructPattern)): Remove
	size check when rest pattern is present.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
Previously, type checking of StructPattern will throw an error if it is used
to match against a tuple struct, even though it is possible to do so in rustc.

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-pattern.cc (visit(StructPattern)): Add type check
	support for StructPatterns matching against a TUPLE type ADT.
	* backend/rust-compile-pattern.cc(CompilePatternBindings::visit(StructPattern)):
	Update assert to allow TUPLE type ADTs.
	* hir/tree/rust-hir.cc (StructPatternField::as_string()): Improve info dumped.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
This adds compilation of libcore up to the AST validation phase to the
testsuite.

gcc/testsuite/ChangeLog:

	* rust/core/core.exp: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Adds a test to verify extra parentheses are discarded, and the source is
compiled as expected.

Resolves: #2886

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4148.rs: New test.

Signed-off-by: Elle Rhumsaa <elle@weathered-steel.dev>
gcc/rust/ChangeLog:

	* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit(TupleStructPattern)):
	Implement lowering of AST::TupleStructItemsHasRest to HIR.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit(TupleStructPattern)):
	Add the respective type checking for AST::TupleStructItemsHasRest
	* checks/errors/rust-hir-pattern-analysis.cc (lower_tuple_pattern):
	Add respective pattern for HAS_REST case.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc: Add compilation support for TupleStructItemsHasRest
	in CompilePatternCheckExpr(TupleStructPattern) & CompilePatternBindings(TupleStructPattern)

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
…error

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-pattern.cc (visit(TupleStructPattern)):
	Update error for mismatched number of fields to use rich_location.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
Path must be made of a single literal item, otherwise an error should be
thrown.

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (AttributeChecker::check_attribute): Recurse
	within attr input for additional attribute checking.
	(AttributeChecker::visit): Remove empty definition in favor of default
	ast visitor definition.
	* util/rust-attributes.h: Remove now unused prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* ast/rust-ast.h: Add missing override modifier.
	* ast/rust-path.h: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
We still don't know which location should be preferred over the other,
this means that nobody should rely on this function's return value.

gcc/rust/ChangeLog:

	* ast/rust-expr.h: Force crash when retrieving locus.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Add location for malformed attribute errors and avoid processing of
malformed attributes.

gcc/rust/ChangeLog:

	* ast/rust-ast.cc (AttrInputMetaItemContainer::separate_cfg_attrs):
	Avoid malformed attributes.
	* util/rust-attributes.cc (AttributeChecker::visit): Change location.

gcc/testsuite/ChangeLog:

	* rust/compile/attr_malformed_path.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Doc attribute checking was not performed on traits.

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_doc_attribute): Change message.
	(AttributeChecker::visit): Add doc attribute checking on traits.

gcc/testsuite/ChangeLog:

	* rust/compile/attr_malformed_doc.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Converts an assert into an early return during AST parsing.

Resolves: #4145

gcc/rust/ChangeLog:

	* ast/rust-ast.cc (Module::process_file_path): empty module early return

Signed-off-by: Elle Rhumsaa <elle@weathered-steel.dev>
gcc/testsuite/ChangeLog:

	* rust/compile/issue-4145.rs: New test.

Signed-off-by: Elle Rhumsaa <elle@weathered-steel.dev>
This patch refactors the const generic type system to follow the same pattern
as regular type parameters. The monolithic ConstType is split into four
distinct types:

  ConstParamType (generic parameter placeholder)
  ConstValueType (resolved constant value)
  ConstInferType (inference variable)
  ConstErrorType (error sentinel)

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::array_copied_expr): refactor to new classes
	* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): likewise
	(CompilePatternBindings::visit): likewise
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): likewise
	* backend/rust-compile-type.h: likewise
	* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): likewise
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): likewise
	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): likewise
	* typecheck/rust-substitution-mapper.h: likewise
	* typecheck/rust-type-util.cc (unify_site_and): remove bad delete (alpine32)
	* typecheck/rust-tyty-call.h: refactor to new classes
	* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::clone): likewise
	(SubstitutionRef::infer_substitions): likewise
	* typecheck/rust-tyty-util.cc (TyVar::get_implicit_const_infer_var): likewise
	* typecheck/rust-tyty-util.h: likewise
	* typecheck/rust-tyty-variance-analysis-private.h: likewise
	* typecheck/rust-tyty-visitor.h: likewise
	* typecheck/rust-tyty.cc (BaseType::destructure): likewise
	(BaseType::monomorphized_clone): likewise
	(BaseType::is_concrete): likewise
	(VariantDef::clone): likewise
	(VariantDef::monomorphized_clone): likewise
	(ArrayType::as_string): likewise
	(ArrayType::get_capacity): likewise
	(ArrayType::handle_substitions): likewise
	(generate_tree_str): likewise
	(ConstType::ConstType): likewise
	(ConstParamType::ConstParamType): likewise
	(ConstType::accept_vis): likewise
	(ConstParamType::const_kind): likewise
	(ConstParamType::get_symbol): likewise
	(ConstParamType::can_resolve): likewise
	(ConstParamType::resolve): likewise
	(ConstParamType::accept_vis): likewise
	(ConstType::set_value): likewise
	(ConstType::as_string): likewise
	(ConstParamType::as_string): likewise
	(ConstType::clone): likewise
	(ConstParamType::clone): likewise
	(ConstType::get_symbol): likewise
	(ConstParamType::get_name): likewise
	(ConstType::can_resolve): likewise
	(ConstParamType::is_equal): likewise
	(ConstType::resolve): likewise
	(ConstValueType::ConstValueType): likewise
	(ConstValueType::const_kind): likewise
	(ConstValueType::accept_vis): likewise
	(ConstValueType::as_string): likewise
	(ConstValueType::clone): likewise
	(ConstValueType::get_name): likewise
	(ConstValueType::is_equal): likewise
	(ConstValueType::get_value): likewise
	(ConstInferType::ConstInferType): likewise
	(ConstInferType::const_kind): likewise
	(ConstInferType::accept_vis): likewise
	(ConstType::get_name): likewise
	(ConstInferType::as_string): likewise
	(ConstInferType::clone): likewise
	(ConstInferType::get_name): likewise
	(ConstType::is_equal): likewise
	(ConstInferType::is_equal): likewise
	(ConstErrorType::ConstErrorType): likewise
	(ConstErrorType::const_kind): likewise
	(ConstType::handle_substitions): likewise
	(ConstErrorType::accept_vis): likewise
	(ConstErrorType::as_string): likewise
	(ConstErrorType::clone): likewise
	(ConstErrorType::get_name): likewise
	(ConstErrorType::is_equal): likewise
	* typecheck/rust-tyty.h (class BaseConstType): likewise
	(class ConstType): likewise
	(class ConstParamType): likewise
	(class ConstValueType): likewise
	(class ConstInferType): likewise
	(class ConstErrorType): likewise
	* typecheck/rust-unify.cc (UnifyRules::commit): likewise
	(UnifyRules::go): likewise
	(UnifyRules::expect_array): likewise
	(UnifyRules::expect_const): likewise
	* typecheck/rust-unify.h: likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Fixes #3927

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check
	and properly emit an error when the tuple index is on a non-tuple-struct.

gcc/testsuite/ChangeLog:

	* rust/compile/tuple_index_on_non_tuple.rs: New test.

Signed-off-by: Ryo Yoshida <low.ryoshida@gmail.com>
gcc/rust/ChangeLog:

	* typecheck/rust-tyty-util.cc (TyVar::TyVar): Add null check to avoid ICE.
	(TyVar::get_tyty): Return nullptr when lookup fails.
	(TyVar::clone): Handle null base type safely.
	(TyVar::monomorphized_clone): Add fallback for error types.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3556.rs: New test.

Signed-off-by: lishin <lishin1008@gmail.com>
gcc/rust/ChangeLog:

	* ast/rust-ast.cc (Attribute::is_derive):
	Change string derive to its definition.
	* util/rust-attribute-values.h:
	Add attribute definition derive.
	* util/rust-attributes.cc (AttributeChecker::visit):
	Add method check_inner_attributes.
	(AttributeChecker::check_inner_attributes):
	Check if there is a bad inner attribute.
	* util/rust-attributes.h:
	Add method check_inner_attributes in .h.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4212.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.fr>
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-base.cc (parse_repr_options): Changed TOKEN_TREE
	assert into error, update malformed repr attribute error message to be inline
	with other attribute error messages.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
When we typecheck a tuple struct pattern and the type of its path is
an enum, it may refer to the enum itself and not a variant. Emit an
E0532 error on such cases.

Fixes #3917
Fixes #3918
Fixes #3926

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Emit
	an error when the path refers to an enum itself rather than its variant.

gcc/testsuite/ChangeLog:

	* rust/compile/match-tuplestructpattern-non-variant.rs: New test.

Signed-off-by: Ryo Yoshida <low.ryoshida@gmail.com>
…pattern

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-pattern.cc (visit(TuplePattern)): Update HAS_REST
	case to continue to attempt to resolve pattern items after emitting size error.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
gcc/rust/ChangeLog:

	* ast/rust-ast-pointer-visitor.cc (PointerVisitor::visit):
	Handle the expression contained in an ErrorPropagationExpr.
	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
@dkm dkm force-pushed the gerris/rebase/2025-10-29 branch from fe11f99 to a1c4558 Compare October 29, 2025 21:26
@dkm
Copy link
Member Author

dkm commented Oct 29, 2025

Removed the reverts and fixed all issue ref missing the prefix (we really need to fix the checker here). Thanks @powerboat9

@dkm
Copy link
Member Author

dkm commented Nov 2, 2025

All pushed upstream

@dkm dkm closed this Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.