Open
Description
return
expression in call params of println!
macro causes inappropriate warning message.
I tried this code (ref: Playground):
fn func1() {
assert_eq!((), return ());
}
fn func2() {
println!("{}", return ());
}
fn main() {
func1();
func2();
}
I expected to print ^^^
against an entire statement:
warning: unreachable expression
--> src/main.rs:2:5
|
2 | assert_eq!((), return ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unreachable_code)] on by default
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
warning: unreachable expression
--> src/main.rs:2:5
|
2 | assert_eq!((), return ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
warning: unreachable expression
--> src/main.rs:6:20
|
6 | println!("{}", return ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
But, it was printed against an expression instead of a sentence:
warning: unreachable expression
--> src/main.rs:2:5
|
2 | assert_eq!((), return ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unreachable_code)] on by default
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
warning: unreachable expression
--> src/main.rs:2:5
|
2 | assert_eq!((), return ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
warning: unreachable expression
--> src/main.rs:6:20
|
6 | println!("{}", return ());
| ^^^^^^^^^
Meta
rustc --version --verbose
: 1.31.1
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Category: An issue proposing an enhancement or a PR with one.Relevant to the compiler team, which will review and decide on the PR/issue.