Skip to content

Fake PR to test the upstreaming of commit up to gerris/rebase-upstream/2026-08-19 - #4801

Closed
dkm wants to merge 44 commits into
dkm/upstream-basefrom
gerris/rebase-upstream/2026-08-19-for-ci
Closed

dkm wants to merge 44 commits into
dkm/upstream-basefrom
gerris/rebase-upstream/2026-08-19-for-ci

Conversation

@dkm

@dkm dkm commented Aug 19, 2026

Copy link
Copy Markdown
Member

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. The branch to push is in gerris/rebase-upstream/2026-08-19.
-- gerris 🦀

powerboat9 and others added 30 commits August 19, 2026 14:10
Makes ExpandVisitor rely more on functions provided by PointerVisitor.
More can be done in this area, but this is enough for now to fix an
issue compiling core.

gcc/rust/ChangeLog:

	* expand/rust-expand-visitor.cc
	(ExpandVisitor::expand_struct_fields): Remove function
	definition.
	(ExpandVisitor::expand_tuple_fields): Likewise.
	(ExpandVisitor::visit (Function)): Visit outer attributes, add
	comment about inner attribute visiting.
	(ExpandVisitor::visit (StructStruct)): Remove function
	definition.
	(ExpandVisitor::visit (TupleStruct)): Likewise.
	(ExpandVisitor::visit (EnumItemTuple)): Likewise.
	(ExpandVisitor::visit (EnumItemStruct)): Likewise.
	(ExpandVisitor::visit (Union)): Likewise.
	(ExpandVisitor::visit (ExternalStaticItem)): Likewise.
	* expand/rust-expand-visitor.h
	(ExpandVisitor::visit (StructStruct)): Remove function
	declaration.
	(ExpandVisitor::visit (TupleStruct)): Likewise.
	(ExpandVisitor::visit (EnumItemTuple)): Likewise.
	(ExpandVisitor::visit (EnumItemStruct)): Likewise.
	(ExpandVisitor::visit (Union)): Likewise.
	(ExpandVisitor::visit (ExternalStaticItem)): Likewise.
	(ExpandVisitor::expand_fields): Likewise.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Warn on a double arithmetic negation such as `- -x`, which is likely a
mistake (Rust has no `--` operator).

gcc/rust/ChangeLog:

	* checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit):
	New.
	* checks/lints/unused/rust-unused-checker.h (UnusedChecker::visit):
	New.

gcc/testsuite/ChangeLog:

	* rust/compile/double-negations_0.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
When creating the list of generic types for the derived impl, default parameters should be
skipped as they can only be present on type definitions, not impls.

gcc/rust/ChangeLog:

	* ast/rust-ast-builder.h: Add new parameter to Builder::new_type_param to avoid
	recreating default type parameters when building the new type parameter.
	* ast/rust-ast-builder.cc: Implement the change.
	* expand/rust-derive.cc: Use it in setup_impl_generics.

gcc/testsuite/ChangeLog:

	* rust/compile/derive-with-default-types.rs: New test.
And also check attributes only in one place to avoid duplicating error handling.

gcc/rust/ChangeLog:

	* ast/rust-collect-lang-items.cc (get_lang_item_attr): Remove attribute checking
	code as this will be done during lowering.
	* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Mention
	the attribute which is unknown.
Tool attributes are allowed in Rust code, and should be ignored by the
compiler and handled by the specified tools instead.

gcc/rust/ChangeLog:

	* util/rust-attributes.h: Change Attributes::is_known API to return an enum, add
	AttributeKnowledge result enum.
	* util/rust-attribute-values.h: Add more known tool attributes.
	* util/rust-attributes.cc (Attributes::is_known): Check for tool attributes and
	adapt return type.
	* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Use new
	API and ignore tool attributes.
	* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/tool-attribute1.rs: New test.
gcc/rust/ChangeLog:

	* util/rust-lang-item.h: Add enum value for Freeze.
	* util/rust-lang-item.cc: Register it.

gcc/testsuite/ChangeLog:

	* rust/compile/freeze-lang-item.rs: New test.
gcc/rust/ChangeLog:

	* util/rust-lang-item.h: Add enum value for VaListImpl.
	* util/rust-lang-item.cc: Register it.

gcc/testsuite/ChangeLog:

	* rust/compile/va_list-lang-item.rs: New test.
…ait params.

Refactor the check of `_: impl Trait` function arguments to use an enum
class instead of a boolean.

gcc/rust/ChangeLog:

	* hir/rust-ast-lower-type.h: New enum, change API to use it.
	* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): Use the new ImplTrait enum.
	* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise.
	* hir/rust-ast-lower-type.cc (ASTLoweringType::ASTLoweringType): Likewise.
	(ASTLoweringType::translate): Likewise.
	(ASTLoweringType::visit): Likewise.
When desugaring the Argument Position Impl Traits of a function, we still need to visit that
function's block and its items as it may contain other inner functions with other APITs.

gcc/rust/ChangeLog:

	* ast/rust-desugar-apit.cc (DesugarApit::visit): Call DefaultASTVisitor::visit
	on the function we're currently visiting.

gcc/testsuite/ChangeLog:

	* rust/compile/apit-in-inner-fn.rs: New test.
Fixes #4747

Update logic so unused collector tracks the usage of only the last
assignment for a given variable. When a new assignment is encountered
before last one is used, move the prior assignment to a new
unused_assigns set.

gcc/rust/ChangeLog:

	* checks/lints/unused/rust-unused-checker.cc
	(UnusedChecker::visit): Update logic for checking unused
	assignments.
	* checks/lints/unused/rust-unused-context.cc
	(UnusedContext::add_assign): Use new set to track unused
	assignments.
	(UnusedContext::remove_assign): Update to track only last
	assignment.
	(UnusedContext::is_variable_assigned): Likewise.
	(UnusedContext::is_assign_unused): New helper function to
	check if given id was marked as unused by collector.
	* checks/lints/unused/rust-unused-context.h:
	(class UnusedContext): Add new set to track unused assignments and
	changed current structure to track only last assignment per
	variable (one to one map).

gcc/testsuite/ChangeLog:

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

Signed-off-by: Aiman Najjar <aiman.najjar@hurranet.com>
…checks

This patch adds support for structural auto-traits and fixes how negative
trait implementations are handled.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty-bounds.cc
	(TypeBoundsProbe::add_trait_bound): Check all fields of an ADT.
	* typecheck/rust-tyty.cc (BaseType::satisfies_bound): Reject
	trait if there is a negative impl.

Signed-off-by: Enes Cevik <enes@nsvke.com>
This patch adds pin/unpin lang items to the compiler but not fully tested
due to issues #4709 and #4678 so we tested
auto trait and negative impls behaviors.

gcc/rust/ChangeLog:

	* util/rust-lang-item.cc (Rust::LangItem::lang_items): Add pin
	and unpin lang items to the BiMap.
	* util/rust-lang-item.h (class LangItem): Add PIN and UNPIN to
	the Kind enum.

gcc/testsuite/ChangeLog:

	* rust/compile/lang-pin-unpin.rs: New test.

Signed-off-by: Enes Cevik <enes@nsvke.com>
Previously, when using a grouped import that combines `self` and a glob
(e.g., `use path::module::{self, *};`), the compiler successfully
imported the inner items via the glob, but failed to import the base
module (or enum) itself.

This patch ensures `self` imports use their own unique NodeId, preventing
them from being dropped during early resolution.

Fixes #4689

gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc
	(Early::resolve_rebind_import): Use the final segment's NodeId
	for 'self' imports instead of the parent's to avoid clashing with
	glob imports.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Enes Cevik <enes@nsvke.com>
Only type-checking support is implemented, simd representation structs are still
compiled as regular structs.

Note that this implementation is specific to 1.49.0, #[repr(simd)] structs uses
a single array field from 1.50.0 onwards.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty.h (ADTType::ReprKind): Add new SIMD variant.
	* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): Parse
	#[repr(simd)] attribute, rename inline_option to repr_option.
	* typecheck/rust-hir-type-check-item.h (TypeCheckItem::validate_repr_simd): New
	function.
	* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::validate_repr_simd):
	Implement type-checking of #[repr(simd)] structs.
	(TypeCheckItem::visit (HIR::TupleStruct)): Support type-checking simd representation.
	(TypeCheckItem::visit (HIR::StructStruct)): Ditto.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
Slice patterns with bound rest patterns still aren't supported in type
checking and compilation to GENERIC.

gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc
	(CompilePatternBindings::visit (SlicePattern)): Assert that the
	rest pattern isn't bound (currently unsupported).
	* checks/errors/borrowck/rust-bir-builder-pattern.cc
	(PatternBindingBuilder::visit (SlicePattern)): Handle bound rest
	pattern.
	* checks/errors/rust-ast-validation.cc
	(ASTValidation::visit (AST::SlicePattern)): Likewise.
	* hir/rust-ast-lower-pattern.cc
	(ASTLoweringPattern::visit (AST::SlicePattern)): Likewise.
	* hir/rust-hir-dump.cc (Dump::visit (SlicePatternItemsHasRest)):
	Likewise.
	* hir/tree/rust-hir-pattern.h
	(SlicePatternItemsHasRest::rest_bind): New member variable.
	(SlicePatternItemsHasRest::SlicePatternItemsHasRest): Initialize
	rest_bind.
	(SlicePatternItemsHasRest::operator=): Likewise.
	(SlicePatternItemsHasRest::has_rest_bind): New member function.
	(SlicePatternItemsHasRest::get_rest_bind): Likewise.
	* hir/tree/rust-hir-visitor.cc
	(DefaultHIRVisitor::walk (SlicePatternItemsHasRest)): Handle
	bound rest pattern.
	* hir/tree/rust-hir.cc (SlicePatternItemsHasRest::to_string):
	Likewise.
	* typecheck/rust-hir-type-check-pattern.cc
	(TypeCheckPattern::visit (SlicePattern)): Assert that the rest
	pattern isn't bound (currently unsupported).

gcc/testsuite/ChangeLog:

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

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Make unlabeled break return its translated tree, matching continue.

Emit tail-position break and continue expressions as statements so
they stay inside the TRY_FINALLY_EXPR body and run block cleanup.

gcc/rust/ChangeLog:

	* backend/rust-compile-block.cc (is_control_flow_expr): New helper.
	(CompileBlock::visit): Emit tail-position break and continue
	expressions as statements.
	* backend/rust-compile-expr.cc (CompileExpr::visit): Return the
	translated expression for unlabeled break instead of emitting it
	directly.

gcc/testsuite/ChangeLog:

	* rust/execute/drop-unlabeled-break-continue.rs: New test.

Signed-off-by: Lishin <lishin1008@gmail.com>
Extern crate declarations did not insert their bound name into any
namespace. Because nothing was inserted, the existing duplicate-name
check could never fire for extern crates. As a result, both
extern crate foo; extern crate foo; and extern crate foo; mod foo {}
compiled silently.

Insert the bound name, using the alias when one is present, into the
type namespace. Record extern crate node ids in Mappings so the check
can determine what kind of declaration each side represents. Select
E0259 when both sides are extern crates and E0260 when only one side is
an extern crate. E0428 remains unchanged for every other item kind.

Record the extern crate node in Mappings before calling
insert_or_error_out because check_multiple_insertion_error runs inside
that call and needs to know whether the new node is an extern crate.
This differs from visit (AST::Module&), which records the node after the
insertion call.

Fixes #4679

gcc/rust/ChangeLog:

	* util/rust-hir-map.h (Mappings::insert_extern_crate_id)
	(Mappings::is_extern_crate): New declaration.
	(Mappings::extern_crate_ids): New member.
	* util/rust-hir-map.cc (Mappings::insert_extern_crate_id)
	(Mappings::is_extern_crate): New function.
	* resolve/rust-toplevel-name-resolver-2.0.h
	(TopLevel::visit (ExternCrate)): New declaration.
	* resolve/rust-toplevel-name-resolver-2.0.cc
	(TopLevel::check_multiple_insertion_error): Select E0259, E0260 or
	E0428 based on the colliding declarations.
	(TopLevel::visit (ExternCrate)): New function definition.

gcc/testsuite/ChangeLog:

	* rust/link/extern_crate_alias_0.rs: New test.
	* rust/link/extern_crate_alias_1.rs: New test.
	* rust/link/extern_crate_dup_0.rs: New test.
	* rust/link/extern_crate_dup_1.rs: New test.
	* rust/link/extern_crate_item_conflict_0.rs: New test.
	* rust/link/extern_crate_item_conflict_1.rs: New test.

Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
Create the requested number of elements in the IndexVec constructor
instead of only reserving space. This fixes an out-of-bounds access
when dumping BIR.

gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-place.h
	(IndexVec::IndexVec): Create the requested number of elements.

Signed-off-by: Lishin <lishin1008@gmail.com>
Add BIR Drop statements at scope exits and classify them as static or
dead by tracking whether each local is initialized or moved.

Treat function arguments as initialized at function entry and schedule
their value drops before returning. Arguments do not receive
StorageLive or StorageDead statements.

Dump the classification and add tests for static local, whole-local
move, a copy, and a function argument.

gcc/rust/ChangeLog:

	* Make-lang.in: Add rust-bir-drop-analysis.o.
	* checks/errors/borrowck/rust-bir.h:
	(Statement::DropStyle): New enum.
	(Statement::Kind): Add DROP.
	(Statement::make_drop): New function.
	(Statement::get_drop_style): Likewise.
	(Statement::set_drop_style): Likewise.
	* checks/errors/borrowck/rust-bir-builder-internal.h:
	(AbstractBuilder::declare_argument): New function.
	(AbstractBuilder::push_drop): Likewise.
	(AbstractBuilder::push_function_argument_drops): Likewise.
	(AbstractBuilder::pop_scope): Schedule Drop statements.
	(AbstractBuilder::unwind_until): Likewise.
	(AbstractBuilder::push_return): Schedule function argument drops.
	* checks/errors/borrowck/rust-bir-builder.h
	(Builder::handle_param): Use declare_argument for function
	parameters.
	* checks/errors/borrowck/rust-bir-dump.cc (Dump::visit): Dump
	Drop classifications.
	* checks/errors/borrowck/rust-bir-fact-collector.h
	(FactCollector::visit): Handle Drop statements.
	* checks/errors/borrowck/rust-borrow-checker.cc
	(BorrowChecker::go): Run BIR Drop analysis.
	* checks/errors/borrowck/rust-bir-drop-analysis.cc: New file.
	* checks/errors/borrowck/rust-bir-drop-analysis.h: New file.

gcc/testsuite/ChangeLog:

	* rust/borrowck/drop_analysis_whole_move.rs: New test.

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

	* checks/errors/borrowck/rust-bir-drop-analysis.cc
	(BasicBlockIdHash): New helper.
	(DropAnalysis::analyze): Use unordered_set for visited block tracking.
	* checks/errors/borrowck/rust-bir-drop-analysis.h: Include rust-bir.h
	directly and remove Function forward declaration.
	* checks/errors/borrowck/rust-bir-place.h
	(IndexVec::IndexVec): Add comment for sized constructor.

Signed-off-by: Lishin <lishin1008@gmail.com>
This patch implements the 'unsize' lang item to the compiler.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (BaseType::unsize_to): New function.
	(BaseType::satisfies_bound): Use it.
	* typecheck/rust-tyty.h (class BaseType): New declaration.
	* util/rust-lang-item.cc (Rust::LangItem::lang_items): Add
	unsize to the BiMap.
	* util/rust-lang-item.h (class LangItem): Add UNSIZE to the Kind
	enum.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Enes Cevik <enes@nsvke.com>
This patch enables fundamental array-to-slice (`[T; N]` to `[T]`)
unsized coercions. Previously, the compiler only handled `dyn Trait`
unsized coercions and immediately rejected array-to-slice conversions.
Now, the compiler correctly identifies valid array-to-slice coercions
and generates the appropriate `Adjustment::UNSIZE` tags.

gcc/rust/ChangeLog:

	* typecheck/rust-coercion.cc
	(TypeCoercionRules::coerce_unsized): Add array-to-slice coercion
	support.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Enes Cevik <enes@nsvke.com>
This patch adds basic support for ADT to ADT unsized coercions. It also
refactors the main coerce_unsized function into smaller helper functions
for better readability and maintainability.

gcc/rust/ChangeLog:

	* backend/rust-compile-base.h (resolve_adjustments): Fix typo.
	(resolve_unsized_adt_adjustment): New declaration.
	* backend/rust-compile-expr.cc (CompileExpr::visit): Fix typo.
	(HIRCompileBase::resolve_unsized_adt_adjustment): New function.
	(HIRCompileBase::resolve_unsized_adjustment): Use it.
	(CompileExpr::generate_possible_fn_trait_call): Likewise.
	(HIRCompileBase::coercion_site): Fix typo.
	* typecheck/rust-coercion.cc
	(TypeCoercionRules::coerce_unsized): Use helper functions.
	(TypeCoercionRules::unwrap_ptrs_and_refs): New function.
	(TypeCoercionRules::coerce_unsized_array_to_slice): Likewise.
	(TypeCoercionRules::coerce_unsized_dyn): Likewise.
	(TypeCoercionRules::coerce_unsized_adt): Liksewise.
	(TypeCoercionRules::apply_reborrow_adjustment): Likewise.
	* typecheck/rust-coercion.h (struct CoercionSetup): New struct.
	(coerce_unsized): Add is_inner parameter.
	(unwrap_ptrs_and_refs): New declaration.
	(coerce_unsized_array_to_slice): Likewise.
	(coerce_unsized_dyn): Likewise.
	(coerce_unsized_adt): Likewise.
	* util/rust-lang-item.cc (Rust::LangItem::lang_items): Add
	coerce_unsized to the BiMap.
	* util/rust-lang-item.h (class LangItem): Add COERCE_UNSIZED to
	the Kind enum.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Enes Cevik <enes@nsvke.com>
This patch introduces support for Dynamically Sized Types (DST) within
Algebraic Data Types (ADTs). Previously, the compiler embedded DST
fields directly into the ADT memory layout, even for ADTs following
unsize coercion rules. With this update, the compiler correctly
identifies unsized ADTs, preserves their static layout by avoiding
direct embedding, and appropriately generates fat pointers (containing
the data pointer and metadata) for references to these ADTs.

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Add
	indirect field access for DST's and new borrow approach for fat
	pointers.
	(resolve_unsized_adt_adjustment): Correct GIMPLE generation for
	nested unsized ADTs.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add
	DST ADT support.
	(TyTyResolveCompile::create_dyn_adt_record): New function.
	* backend/rust-compile-type.h (create_dyn_adt_record): New
	declaration.
	* backend/rust-intrinsic-handlers.cc (get_inner_dst): New
	function.
	(size_of_val_handler): Add DST ADT support.
	(min_align_of_val_handler): Likewise.
	* typecheck/rust-coercion.cc
	(TypeCoercionRules::coerce_unsized_adt): Skip zero-sized fields
	during coercion.
	* backend/rust-compile.cc (HIRCompileBase::coerce_to_dyn_object):
	Remove unnecessary ref wrapping.
	* typecheck/rust-tyty.cc (ADTType::is_unsized): New function.
	(ReferenceType::is_dyn_object): Add DST ADT support.
	(ReferenceType::is_dyn_adt_type): New function.
	(PointerType::is_dyn_object): Add DST ADT support.
	(PointerType::is_dyn_adt_type): New function.
	* typecheck/rust-tyty.h (is_unsized): New declaration.

gcc/testsuite/ChangeLog:

	* rust/execute/unsized-adt-nested-coercion.rs: New test.
	* rust/execute/unsized-adt-size.rs: New test.

Signed-off-by: Enes Cevik <enes@nsvke.com>
Connect the straight-line Drop analysis to the existing backend
cleanup.

Use the BIR analysis result to skip backend Drops for moved locals.
Static and unclassified Drops keep the existing cleanup behavior.

gcc/rust/ChangeLog:

	* backend/rust-compile-drop.cc
	(CompileDrop::build_current_scope_drop_cleanup): Skip definitely
	dead Drop candidates.
	* checks/errors/borrowck/rust-bir-drop-analysis.cc
	(DropAnalysis::get): New function.
	(DropAnalysis::clear): Likewise.
	(DropAnalysis::is_definitely_dead): Likewise.
	(DropAnalysis::analyze): Record dead whole-local HirIds.
	* checks/errors/borrowck/rust-bir-drop-analysis.h
	(DropAnalysis::get): New declaration.
	(DropAnalysis::clear): Likewise.
	(DropAnalysis::is_definitely_dead): Likewise.
	(DropAnalysis::definitely_dead): New member.
	* checks/errors/borrowck/rust-borrow-checker.cc
	(BorrowChecker::go): Clear old Drop analysis results and analyze
	each BIR function.

gcc/testsuite/ChangeLog:

	* rust/execute/drop-whole-local-move.rs: New test.

Signed-off-by: Lishin <lishin1008@gmail.com>
Warn on a `#[repr(C)]` enum whose discriminant fits into neither a C
`int` nor a C `unsigned int`. Such an enum is non-portable: C only
permits enums whose discriminants do not all fit into one of those two
types since C23, and Rust interprets `repr(C)` discriminants as `isize`,
so its size may not match the C one.

The discriminant is const evaluated with query_compile_const_expr during
type resolution, so any constant discriminant expression is handled.

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-item.cc
	(check_repr_c_enum_discriminants): New.
	(TypeCheckItem::visit): Check repr(C) enum discriminants.

gcc/testsuite/ChangeLog:

	* rust/compile/repr-c-enums-larger-than-int_0.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
Adjusts some visitor functions and makes AST::LlvmInlineAsm store only a
single template string.

gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc
	(TokenCollector::visit (LlvmInlineAsm)): Improve accuracy of
	token collection.
	* ast/rust-ast-pointer-visitor.cc
	(PointerVisitor::visit (LlvmInlineAsm)): Visit outer attributes.
	* ast/rust-ast-visitor.cc
	(DefaultASTVisitor::visit (LlvmInlineAsm)): Likewise.
	* ast/rust-expr.h (LlvmInlineAsm::templates): Remove member
	variable and replace with...
	(LlvmInlineAsm::template_str): ...new member variable.
	(LlvmInlineAsm::LlvmInlineAsm): Initialize template_str.
	(LlvmInlineAsm::get_templates): Remove member function.
	(LlvmInlineAsm::set_template): New member function.
	(LlvmInlineAsm::get_template): Likewise.
	* expand/rust-macro-builtins-asm.cc (parse_llvm_templates):
	Rename to...
	(parse_llvm_template): ...here and adjust to not expect multiple
	template strings.
	(parse_llvm_asm): Handle rename of parse_llvm_templates to
	parse_llvm_template.
	* hir/rust-ast-lower-expr.cc (check_llvm_asm_support): Handle
	changes to LlvmInlineAsm.
	(ASTLoweringExpr::visit (LlvmInlineAsm)): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Warn on a labeled `break` whose value is a loop expression, as it is
easy to confuse with an unlabeled `break` of a labeled value.

gcc/rust/ChangeLog:

	* checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit):
	New.
	* checks/lints/unused/rust-unused-checker.h (UnusedChecker::visit):
	New.
	* rust-lang.cc (grs_langhook_init_options_struct): Enable warn_unused.

gcc/testsuite/ChangeLog:

	* rust/compile/break-with-label-and-loop_0.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
This patch introduces DST support for box, allowing it to correctly
handle unsized types.

It also implements the auto-deref mechanism for box. This ensures that
method dispatch, indexing, and tuple field access work correctly.

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (compile_box): Remove DST guard.
	(build_box_inner_ptr): Add fat pointer control.
	(CompileExpr::visit): Add auto-deref for box.
	(HIRCompileBase::resolve_deref_adjustment): Return fat or thin
	pointer.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Add auto-deref for box.
	* typecheck/rust-tyty.cc (ADTType::is_box): New function.
	* typecheck/rust-tyty.h (class BaseType): New declaration.

gcc/testsuite/ChangeLog:

	* rust/execute/box-dispatch-1.rs: New test.
	* rust/execute/box-dispatch-2.rs: New test.
	* rust/execute/unsized-adt-size.rs: Format test.

Signed-off-by: Enes Cevik <enes@nsvke.com>
This patch implements the 'dispatch_from_dyn' lang item specifically for
'Box'. While there are other smart pointers and types that require this
lang item for dynamic dispatch, they are omitted in this patch as they
are not yet fully supported by the compiler.

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Handle Box
	receivers correctly during dynamic dispatch.
	* typecheck/rust-hir-dot-operator.cc (MethodResolver::try_hook):
	Extract the inner type of a Box to resolve trait methods.
	* util/rust-lang-item.cc (Rust::LangItem::lang_items): Register
	dispatch_from_dyn to the BiMap.
	* util/rust-lang-item.h (class LangItem): Add DISPATCH_FROM_DYN
	to the Kind enum.

gcc/testsuite/ChangeLog:

	* rust/execute/box-dispatch-from-dyn.rs: New test.

Signed-off-by: Enes Cevik <enes@nsvke.com>
philberty and others added 14 commits August 19, 2026 14:10
Fixes #3585

gcc/rust/ChangeLog:

	* ast/rust-ast-visitor.cc (ContextualASTVisitor::visit): missing visitor
	* ast/rust-ast-visitor.h: prototype

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
We need to force braces on the default expression in the parser but also
the typecheck cant const eval when the typecheck fails otherwise it will
crash because invalid error mark node.

Fixes #4173

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.hxx:
	* typecheck/rust-hir-type-check-base.cc:

gcc/testsuite/ChangeLog:

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

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

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
…pr.cc

Fixes #4631

gcc/rust/ChangeLog:

	* backend/rust-constexpr.cc (maybe_fold_reference_address_to_pointer): port over from cp
	(eval_binary_expression): likewise

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Items declared in a block expression can't be unreachable.

gcc/rust/ChangeLog:

	* hir/rust-ast-lower.cc (ASTLoweringBlock::visit): Check if a
	statement is an item before warning.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Warn about an unsafe block that does not contain any operation requiring
an unsafe context. The unsafe checker now records which unsafe blocks are
actually used by an unsafe operation, and reports the rest. The warning
is gated behind -frust-unused-check-2.0.

gcc/rust/ChangeLog:

	* checks/errors/rust-unsafe-checker.cc (check_static_mut)
	(check_extern_static, check_unsafe_call, check_extern_call)
	(check_target_attr): Return whether the operation requires unsafe and
	only error outside of an unsafe context.
	(UnsafeChecker::mark_unsafe_used): New.
	(UnsafeChecker::check_use_of_static)
	(UnsafeChecker::check_function_call)
	(UnsafeChecker::check_function_attr): Mark the unsafe block as used.
	(UnsafeChecker::visit): Mark used and warn on unnecessary unsafe block.
	* checks/errors/rust-unsafe-checker.h (UnsafeChecker): Add
	mark_unsafe_used and used_unsafe_blocks.
	* rust-lang.cc (grs_langhook_init_options_struct): Enable warn_unused.

gcc/testsuite/ChangeLog:

	* rust/compile/unused-unsafe_0.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
Before this require_b<T: B> (T) only checked for S<Bad> implement B and
it early accepted the

  impl<T: A> B for S<T>

But we need to validate the impl's bound after we bind the arguments being
used on the generic impl. So when we do a call-expr/method-call expr we are
binding to that impl and we need to validate. When we do that we know that
impl T = Bad and we walk the impl generic params T: A apply the subst for
Bad: A where its is not implemented and we fail and return.

Fixes #4678

gcc/rust/ChangeLog:

	* typecheck/rust-hir-trait-reference.h: add emit_errors option
	* typecheck/rust-hir-trait-resolve.cc (AssociatedImplTrait::bind_impl_for_projection): new
	(AssociatedImplTrait::bind_impl_for_bound): call new validate function
	* typecheck/rust-type-util.cc (lookup_associated_impl_block): make this more generic
	* typecheck/rust-tyty-call.cc (validate_call_argument_associated_impl_bounds): new
	(TypeCheckCallExpr::visit): for each call arg validate and bind
	(TypeCheckMethodCallExpr::check): likewise

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
This should allow the use of gcc diagnostic format specifiers in debug
diagnostics, in exchange for stricter diagnostic quality checks.

gcc/rust/ChangeLog:

	* rust-diagnostics.cc (rust_debug_fmt_at): New function
	definition.
	* rust-diagnostics.h (rust_debug_fmt): New function-like macro
	definition.
	(rust_debug_fmt_at): New function declaration.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Add execute coverage for Drop behavior that is already supported but was not
covered by the testsuite.

Cover function parameter drop order, explicit returns, ownership transfers
through function arguments and return values, and branch-local values.

gcc/testsuite/ChangeLog:

	* rust/execute/drop-explicit-return.rs: Test parameter drops on explicit
	return.
	* rust/execute/drop-function-boundary-moves.rs: New test.
	* rust/execute/drop-function-params.rs: Test multiple parameter drop
	order.
	* rust/execute/drop-if-else-local.rs: New test.
gcc/rust/ChangeLog:

	* util/rust-lang-item.h (LangItem::Kind): Add lang item declarations for missing
	lang items required for core 1.49 compilation.
	* util/rust-lang-item.cc (LangItem::lang_items): Ditto.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
More subtle differences between GCC and LLVM inline assembly might be
an issue in the future, but this should handle or safely reject most
usages.

gcc/rust/ChangeLog:

	* ast/rust-expr.h (LlvmInlineAsm::LlvmInlineAsm): Initialize
	more member variables.
	(LlvmInlineAsm::get_dialect): Make function const qualified.
	(LlvmInlineAsm::is_stack_aligned): Likewise.
	(LlvmInlineAsm::is_volatile): Likewise.
	* backend/rust-compile-asm.cc
	(CompileLlvmAsm::construct_operands): Handle llvm-specific "=*m"
	constraint.
	(CompileLlvmAsm::tree_codegen_asm): Handle change from multiple
	template strings to a single template string.
	* hir/rust-ast-lower-expr.cc (convert_template_str): New
	function.
	(check_llvm_asm_support): Remove unnecessary parameters and
	expand the set of allowed llvm_asm usages.
	(ASTLoweringExpr::visit (LlvmInlineAsm)): Adjust lowering.
	* hir/tree/rust-hir-expr.h (LlvmInlineAsm::templates): Remove
	member variable and replace with...
	(LlvmInlineAsm::template_str): ...new member variable.
	(LlvmInlineAsm::LlvmInlineAsm): Handle member variable changes.
	(LlvmInlineAsm::get_templates): Remove member function and
	replace with...
	(LlvmInlineAsm::get_template): ...new member function.
	* hir/tree/rust-hir-visitor.cc
	(DefaultHIRVisitor::walk (LlvmInlineAsm)): Visit outer
	attributes.
	* typecheck/rust-hir-type-check-expr.cc
	(TypeCheckExpr::visit (LlvmInlineAsm)): Adjust comments.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Fixes #1553

gcc/rust/ChangeLog:

	* backend/rust-constexpr.cc (eval_constant_expression): port over goto
	(potential_constant_expression_1): likewise

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
GCC makes this stuff really straight forward which is nice.

Fixes #4794

gcc/rust/ChangeLog:

	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): make vector
	* rust-gcc.cc (struct_field_expression): we use bit field acces for lanes
	(constructor_expression): special case VECTOR
	(convert_tree): likewise for canonical main variant

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
This is only bringing basic CI. Never push upstream
@dkm
dkm requested review from CohenArthur and P-E-P August 19, 2026 12:11
@dkm

dkm commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

@P-E-P @CohenArthur FYI, this is the upstream branch + 1 commit for CI.
The branch to upstream is thisone^ or simply, as stated in the description: gerris/rebase-upstream/2026-08-19

CI will take a long time, all builds are bootstrap build + 32/64 tests.

@dkm dkm closed this Sep 14, 2026
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.

10 participants