]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: expansion: Expand generic args in generic type path segments
authorArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Feb 2025 11:18:54 +0000 (12:18 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:07:11 +0000 (13:07 +0100)
gcc/rust/ChangeLog:

* expand/rust-expand-visitor.cc (ExpandVisitor::visit): Correctly visit the generic args
of a generic type path segment.

gcc/testsuite/ChangeLog:

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

gcc/rust/expand/rust-expand-visitor.cc
gcc/testsuite/rust/compile/issue-2015.rs [new file with mode: 0644]

index 1d131b181805968ce7eab58a6077eb65ac42ada1..d4db3137565e6e0af484b36188295c6466daafe6 100644 (file)
@@ -488,7 +488,9 @@ ExpandVisitor::visit (AST::PathInExpression &path)
 
 void
 ExpandVisitor::visit (AST::TypePathSegmentGeneric &segment)
-{}
+{
+  expand_generic_args (segment.get_generic_args ());
+}
 
 void
 ExpandVisitor::visit (AST::TypePathSegmentFunction &segment)
diff --git a/gcc/testsuite/rust/compile/issue-2015.rs b/gcc/testsuite/rust/compile/issue-2015.rs
new file mode 100644 (file)
index 0000000..7789ecd
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-additional-options "-frust-compile-until=lowering" }
+
+macro_rules! impl_foo {
+       () => { impl Foo }
+}
+
+pub trait Foo {}
+
+pub trait Bar {
+    type Baz;
+}
+
+pub fn foo(_value: impl Bar<Baz = impl_foo!()>) -> i32 {
+    15
+}
+
+pub fn bar(_value: impl Bar<Baz = impl Foo>) -> i32 {
+    16
+}