block-expr: add new rule expr.block.result-value#2174
block-expr: add new rule expr.block.result-value#2174DanielEScherzer wants to merge 1 commit intorust-lang:masterfrom
Conversation
Document that the value of a block expression is based on the final operand (if present), just like the type.
e4ab033 to
24a2ca3
Compare
|
Discovered while working on a conference talk about rust, I couldn't find any rule saying that a block expression had a value equal to the final operand, so I added such a rule fn main () {
let result: String = { panic!("test") };
let result: bool = { panic!("test") };
let result: Vec<String> = { panic!("test") };
}also, rule name could be improved, I originally was going to use
@rustbot label A-expressions |
|
From the review policy
Not sure if this is a new guarantee or just documenting a long-standing reality, @traviscross does this need to go through the lang team? |
Document that the value of a block expression is based on the final operand (if present), just like the type.