-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Improve suggestion for missing fmt str in println #52394
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f53c145
Improve suggestion for missing fmt str in println
estebank fbce952
review comments: modify note wording and change `println`
estebank e613bfb
Same change as `println` for `eprintln`
estebank a476532
Fix hir tree test
estebank 154dee2
rework println
f4306ff
Use correct spans for format string errors
85da68c
Rebase and fix text changed by master
052159b
fix incorrect position of chars in fmt str
9112e1a
fix rebase
8b59fbc
fix grep test looking for newline
83a8af5
Suggest space separated format str literal
00d5000
Gate `format_args_nll` behind feature flag
a7a6837
Change `eprintln!()`
93b2bb0
Remove dependency on `libsyntax`
915ff0b
fix logic bug
118b0f9
Fix tidy by adding new feature gate test
6aa17a3
Don't use the new `eprintln` for stage0 and stage1
3c81725
fix tidy ~ again
dc563d9
fix test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,10 +153,17 @@ macro_rules! print { | |
/// ``` | ||
#[macro_export] | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[allow_internal_unstable] | ||
macro_rules! println { | ||
() => (print!("\n")); | ||
($fmt:expr) => (print!(concat!($fmt, "\n"))); | ||
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); | ||
($($arg:tt)*) => ({ | ||
#[cfg(not(stage0))] { | ||
($crate::io::_print(format_args_nl!($($arg)*))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed because |
||
} | ||
#[cfg(stage0)] { | ||
print!("{}\n", format_args!($($arg)*)) | ||
} | ||
}) | ||
} | ||
|
||
/// Macro for printing to the standard error. | ||
|
@@ -210,10 +217,17 @@ macro_rules! eprint { | |
/// ``` | ||
#[macro_export] | ||
#[stable(feature = "eprint", since = "1.19.0")] | ||
#[allow_internal_unstable] | ||
macro_rules! eprintln { | ||
() => (eprint!("\n")); | ||
($fmt:expr) => (eprint!(concat!($fmt, "\n"))); | ||
($fmt:expr, $($arg:tt)*) => (eprint!(concat!($fmt, "\n"), $($arg)*)); | ||
($($arg:tt)*) => ({ | ||
#[cfg(all(not(stage0), not(stage1)))] { | ||
($crate::io::_eprint(format_args_nl!($($arg)*))); | ||
} | ||
#[cfg(any(stage0, stage1))] { | ||
eprint!("{}\n", format_args!($($arg)*)) | ||
} | ||
}) | ||
} | ||
|
||
#[macro_export] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hack which will make the span to be shifted one to the left when doing
format!("{\n")
, making the span point at the\
in stead of the"
, but the improvement in diagnostics forprintln
are worth it given how much of a corner case it is (and we can get back to this later to fix it).