https://gcc.gnu.org/g:9c1da61f610c11febcc880ee1dc65aaec5e03847
commit r17-4327-g9c1da61f610c11febcc880ee1dc65aaec5e03847 Author: Pierre-Emmanuel Patry <[email protected]> Date: Thu Sep 3 21:37:33 2026 +0200 gccrs: Do not continue when self is malformed If a self segment is malformed we do not want to continue as the node id retrieved during import finalization may crash the compiler. Fixes Rust-GCC/gccrs#4735 gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Return on error. Signed-off-by: Pierre-Emmanuel Patry <[email protected]> Diff: --- gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc index cb67af3e9b3d..aae601e92465 100644 --- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc @@ -594,8 +594,12 @@ Early::visit (AST::UseDeclaration &decl) if (rebind.get_path ().get_final_segment ().is_lower_self_seg ()) { collect_error ( - Error (decl.get_locus (), ErrorCode::E0429, + Error (rebind.get_path ().get_final_segment ().get_locus (), + ErrorCode::E0429, "%<self%> imports are only allowed within a { } list")); + // We must not continue, malformed use declaration must not be + // finalized. + return; } }
