From: Arthur Cohen Date: Thu, 29 Feb 2024 15:09:23 +0000 (+0100) Subject: gccrs: format-args: Add basic test case X-Git-Tag: basepoints/gcc-16~7025 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0e8bf92395be8c4b5f059f93006655b63e1367e;p=thirdparty%2Fgcc.git gccrs: format-args: Add basic test case gcc/testsuite/ChangeLog: * rust/compile/format_args_basic_expansion.rs: New test. --- 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 00000000000..40bcd3c1433 --- /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); +}