Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize format_args_ln! #97658

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ pub fn expand_format_args<'cx>(
expand_format_args_impl(ecx, sp, tts, false)
}

pub fn expand_format_args_nl<'cx>(
pub fn expand_format_args_ln<'cx>(
ecx: &'cx mut ExtCtxt<'_>,
sp: Span,
tts: TokenStream,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
concat: concat::expand_concat,
env: env::expand_env,
file: source_util::expand_file,
format_args_nl: format::expand_format_args_nl,
format_args_ln: format::expand_format_args_ln,
format_args: format::expand_format_args,
const_format_args: format::expand_format_args,
global_asm: asm::expand_global_asm,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ symbols! {
format,
format_args,
format_args_capture,
format_args_ln,
format_args_macro,
format_args_nl,
format_macro,
fp,
freeze,
Expand Down
15 changes: 5 additions & 10 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,12 @@ macro_rules! write {
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "writeln_macro")]
#[allow_internal_unstable(format_args_nl)]
macro_rules! writeln {
($dst:expr $(,)?) => {
$crate::write!($dst, "\n")
};
($dst:expr, $($arg:tt)*) => {{
let result = $dst.write_fmt($crate::format_args_nl!($($arg)*));
let result = $dst.write_fmt($crate::format_args_ln!($($arg)*));
result
}};
}
Expand Down Expand Up @@ -896,16 +895,12 @@ pub(crate) mod builtin {
}

/// Same as [`format_args`], but adds a newline in the end.
#[unstable(
feature = "format_args_nl",
issue = "none",
reason = "`format_args_nl` is only for internal \
language use and is subject to change"
)]
#[stable(feature = "format_args_ln", since = "1.63.0")]
#[allow_internal_unstable(fmt_internals)]
#[rustc_builtin_macro]
#[cfg_attr(bootstrap, rustc_builtin_macro(format_args_nl))]
#[cfg_attr(not(bootstrap), rustc_builtin_macro)]
#[macro_export]
macro_rules! format_args_nl {
macro_rules! format_args_ln {
($fmt:expr) => {{ /* compiler built-in */ }};
($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub use crate::hash::macros::Hash;
#[doc(no_inline)]
pub use crate::{
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
format_args_ln, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
stringify, trace_macros,
};

Expand Down
3 changes: 1 addition & 2 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@
#![feature(core_panic)]
#![feature(custom_test_frameworks)]
#![feature(edition_panic)]
#![feature(format_args_nl)]
#![feature(log_syntax)]
#![feature(once_cell)]
#![feature(saturating_int_impl)]
Expand Down Expand Up @@ -593,7 +592,7 @@ pub use core::{
#[allow(deprecated)]
pub use core::{
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
env, file, format_args, format_args_ln, include, include_bytes, include_str, line, log_syntax,
module_path, option_env, stringify, trace_macros,
};

Expand Down
8 changes: 4 additions & 4 deletions library/std/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ macro_rules! print {
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "println_macro")]
#[allow_internal_unstable(print_internals, format_args_nl)]
#[allow_internal_unstable(print_internals)]
macro_rules! println {
() => {
$crate::print!("\n")
};
($($arg:tt)*) => {{
$crate::io::_print($crate::format_args_nl!($($arg)*));
$crate::io::_print($crate::format_args_ln!($($arg)*));
}};
}

Expand Down Expand Up @@ -163,13 +163,13 @@ macro_rules! eprint {
#[macro_export]
#[stable(feature = "eprint", since = "1.19.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "eprintln_macro")]
#[allow_internal_unstable(print_internals, format_args_nl)]
#[allow_internal_unstable(print_internals)]
macro_rules! eprintln {
() => {
$crate::eprint!("\n")
};
($($arg:tt)*) => {{
$crate::io::_eprint($crate::format_args_nl!($($arg)*));
$crate::io::_eprint($crate::format_args_ln!($($arg)*));
}};
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub use crate::result::Result::{self, Err, Ok};
#[doc(no_inline)]
pub use core::prelude::v1::{
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
format_args_ln, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd,
};

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrowck-and-init.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `i`
LL | println!("{}", i);
| ^ use of possibly-uninitialized `i`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrowck-break-uninit-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `x`
LL | println!("{}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrowck-break-uninit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `x`
LL | println!("{}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrowck-or-init.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `i`
LL | println!("{}", i);
| ^ use of possibly-uninitialized `i`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrowck-while-break.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `v`
LL | println!("{}", v);
| ^ use of possibly-uninitialized `v`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/borrowck/issue-24267-flow-exit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ error[E0381]: borrow of possibly-uninitialized variable: `x`
LL | println!("{}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0381]: borrow of possibly-uninitialized variable: `x`
--> $DIR/issue-24267-flow-exit.rs:18:20
|
LL | println!("{}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ LL | println!("{}", arr[3]);
LL | c();
| - mutable borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0502]: cannot borrow `arr` as immutable because it is also borrowed as mutable
--> $DIR/arrays.rs:73:24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ LL |
LL | c();
| - mutable borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0506]: cannot assign to `e.0.0.m.x` because it is borrowed
--> $DIR/box.rs:55:5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | println!("{}", foo.x);
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand All @@ -25,5 +25,5 @@ LL | println!("{}", foo.x);
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LL |
LL | c();
| - mutable borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/codemap_tests/tab_3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ note: this function takes ownership of the receiver `self`, which moves `some_ve
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LL | println!("{}", FOO);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this warning originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error; 2 warnings emitted

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/const-eval/issue-43197.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ LL | println!("{} {}", X, Y);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this warning originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
--> $DIR/issue-43197.rs:16:26
Expand All @@ -55,7 +55,7 @@ LL | println!("{} {}", X, Y);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this warning originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors; 4 warnings emitted

Expand Down
3 changes: 0 additions & 3 deletions src/test/ui/feature-gates/feature-gate-format_args_nl.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/feature-gates/feature-gate-format_args_nl.stderr

This file was deleted.

4 changes: 2 additions & 2 deletions src/test/ui/fmt/ifmt-bad-arg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ note: associated function defined here
|
LL | pub fn from_usize(x: &usize) -> ArgumentV1<'_> {
| ^^^^^^^^^^
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
--> $DIR/ifmt-bad-arg.rs:81:35
Expand All @@ -326,7 +326,7 @@ note: associated function defined here
|
LL | pub fn from_usize(x: &usize) -> ArgumentV1<'_> {
| ^^^^^^^^^^
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 36 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generator/yield-while-ref-reborrowed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | println!("{}", x);
LL | Pin::new(&mut b).resume(());
| ------ first borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
3 changes: 1 addition & 2 deletions src/test/ui/hygiene/format-args.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// check-pass

#![allow(non_upper_case_globals)]
#![feature(format_args_nl)]

static arg0: () = ();

fn main() {
static arg1: () = ();
format_args!("{} {:?}", 0, 1);
format_args_nl!("{} {:?}", 0, 1);
format_args_ln!("{} {:?}", 0, 1);
}
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-42796.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | let mut s_copy = s;
LL | println!("{}", s);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-47646.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LL | println!("{:?}", heap);
LL | };
| - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(Option<PeekMut<'_, i32>>, ())`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-69455.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | println!("{}", 23u64.test(xs.iter().sum()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the associated function `new_display`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider specifying the generic argument
|
LL | println!("{}", 23u64.test(xs.iter().sum())::<T>);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/limits/issue-55878.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/liveness/liveness-move-in-while.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ LL | println!("{}", y);
LL | while true { while true { while true { x = y; x.clone(); } } }
| - value moved here, in previous iteration of loop
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error; 3 warnings emitted

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/liveness/liveness-use-after-move.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL |
LL | println!("{}", *x);
| ^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/liveness/liveness-use-after-send.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | send(ch, message);
LL | println!("{}", message);
| ^^^^^^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::format_args_ln` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Expand Down
Loading