Skip to content

Commit

Permalink
Update Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
veera-sivarajan committed Oct 22, 2024
1 parent 86d69c7 commit 78a2f9d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/codegen/issues/issue-128709-format-without-args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ compile-flags: -C no-prepopulate-passes -C opt-level=0

#![crate_type = "lib"]

// String formating macros without any arguments should compile
// to a `memcpy` followed by a call to `std::io::stdio::_print`.

#[no_mangle]
pub fn code() {
// CHECK-LABEL: @code
// CHECK-NOT: getelementptr
// CHECK-NOT: store
// CHECK-NOT: ; call core::fmt::Arguments::new_const
// CHECK: call void @llvm.memcpy
// CHECK-NEXT: ; call std::io::stdio::_print
println!("hello world");
}
5 changes: 5 additions & 0 deletions tests/ui/consts/const-format-arguments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

pub fn main() {
const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]);
//~^ use of unstable library feature
}
20 changes: 20 additions & 0 deletions tests/ui/consts/const-format-arguments.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error[E0658]: use of unstable library feature 'fmt_internals'
--> $DIR/const-format-arguments.rs:3:36
|
LL | const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(fmt_internals)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: `Arguments::<'a>::new_const` is not yet stable as a const fn
--> $DIR/const-format-arguments.rs:3:36
|
LL | const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.

0 comments on commit 78a2f9d

Please sign in to comment.