From cd8547f85e53b42eff5a7c7572b466c023c75daf Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 25 Dec 2024 17:55:09 +0000 Subject: gccrs: lower: Correctly lower parenthesized types This is useful for handling multiple trait bounds, and required for better handling of auto traits. gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLoweringType::visit): Add implementation for ParenthesizedType. * hir/rust-ast-lower-type.h: Declare that new visitor. gcc/testsuite/ChangeLog: * rust/compile/auto_traits1.rs: New test. --- gcc/testsuite/rust/compile/auto_traits1.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gcc/testsuite/rust/compile/auto_traits1.rs (limited to 'gcc/testsuite/rust/compile') diff --git a/gcc/testsuite/rust/compile/auto_traits1.rs b/gcc/testsuite/rust/compile/auto_traits1.rs new file mode 100644 index 0000000..192052d --- /dev/null +++ b/gcc/testsuite/rust/compile/auto_traits1.rs @@ -0,0 +1,27 @@ +// { dg-additional-options "-frust-compile-until=typecheck" } + +#![feature(optin_builtin_traits)] + +pub unsafe auto trait Send {} +#[lang = "sync"] +pub unsafe auto trait Sync {} + +trait A { + fn a_method(&self) {} +} + +fn foo(a: &(dyn A + Send + Sync)) { + a.a_method(); +} + +struct S; + +impl A for S { + fn a_method(&self) {} +} + +fn main() { + let s = S; + + foo(&s); +} -- cgit v1.1