Auto merge of #60174 - matthewjasper:add-match-arm-scopes, r=pnkfelix

Add match arm scopes and other scope fixes

* Add drop and lint scopes for match arms.
* Lint attributes are now respected on match arms.
* Make sure we emit a StorageDead if we diverge when initializing a temporary.
* Adjust MIR pretty printing of scopes for locals.
* Don't generate duplicate lint scopes for `let statements`.
* Add some previously missing fake borrows for matches.

closes #46525

cc @rust-lang/compiler
This commit is contained in:
bors 2019-05-23 04:48:21 +00:00
commit 85334c5092
41 changed files with 727 additions and 277 deletions

View file

@ -3946,6 +3946,7 @@ impl<'a> Parser<'a> {
crate fn parse_arm(&mut self) -> PResult<'a, Arm> {
let attrs = self.parse_outer_attributes()?;
let lo = self.span;
let pats = self.parse_pats()?;
let guard = if self.eat_keyword(kw::If) {
Some(Guard::If(self.parse_expr()?))
@ -3965,6 +3966,8 @@ impl<'a> Parser<'a> {
let require_comma = classify::expr_requires_semi_to_be_stmt(&expr)
&& self.token != token::CloseDelim(token::Brace);
let hi = self.span;
if require_comma {
let cm = self.sess.source_map();
self.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Brace)])
@ -4008,6 +4011,7 @@ impl<'a> Parser<'a> {
pats,
guard,
body: expr,
span: lo.to(hi),
})
}