about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-09-12 03:21:08 -0700
committerbors <bors@rust-lang.org>2013-09-12 03:21:08 -0700
commit4825db44c81ca2b122282dfb59aa705ad2475e5d (patch)
treec8a8f6bcd0c72b08d8ba369653b7eb3f53bb48e6 /src/rustllvm/PassWrapper.cpp
parent68125359cdd053628b437c2b963bd82e1ff03523 (diff)
parent9a5f95a82c2836fa6c57ede49d27c060f2377fa1 (diff)
downloadrust-4825db44c81ca2b122282dfb59aa705ad2475e5d.tar.gz
rust-4825db44c81ca2b122282dfb59aa705ad2475e5d.zip
auto merge of #9012 : alexcrichton/rust/format-args, r=huonw
The purpose of this macro is to further reduce the number of allocations which
occur when dealing with formatting strings. This macro will perform all of the
static analysis necessary to validate that a format string is safe, and then it
will wrap up the "format string" into an opaque struct which can then be passed
around.

Two safe functions are added (write/format) which take this opaque argument
structure, unwrap it, and then call the unsafe version of write/format (in an
unsafe block). Other than these two functions, it is not intended for anyone to
ever look inside this opaque struct.

The macro looks a bit odd, but mostly because of rvalue lifetimes this is the
only way for it to be safe that I know of.

Example use-cases of this are:

* third-party libraries can use the default formatting syntax without any
  forced allocations
* the fail!() macro can avoid allocating the format string
* the logging macros can avoid allocation any strings

I plan on transitioning the standard logging/failing to using these macros soon. This is currently blocking on inner statics being usable in cross-crate situations (still tracking down bugs there), but this will hopefully be coming soon!

Additionally, I'd rather settle on a name now than later, so if anyone has a better suggestion other than `format_args`, I'm not attached to the name at all :)
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions