]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
gccrs: Fix name-resolution to be permissive and carry on
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 3 Mar 2023 18:01:01 +0000 (18:01 +0000)
committerPhilip Herron <philip.herron@embecosm.com>
Fri, 3 Mar 2023 19:27:24 +0000 (19:27 +0000)
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

  <A as B>::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:

  <<A as B>::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 <herron.philip@googlemail.com>
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

gcc/rust/resolve/rust-ast-resolve-type.cc
gcc/testsuite/rust/compile/parse_associated_type_as_generic_arg3.rs

index 28ab069743159a48ae531829d6f7c019c68f898a..f315985450e611425c4492d522117437676da9f3 100644 (file)
@@ -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;
 }
index f1cc9e7dcde8364d399110923b65f8e875f61e89..72c1b95c09a5056c9bb82feaea0fab6b0e931f58 100644 (file)
@@ -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<T> {
     Nothing,
 }
 
-fn foo() -> Maybe<<<<<S as Foo>::A as Bar>::B as Toto>::C as Tata>::D> {
+pub fn foo() -> Maybe<<<<<S as Foo>::A as Bar>::B as Toto>::C as Tata>::D> {
     Maybe::Something(15)
 }