Skip to content

Conversation

@philberty
Copy link
Member

@philberty philberty commented Nov 9, 2025

When we typecheck a trait impl block item, at the end we validate it against the trait definition by doing a final unify but if the type check fails on the the impl item it returns NULL here. The other issue was that if we fail to resolve the specified lifetime we return error early, this changes the typechecking to default to an anon lifetime so we can continue typechecking.

Fixes #4188

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItemWithTrait::visit): null guard
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): default to anon

gcc/testsuite/ChangeLog:

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

When we typecheck a trait impl block item, at the end we validate it
against the trait definition by doing a final unify but if the type check
fails on the the impl item it returns NULL here. The other issue was that
if we fail to resolve the specified lifetime we return error early, this
changes the typechecking to default to an anon lifetime so we can continue
typechecking.

Fixes #4188

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItemWithTrait::visit): null guard
	* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): default to anon

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty philberty force-pushed the phil/lifetime-crash branch from 0491d7e to 40a7cbe Compare November 9, 2025 22:12
@philberty philberty enabled auto-merge November 9, 2025 22:24
@philberty philberty added this pull request to the merge queue Nov 9, 2025
auto-merge was automatically disabled November 9, 2025 23:24

Pull Request is not mergeable

Merged via the queue into master with commit 1a1ba41 Nov 9, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in libcore 1.49 Nov 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

segfault TyWithLocation, extern C

2 participants