aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-02-29 16:09:23 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-03-19 17:37:38 +0000
commitb4de854a5396909fe8ad757676dbaf4957c3194f (patch)
treec7bc8b94ca8ea806ae2534d8ebe5c14d00014287
parent36aeecfb22d42649b2b1101a96b1d389e439757c (diff)
downloadgcc-b4de854a5396909fe8ad757676dbaf4957c3194f.zip
gcc-b4de854a5396909fe8ad757676dbaf4957c3194f.tar.gz
gcc-b4de854a5396909fe8ad757676dbaf4957c3194f.tar.bz2
format-args: Add basic test case
gcc/testsuite/ChangeLog: * rust/compile/format_args_basic_expansion.rs: New test.
-rw-r--r--gcc/testsuite/rust/compile/format_args_basic_expansion.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/format_args_basic_expansion.rs b/gcc/testsuite/rust/compile/format_args_basic_expansion.rs
new file mode 100644
index 0000000..40bcd3c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/format_args_basic_expansion.rs
@@ -0,0 +1,47 @@
+#![feature(rustc_attrs)]
+
+#[rustc_builtin_macro]
+macro_rules! format_args {
+ () => {};
+}
+
+#[lang = "sized"]
+trait Sized {}
+
+pub mod core {
+ pub mod fmt {
+ pub struct Formatter;
+ pub struct Result;
+
+ pub struct Arguments<'a>;
+
+ impl<'a> Arguments<'a> {
+ pub fn new_v1(_: &'a [&'static str], _: &'a [ArgumentV1<'a>]) -> Arguments<'a> {
+ Arguments
+ }
+ }
+
+ pub struct ArgumentV1<'a>;
+
+ impl<'a> ArgumentV1<'a> {
+ pub fn new<'b, T>(_: &'b T, _: fn(&T, &mut Formatter) -> Result) -> ArgumentV1 {
+ ArgumentV1
+ }
+ }
+
+ pub trait Display {
+ fn fmt(&self, _: &mut Formatter) -> Result;
+ }
+
+ impl Display for i32 {
+ fn fmt(&self, _: &mut Formatter) -> Result {
+ // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
+ Result
+ }
+ }
+ }
+}
+
+fn main() {
+ let _formatted = format_args!("hello {}", 15);
+}