From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id A39AF385840E; Sun, 5 Mar 2023 11:42:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A39AF385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678016570; bh=KQNiFTr8i84rK0O0+Lvuf0+zXohsmXVEI3rTmtXUm/U=; h=From:To:Subject:Date:From; b=lBF0rEI7iZW+j+yzR56dxemEW6O1nlHyW9U2FomtsZVWoRSM0+KjTBschI/5m8xbj Zb6ICzmWDbspbhEykEEnuIxwcPvSV3w5NCt+VnvYkwMPgE2biNZgr+LFpZZIEvaHHR /AGEipLQuO3/iLRThQ4oi70PG/iDoHsrc+4FZhKI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] gccrs: Fix name-resolution to be permissive and carry on X-Act-Checkin: gcc X-Git-Author: Philip Herron X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: f71f25af741238e911d38874da18a5654fc836f7 X-Git-Newrev: 06e1d43c2f8a05af9fd862e6497c21741fce85c7 Message-Id: <20230305114250.A39AF385840E@sourceware.org> Date: Sun, 5 Mar 2023 11:42:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:06e1d43c2f8a05af9fd862e6497c21741fce85c7 commit 06e1d43c2f8a05af9fd862e6497c21741fce85c7 Author: Philip Herron Date: Fri Mar 3 18:01:01 2023 +0000 gccrs: Fix name-resolution to be permissive and carry on There are a few edge cases when resolving TypePaths that we cannot fully resolve to an explicit node_id and this is expected. So for example ::foo A and B are simple Type paths and thats 100% but the segment foo cannot be 100% resolved to an explicit node id as this requires type-resolution to find the correct path. So when we have complex paths such as: <::foo as C> The ::foo part will return UNKNOWN_NODEId and we return early and think its a failure case but its not necessarily a failure but we need to make sure to name resolve C so when we do type-resolution we can resolve C properly. Addresses #1524 Signed-off-by: Philip Herron gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveRelativeQualTypePath::resolve_qual_seg): fix gcc/testsuite/ChangeLog: * rust/compile/parse_associated_type_as_generic_arg3.rs: remove -fsyntax-only Diff: --- gcc/rust/resolve/rust-ast-resolve-type.cc | 12 +++--------- .../rust/compile/parse_associated_type_as_generic_arg3.rs | 6 ++---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-type.cc b/gcc/rust/resolve/rust-ast-resolve-type.cc index 28ab0697431..f315985450e 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.cc +++ b/gcc/rust/resolve/rust-ast-resolve-type.cc @@ -321,16 +321,10 @@ ResolveRelativeQualTypePath::resolve_qual_seg (AST::QualifiedPathType &seg) } auto type = seg.get_type ().get (); - NodeId type_resolved_node = ResolveType::go (type); - if (type_resolved_node == UNKNOWN_NODEID) - return false; - - if (!seg.has_as_clause ()) - return true; + ResolveType::go (type); - NodeId trait_resolved_node = ResolveType::go (&seg.get_as_type_path ()); - if (trait_resolved_node == UNKNOWN_NODEID) - return false; + if (seg.has_as_clause ()) + ResolveType::go (&seg.get_as_type_path ()); return true; } diff --git a/gcc/testsuite/rust/compile/parse_associated_type_as_generic_arg3.rs b/gcc/testsuite/rust/compile/parse_associated_type_as_generic_arg3.rs index f1cc9e7dcde..72c1b95c09a 100644 --- a/gcc/testsuite/rust/compile/parse_associated_type_as_generic_arg3.rs +++ b/gcc/testsuite/rust/compile/parse_associated_type_as_generic_arg3.rs @@ -1,5 +1,3 @@ -// { dg-additional-options "-fsyntax-only" } - trait Bar { type B; @@ -35,7 +33,7 @@ impl Tata for f32 { fn tata() {} } -struct S; +struct S; // { dg-warning "struct is never constructed" } impl Bar for i32 { type B = u32; @@ -54,6 +52,6 @@ enum Maybe { Nothing, } -fn foo() -> Maybe<<<<::A as Bar>::B as Toto>::C as Tata>::D> { +pub fn foo() -> Maybe<<<<::A as Bar>::B as Toto>::C as Tata>::D> { Maybe::Something(15) }