-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
println!, eprintln! and writeln! accept other literals not just format strings #30143
Comments
One way to fix this is to replace macro_rules! print {
($fmt:tt $($arg:tt)*) => ($crate::io::_print(format_args!(concat!($fmt) $($arg)*)));
} I would prefer to force EDIT: I honestly don't like how |
|
@nagisa awesome! Why do the places that need EDIT: Turns out |
Seems like it'd be a breaking change to "fix" this. |
For ($msg:expr) => ({
unreachable!("{}", $msg)
}); |
Why do we consider that the code like |
@raindev it's not documented so technically something needs to fixed, even if it's just the documentation. If we make I think this should either be fixed as a breaking change, I doubt it will break much if any real world code, or just depreciated. |
@ollie27 thanks for the clarifications, thats makes sense now. I'm not sure |
Libs team consensus: while it may be desirable to clean this up, this is not breakage we're willing to take on during the Rust 1.x series. I've added a new tag, closed-as-desirable-breakage, to help us track issues like this that we might want to revisit if we ever produce a 2.0 release. |
related issue: |
Sadly, |
This would be improved by #35625 |
Address rust-lang#30143 as well. `writeln!()` hasn't been changed.
The following all compile and run for example:
I would expect them to produce "error: format argument must be a string literal." like
print!(0);
does.This is because they use things like
concat!($fmt, "\n")
butconcat!
accepts other literals not juststr
.I assume this isn't intentional.
The text was updated successfully, but these errors were encountered: