rust/compiler
bors d19b64fb54 Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk
Enable flatten-format-args by default.

Part of https://github.com/rust-lang/rust/issues/99012.

This enables the `flatten-format-args` feature that was added by https://github.com/rust-lang/rust/pull/106824:

> This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir:
>
> ```rust
> println!("Hello, {}!", "World");
> println!("Hello, World!");
> ```
>
> ```rust
> println!("[info] {}", format_args!("error"));
> println!("[info] error");
> ```
>
> ```rust
> println!("[{}] {}", status, format_args!("error: {}", msg));
> println!("[{}] error: {}", status, msg);
> ```
>
> ```rust
> println!("{} + {} = {}", 1, 2, 1 + 2);
> println!("1 + 2 = {}", 1 + 2);
> ```
>
> And so on.
>
> This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`.
>
> It also means that `dbg!(x)` will have its file, line, and expression name inlined:
>
> ```rust
> eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before
> eprintln!("[example.rs:1] x = {:#?}", x); // after
> ```
>
> Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot.

This is mostly an optimization, except that it will be visible through [`fmt::Arguments::as_str()`](https://doc.rust-lang.org/nightly/std/fmt/struct.Arguments.html#method.as_str).

In https://github.com/rust-lang/rust/pull/106823, there was already a libs-api FCP about the documentation of `fmt::Arguments::as_str()` to allow it to give `Some` rather than `None` depending on optimizations like this. That was just a documentation update though. This PR is the one that actually makes the user visible change:

```rust
assert_eq!(format_args!("abc").as_str(), Some("abc")); // Unchanged.
assert_eq!(format_args!("ab{}", "c").as_str(), Some("abc")); // Was `None` before!
```
2023-04-20 23:19:19 +00:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
rustc_apfloat
rustc_arena Allow clippy::from_mut_ref 2023-04-09 22:29:56 +02:00
rustc_ast Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk 2023-04-19 13:03:40 +00:00
rustc_ast_lowering Update comments in format args lowering. 2023-04-20 18:09:32 +02:00
rustc_ast_passes Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_ast_pretty Remove .. from return type notation 2023-04-10 22:19:46 +00:00
rustc_attr Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_baked_icu_data
rustc_borrowck Extend and use hir::Node::body_id 2023-04-19 19:13:45 +00:00
rustc_builtin_macros Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_codegen_cranelift Remove from cranelift too. 2023-04-14 16:26:11 +00:00
rustc_codegen_gcc Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_codegen_llvm Rollup merge of #110545 - WaffleLapkin:generic_arg_as_x, r=cjgillot 2023-04-20 14:36:54 +02:00
rustc_codegen_ssa Auto merge of #110598 - matthiaskrgr:rollup-0ybd9i3, r=matthiaskrgr 2023-04-20 13:03:31 +00:00
rustc_const_eval Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk 2023-04-19 13:03:40 +00:00
rustc_data_structures deny(unsafe_op_in_unsafe_fn) in rustc_data_structures 2023-04-19 18:00:48 +00:00
rustc_driver
rustc_driver_impl Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_error_codes Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_error_messages Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_errors Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_expand Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_feature Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_fluent_macro Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_fs_util Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
rustc_graphviz
rustc_hir Auto merge of #110061 - WaffleLapkin:duality_of_myself_and_this, r=cjgillot 2023-04-19 23:39:03 +00:00
rustc_hir_analysis Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_hir_pretty Remove identity casts 2023-04-09 23:22:14 +02:00
rustc_hir_typeck Move GenericArgKind::as_{type,const,region} to GenericArg 2023-04-19 17:59:30 +00:00
rustc_incremental Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_index Don't allocate it IndexVec::remove 2023-04-18 12:55:54 +00:00
rustc_infer Auto merge of #110527 - nnethercote:lazy-graph, r=lqd 2023-04-20 06:14:55 +00:00
rustc_interface Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk 2023-04-20 23:19:19 +00:00
rustc_lexer Revert "Don't recover lifetimes/labels containing emojis as character literals" 2023-04-10 06:52:41 +00:00
rustc_lint Rollup merge of #110545 - WaffleLapkin:generic_arg_as_x, r=cjgillot 2023-04-20 14:36:54 +02:00
rustc_lint_defs Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_llvm Recognize AIX style archive kind 2023-04-19 11:10:47 +08:00
rustc_log Stabilize IsTerminal 2023-04-10 17:24:23 +09:00
rustc_macros Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_metadata Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_middle Rollup merge of #110599 - WaffleLapkin:bonk_tygenericarg_transmutes, r=compiler-errors 2023-04-20 17:59:55 +02:00
rustc_mir_build Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_mir_dataflow Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_mir_transform Move GenericArgKind::as_{type,const,region} to GenericArg 2023-04-19 17:59:30 +00:00
rustc_monomorphize Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_parse Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_parse_format Fix typos in compiler 2023-04-10 22:02:52 +02:00
rustc_passes Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_plugin_impl Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_privacy Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_query_impl Rollup merge of #110498 - kylematsuda:earlybinder-rpitit-tys, r=compiler-errors 2023-04-19 06:35:35 +02:00
rustc_query_system Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_resolve Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_serialize Remove f32 & f64 from MemDecoder/MemEncoder 2023-04-06 00:54:07 -07:00
rustc_session Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk 2023-04-20 23:19:19 +00:00
rustc_smir Add Call terminator to SMIR 2023-04-20 12:00:41 -03:00
rustc_span Rollup merge of #110548 - kpreid:span, r=WaffleLapkin 2023-04-20 17:03:25 +09:00
rustc_symbol_mangling Add GenericArgKind::as_{type,const,region} 2023-04-19 14:54:31 +00:00
rustc_target Rollup merge of #108795 - thomcc:x86_64h-target, r=wesleywiser 2023-04-20 17:59:53 +02:00
rustc_trait_selection Rollup merge of #110531 - lcnr:type-system-stuff, r=aliemjay 2023-04-19 17:54:42 +02:00
rustc_traits Don't transmute &List<GenericArg> <-> &List<Ty> 2023-04-18 17:42:30 +00:00
rustc_transmute Erase regions when confirming transmutability candidate 2023-04-16 19:12:34 +00:00
rustc_ty_utils Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco 2023-04-19 08:26:47 +00:00
rustc_type_ir Rollup merge of #110386 - nnethercote:clean-up-traversal-macros, r=lcnr 2023-04-17 18:13:35 +02:00