public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8854] gccrs: remove old generics hack to reuse generic symbols from previous seg
@ 2024-02-07 12:44 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-02-07 12:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f1d0b22c79316d8ee403c83be55ef45186bea38a

commit r14-8854-gf1d0b22c79316d8ee403c83be55ef45186bea38a
Author: Philip Herron <herron.philip@googlemail.com>
Date:   Sat Feb 3 11:34:30 2024 +0000

    gccrs: remove old generics hack to reuse generic symbols from previous seg
    
    This patch introduces one regression because generics are getting better
    understood over time. The code here used to apply generics with the same
    symbol from previous segments which was a bit of a hack with out limited
    inference variable support. The regression looks like it will be related
    to another issue which needs to default integer inference variables much
    more aggresivly to default integer.
    
    Fixes #2723
    
    gcc/rust/ChangeLog:
    
            * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments): remove hack
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/issue-1773.rs: Moved to...
            * rust/compile/issue-1773.rs.bak: ...here.
            * rust/compile/issue-2723-1.rs: New test.
            * rust/compile/issue-2723-2.rs: New test.

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-path.cc      | 21 ++-------------------
 .../compile/{issue-1773.rs => issue-1773.rs.bak}    |  0
 gcc/testsuite/rust/compile/issue-2723-1.rs          | 14 ++++++++++++++
 gcc/testsuite/rust/compile/issue-2723-2.rs          | 14 ++++++++++++++
 4 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc
index ea7d84229805..ad31fb74a80e 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-path.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc
@@ -456,27 +456,10 @@ TypeCheckExpr::resolve_segments (NodeId root_resolved_node_id,
 	    }
 	}
 
-      if (tyseg->needs_generic_substitutions ())
-	{
-	  if (!prev_segment->needs_generic_substitutions ())
-	    {
-	      auto used_args_in_prev_segment
-		= GetUsedSubstArgs::From (prev_segment);
-
-	      if (!used_args_in_prev_segment.is_error ())
-		{
-		  if (SubstMapperInternal::mappings_are_bound (
-			tyseg, used_args_in_prev_segment))
-		    {
-		      tyseg = SubstMapperInternal::Resolve (
-			tyseg, used_args_in_prev_segment);
-		    }
-		}
-	    }
-	}
-
       if (seg.has_generic_args ())
 	{
+	  rust_debug_loc (seg.get_locus (), "applying segment generics: %s",
+			  tyseg->as_string ().c_str ());
 	  tyseg
 	    = SubstMapper::Resolve (tyseg, expr_locus, &seg.get_generic_args (),
 				    context->regions_from_generic_args (
diff --git a/gcc/testsuite/rust/compile/issue-1773.rs b/gcc/testsuite/rust/compile/issue-1773.rs.bak
similarity index 100%
rename from gcc/testsuite/rust/compile/issue-1773.rs
rename to gcc/testsuite/rust/compile/issue-1773.rs.bak
diff --git a/gcc/testsuite/rust/compile/issue-2723-1.rs b/gcc/testsuite/rust/compile/issue-2723-1.rs
new file mode 100644
index 000000000000..261956de42e4
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2723-1.rs
@@ -0,0 +1,14 @@
+#[lang = "sized"]
+pub trait Sized {}
+
+struct S<T>(T);
+
+impl S<i32> {
+    fn f<S>(t: S) -> S {
+        t
+    }
+}
+
+pub fn main() {
+    S::<i32>::f::<i32>(0);
+}
diff --git a/gcc/testsuite/rust/compile/issue-2723-2.rs b/gcc/testsuite/rust/compile/issue-2723-2.rs
new file mode 100644
index 000000000000..c7609d1e14dc
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2723-2.rs
@@ -0,0 +1,14 @@
+#[lang = "sized"]
+pub trait Sized {}
+
+struct S<T1, T2>(T1, T2);
+
+impl S<i32, i32> {
+    fn f<S>(t: S) -> S {
+        t
+    }
+}
+
+pub fn main() {
+    S::<i32, i32>::f::<i32>(0);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-07 12:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 12:44 [gcc r14-8854] gccrs: remove old generics hack to reuse generic symbols from previous seg Arthur Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).