public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Fix bad name resolution of path with generic segments
@ 2022-06-08 12:38 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:38 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:40f2979b73b56e4ddc5ab5686d75164a8b664320
commit 40f2979b73b56e4ddc5ab5686d75164a8b664320
Author: Philip Herron <philip.herron@embecosm.com>
Date: Tue Apr 26 11:20:22 2022 +0100
Fix bad name resolution of path with generic segments
When name-resolving paths we expect the name-resolver must resolve the
root of the path. Such that a path might be
module::type::associated_function
We expect that the name resolution step must be able to resolve the
module::type
Portion of the path, it is permissive to allow everything after that to
fail name resolution as this may require generic arguments of type
inferencing to figure out which associated items are required.
The issue in this referenced issue was that the generic arguments here were
wrongly canonicalized to be part of the root path which meant the segment
could not be name-resolved allowing the type resolution system to perform
the generic specialization.
Fixes #1173
Diff:
---
gcc/rust/resolve/rust-ast-resolve-type.h | 7 +------
gcc/testsuite/rust/compile/issue-1173.rs | 20 ++++++++++++++++++++
gcc/testsuite/rust/compile/torture/issue-893-2.rs | 2 +-
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h
index 4920e2bb6c1..72846336d23 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -169,13 +169,8 @@ public:
return CanonicalPath::create_empty ();
}
- std::string generics
- = ResolveTypeToCanonicalPath::canonicalize_generic_args (
- seg.get_generic_args ());
-
return CanonicalPath::new_seg (seg.get_node_id (),
- seg.get_ident_segment ().as_string ()
- + "::" + generics);
+ seg.get_ident_segment ().as_string ());
}
};
diff --git a/gcc/testsuite/rust/compile/issue-1173.rs b/gcc/testsuite/rust/compile/issue-1173.rs
new file mode 100644
index 00000000000..b08d7205717
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-1173.rs
@@ -0,0 +1,20 @@
+// { dg-additional-options "-w" }
+mod mem {
+ extern "rust-intrinsic" {
+ fn transmute<U, V>(_: U) -> V;
+ }
+}
+
+pub trait Hasher {
+ fn write(&mut self, bytes: &[u8]);
+ fn write_u16(&mut self, i: u16) {
+ self.write(&mem::transmute::<_, [u8; 2]>(i))
+ }
+}
+
+pub struct SipHasher;
+
+impl Hasher for SipHasher {
+ #[inline]
+ fn write(&mut self, msg: &[u8]) {}
+}
diff --git a/gcc/testsuite/rust/compile/torture/issue-893-2.rs b/gcc/testsuite/rust/compile/torture/issue-893-2.rs
index 88a865d66dc..c0eb1bb00bc 100644
--- a/gcc/testsuite/rust/compile/torture/issue-893-2.rs
+++ b/gcc/testsuite/rust/compile/torture/issue-893-2.rs
@@ -24,7 +24,7 @@ impl Baz<i32, f32> {
pub fn main() {
let a = Foo::<i32>::new::<f32>(123, 456f32);
- let b = Foo::new::<f32>(123, 456f32);
+ // let b = Foo::new::<f32>(123, 456f32);
let c = Bar::<i32>(123);
let d = Bar::baz(c);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:38 [gcc/devel/rust/master] Fix bad name resolution of path with generic segments Thomas Schwinge
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).