Skip to content

Conversation

dkm
Copy link
Member

@dkm dkm commented Sep 9, 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 September 9, 2025 09:11
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Ryutaro Okada <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
philberty and others added 30 commits September 9, 2025 09:11
We use the types compatable interface for unify here and so if
we dont respect the commit flag the interface can have unintended
side effects with infer type hints throwing things off down the line.

gcc/rust/ChangeLog:

	* typecheck/rust-unify.cc (UnifyRules::expect_inference_variable): dont commit
	(UnifyRules::expect_adt): 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

Signed-off-by: Philip Herron <[email protected]>
Getting close to getting rid of can_eq and tyty-cmp soon.

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.cc (PathProbeType::process_impl_item_candidate):
	refactor to types_compatable

Signed-off-by: Philip Herron <[email protected]>
We need to make the type bounds check a flag because it can turn into a
recursive type bounds check. This allows us to remove another can_eq usage

gcc/rust/ChangeLog:

	* typecheck/rust-type-util.cc (types_compatable):  add check bounds flag
	(unify_site_and): likewise
	* typecheck/rust-type-util.h (types_compatable): likewise
	(unify_site_and): likewise
	* typecheck/rust-tyty-bounds.cc: likewise
	* typecheck/rust-unify.cc (UnifyRules::UnifyRules): likewise
	(UnifyRules::Resolve): likewise
	(UnifyRules::resolve_subtype): likewise
	(UnifyRules::go): likewise
	* typecheck/rust-unify.h: likewise

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (BaseType::satisfies_bound): use types_compatable instead

gcc/testsuite/ChangeLog:

	* rust/compile/issue-1725-2.rs: remove bad error message

Signed-off-by: Philip Herron <[email protected]>
We should only clone when we commit and it was successful. With no
cloning there is a regression in min specialization 2. Probably because
it needs to know the unify site hirid and ensure we have it set there.

gcc/rust/ChangeLog:

	* typecheck/rust-unify.cc (UnifyRules::Resolve): check for success
	(UnifyRules::expect_inference_variable): dont clone
	(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

Signed-off-by: Philip Herron <[email protected]>
During unification we denote failures using a new error mark node. This
keeps a static one and reuses it instead.

gcc/rust/ChangeLog:

	* typecheck/rust-unify.cc (unify_error_type_node): new static node
	(UnifyRules::go): likewise
	(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
	(UnifyRules::expect_const): likewise

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (ParamType::is_equal): uses types_compatable

Signed-off-by: Philip Herron <[email protected]>
This was an initial helper from back in the day which was not maintained
but was a nice const simple way to check if types are compatable. But
reusing our unify code is much much more acurate and single source of
truth on the type system.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (InferType::can_eq): remove
	(ErrorType::can_eq): likewise
	(ADTType::can_eq): likewise
	(TupleType::can_eq): likewise
	(FnType::can_eq): likewise
	(FnPtr::can_eq): likewise
	(ClosureType::can_eq): likewise
	(ArrayType::can_eq): likewise
	(SliceType::can_eq): likewise
	(BoolType::can_eq): likewise
	(IntType::can_eq): likewise
	(UintType::can_eq): likewise
	(FloatType::can_eq): likewise
	(USizeType::can_eq): likewise
	(ISizeType::can_eq): likewise
	(CharType::can_eq): likewise
	(ReferenceType::can_eq): likewise
	(PointerType::can_eq): likewise
	(ParamType::can_eq): likewise
	(ConstType::can_eq): likewise
	(OpaqueType::can_eq): likewise
	(StrType::can_eq): likewise
	(NeverType::can_eq): likewise
	(PlaceholderType::can_eq): likewise
	(ProjectionType::can_eq): likewise
	(DynamicObjectType::can_eq): likewise
	* typecheck/rust-tyty.h: remove can_eq
	* typecheck/rust-tyty-cmp.h: Removed.

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (VariantDef::clone): fix formatting
	(VariantDef::monomorphized_clone): likewise
	* typecheck/rust-tyty.h: likewise

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-tyty-subst.cc: const generic arguments dont have a value yet

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-base.cc (walk_types_to_constrain): track the ref as well

Signed-off-by: Philip Herron <[email protected]>
When type resolving a function which returns a const generic for example
this means its unifying the ConstType vs the the specified type so this
mean unwrapping the type of the const.

gcc/rust/ChangeLog:

	* typecheck/rust-unify.cc (UnifyRules::go): unwrap the const type

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-unify.cc (UnifyRules::commit): commit hook update
	(UnifyRules::go): insert implicit infer const types

Signed-off-by: Philip Herron <[email protected]>
This doesn't actually handle the attribute, although it does allow us to
recognize it as valid.

gcc/rust/ChangeLog:

	* util/rust-attribute-values.h
	(Attributes::RUSTC_ALLOW_CONST_FN_UNSTABLE): New static
	constexpr member variable.
	* util/rust-attributes.cc (__definitions): Add entry for
	RUSTC_ALLOW_CONST_FN_UNSTABLE.

Signed-off-by: Owen Avery <[email protected]>
gcc/rust/ChangeLog:

	* expand/rust-macro-expand.cc: Adjust includes.
	(MacroExpander::expand_crate): Remove usage of 1.0 resolver.
	* expand/rust-macro-expand.h: Adjust includes.
	(MacroExpander::MacroExpander): Remove initialization of
	resolver member variable.
	(MacroExpander::resolver): Remove member variable.

Signed-off-by: Owen Avery <[email protected]>
GIMPLE dump from compiling issue-3930.rs:

...
  const i32 b;
  const i32 a;

  D.114.__0 = 2;
  D.114.__1 = 3;
  RUSTTMP.1 = D.114;
  a = RUSTTMP.1.__0;
  b = RUSTTMP.1.__1;
...

gcc/rust/ChangeLog:

	* backend/rust-compile-var-decl.h (CompileVarDecl::visit(TuplePattern)): Implement
	variable declaration bindings for tuple patterns with rest pattern (i.e.
	TuplePatternItemsHasRest).

Signed-off-by: Yap Zhi Heng <[email protected]>
gcc/rust/ChangeLog:

	* checks/errors/rust-readonly-check.cc (collect_assignment_tuple): Implement
	read-only checker for tuple patterns with rest pattern.

Signed-off-by: Yap Zhi Heng <[email protected]>
We need to catch the error node for the array capacity and return early.
Otherwise we try to const evaluate something thats just silly. Also
when compiling array expressions we can simply reuse the array capacity
expression we already have cons folded.

Fixes #3965

gcc/rust/ChangeLog:

	* backend/rust-compile-context.h: add assertions for context peeks
	* backend/rust-compile-expr.cc (CompileExpr::visit): check for valid loop context
	(CompileExpr::array_copied_expr): just reuse array tyty capacity value
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): catch error

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3965-1.rs: New test.
	* rust/compile/issue-3965-2.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
We need to add a guard to catch the case when there is no loop context
for break outside of loop.

Fixes #3969

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): add guard

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Use
	resolve_type_path_like in overloads for TypePath,
	StructExprStruct, StructExprStructBase, and
	StructExprStructFields.
	(resolve_type_path_like): New static function based off
	Late::visit overload for TypePath.
	* util/rust-unwrap-segment.h (unwrap_segment_error_string): New
	inline static function definitions.

Signed-off-by: Owen Avery <[email protected]>
This removes large chunks of the 1.0 resolution phase, not the nr1.0
resolver itself quite yet.

gcc/rust/ChangeLog:

	* Make-lang.in (GRS_OBJS): Remove entries.
	* rust-lang.cc: Remove inclusion of "rust-ast-resolve-item.h".
	(run_rust_tests): Remove call to rust_simple_path_resolve_test.
	* resolve/rust-ast-resolve-base.cc: Removed.
	* resolve/rust-ast-resolve-base.h: Removed.
	* resolve/rust-ast-resolve-expr.cc: Removed.
	* resolve/rust-ast-resolve-expr.h: Removed.
	* resolve/rust-ast-resolve-implitem.h: Removed.
	* resolve/rust-ast-resolve-item.cc: Removed.
	* resolve/rust-ast-resolve-item.h: Removed.
	* resolve/rust-ast-resolve-path.cc: Removed.
	* resolve/rust-ast-resolve-path.h: Removed.
	* resolve/rust-ast-resolve-pattern.cc: Removed.
	* resolve/rust-ast-resolve-pattern.h: Removed.
	* resolve/rust-ast-resolve-stmt.cc: Removed.
	* resolve/rust-ast-resolve-stmt.h: Removed.
	* resolve/rust-ast-resolve-struct-expr-field.cc: Removed.
	* resolve/rust-ast-resolve-struct-expr-field.h: Removed.
	* resolve/rust-ast-resolve-toplevel.h: Removed.
	* resolve/rust-ast-resolve-type.cc: Removed.
	* resolve/rust-ast-resolve-type.h: Removed.
	* resolve/rust-ast-resolve.cc: Removed.

Signed-off-by: Owen Avery <[email protected]>
gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
… this

Change this formatting, so clang format stops formatting this wierd for me.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (VariantDef::clone): remove template param
	(VariantDef::monomorphized_clone): likewise

Signed-off-by: Philip Herron <[email protected]>
This reverts commit a50fb38 as it breaks
gcc5 bootstrap.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (VariantDef::clone): revert
	(VariantDef::monomorphized_clone): likewise

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-unify.cc (UnifyRules::expect_reference): remove clone
	(UnifyRules::expect_pointer): likewise
	(UnifyRules::expect_slice): likewise
	(UnifyRules::expect_tuple): likewise
	(UnifyRules::expect_int): likewise
	(UnifyRules::expect_uint): likewise
	(UnifyRules::expect_float): likewise

Signed-off-by: Philip Herron <[email protected]>
This reverts commit 3e52769.

gcc/rust/ChangeLog:

	* expand/rust-macro-expand.cc (MacroExpander::expand_crate): revert
	* expand/rust-macro-expand.h (struct MacroExpander): likewise

Signed-off-by: Philip Herron <[email protected]>
We need to distinguish between abi's and unsafety on fnptrs. There is
a commented out check because there is a regression in:

  rust/compile/try-catch-unwind-{new/old}.rs

But i think this is because the test case should be taking an FnOnce
from reading std::panic in rust 1.49. Where as we are passing an fnptr
which is probably because we didnt support fnonce at all then.

Addresses #4090

gcc/rust/ChangeLog:

	* hir/tree/rust-hir-item.h: add unsafe helper
	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): pass in abi and unsafe
	* typecheck/rust-tyty.cc (BaseType::monomorphized_clone): likewise
	(FnPtr::as_string): emit more info
	(FnPtr::clone): update ctor call
	* typecheck/rust-tyty.h: new ctor params
	* typecheck/rust-unify.cc (UnifyRules::expect_fnptr): check abi and unsafe

Signed-off-by: Philip Herron <[email protected]>
contrib/ChangeLog:

	* gcc-changelog/git_commit.py (ignored_prefixes): Add
	'libgrust/rustc-lib/core/'.

Signed-off-by: Owen Avery <[email protected]>
This commit imports libcore 1.49.0 into a new directory,
"libgrust/rustc-lib/core". LICENSE-* files are taken from the rustc
1.49.0 repository root.

libgrust/ChangeLog:

	* rustc-lib/LICENSE-APACHE: New file.
	* rustc-lib/LICENSE-MIT: New file.
	* rustc-lib/version-info: New file.

Signed-off-by: Owen Avery <[email protected]>
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.

8 participants