Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upprintln!, eprintln! and writeln! accept other literals not just format strings #30143
Comments
steveklabnik
added
A-libs
A-macros
labels
Dec 1, 2015
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
@nagisa awesome! Why do the places that need EDIT: Turns out |
This comment has been minimized.
This comment has been minimized.
|
Seems like it'd be a breaking change to "fix" this. |
This comment has been minimized.
This comment has been minimized.
|
For ($msg:expr) => ({
unreachable!("{}", $msg)
}); |
ollie27
changed the title
println!, writeln! and unreachable! accept other literals not just format strings
println! and writeln! accept other literals not just format strings
Dec 2, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Why do we consider that the code like |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
@ollie27 thanks for the clarifications, thats makes sense now. I'm not sure |
huonw
added
I-nominated
T-libs
labels
Jan 6, 2016
brson
added
the
I-wishlist
label
Jan 6, 2016
aturon
added
rust-2-breakage-wishlist
and removed
I-nominated
I-wishlist
rust-2-breakage-wishlist
labels
Jan 8, 2016
This comment has been minimized.
This comment has been minimized.
|
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. |
aturon
closed this
Jan 8, 2016
durka
referenced this issue
Feb 11, 2016
Closed
`println!(123)` works, but `print!(123)` and `format!(123)` do not #31556
ollie27
referenced this issue
Feb 12, 2016
Closed
ensure that the assert! macro doesn't ICE on non-booleans #31604
This comment has been minimized.
This comment has been minimized.
|
related issue: |
ollie27
referenced this issue
Jun 20, 2016
Merged
Add custom message parameter to `assert_eq!` #33976
ollie27
referenced this issue
Apr 13, 2017
Merged
Add `eprint!` and `eprintln!` macros to the prelude. #41192
This comment has been minimized.
This comment has been minimized.
|
Sadly, |
ollie27
changed the title
println! and writeln! accept other literals not just format strings
println!, eprintln! and writeln! accept other literals not just format strings
May 12, 2017
sfackler
referenced this issue
Jan 15, 2018
Closed
print! and println! (and other similar macro pairs) accept differing types of "format strings" #47441
This comment has been minimized.
This comment has been minimized.
Vurich
commented
Jun 18, 2018
|
This would be improved by #35625 |
ollie27 commentedDec 1, 2015
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.