Auto merge of - Centril:rollup-ir2vmid, r=Centril

Rollup of 3 pull requests

Successful merges:

 -  (Update cargo, books)
 -  (typeck: simplify the handling of `diverges`)
 -  (Update Clippy)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-01-22 00:50:48 +00:00
commit 2f688ac602
10 changed files with 38 additions and 56 deletions

@ -307,7 +307,7 @@ dependencies = [
"glob",
"hex 0.4.0",
"home",
"humantime",
"humantime 2.0.0",
"ignore",
"im-rc",
"jobserver",
@ -1013,7 +1013,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
dependencies = [
"atty",
"humantime",
"humantime 1.3.0",
"log",
"regex",
"termcolor",
@ -1026,7 +1026,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"atty",
"humantime",
"humantime 1.3.0",
"log",
"regex",
"termcolor",
@ -1454,6 +1454,12 @@ dependencies = [
"quick-error",
]
[[package]]
name = "humantime"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9b6c53306532d3c8e8087b44e6580e10db51a023cf9b433cea2ac38066b92da"
[[package]]
name = "hyper"
version = "0.12.31"
@ -2647,7 +2653,7 @@ dependencies = [
"clap",
"derive_more",
"env_logger 0.6.2",
"humantime",
"humantime 1.3.0",
"lazy_static 1.3.0",
"log",
"rls-span",

@ -1 +1 @@
Subproject commit 5c5cfd2e94cd42632798d9bd3d1116133e128ac9
Subproject commit 87dd6843678575f8dda962f239d14ef4be14b352

@ -1 +1 @@
Subproject commit 9493b7d4dc97eda439bd8780f05ad7b234cd1cd7
Subproject commit 4d78994915af1bde9a95c04a8c27d8dca066232a

@ -1 +1 @@
Subproject commit e1157538e86d83df0cf95d5e33bd943f80d0248f
Subproject commit 11e893fc1357bc688418ddf1087c2b7aa25d154d

@ -1 +1 @@
Subproject commit 1d59403cb5269c190cc52a95584ecc280345495a
Subproject commit 1c2bd024d13f8011307e13386cf1fea2180352b5

@ -50,30 +50,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.warn_arms_when_scrutinee_diverges(arms, match_src);
// Otherwise, we have to union together the types that the
// arms produce and so forth.
let scrut_diverges = self.diverges.get();
self.diverges.set(Diverges::Maybe);
// Otherwise, we have to union together the types that the arms produce and so forth.
let scrut_diverges = self.diverges.replace(Diverges::Maybe);
// rust-lang/rust#55810: Typecheck patterns first (via eager
// collection into `Vec`), so we get types for all bindings.
let all_arm_pats_diverge: Vec<_> = arms
.iter()
.map(|arm| {
let mut all_pats_diverge = Diverges::WarnedAlways;
self.diverges.set(Diverges::Maybe);
self.check_pat_top(&arm.pat, scrut_ty, Some(scrut.span), true);
all_pats_diverge &= self.diverges.get();
// As discussed with @eddyb, this is for disabling unreachable_code
// warnings on patterns (they're now subsumed by unreachable_patterns
// warnings).
match all_pats_diverge {
Diverges::Maybe => Diverges::Maybe,
Diverges::Always { .. } | Diverges::WarnedAlways => Diverges::WarnedAlways,
}
})
.collect();
// #55810: Type check patterns first so we get types for all bindings.
for arm in arms {
self.check_pat_top(&arm.pat, scrut_ty, Some(scrut.span), true);
}
// Now typecheck the blocks.
//
@ -104,11 +87,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
CoerceMany::with_coercion_sites(coerce_first, arms)
};
let mut other_arms = vec![]; // used only for diagnostics
let mut other_arms = vec![]; // Used only for diagnostics.
let mut prior_arm_ty = None;
for (i, (arm, pats_diverge)) in arms.iter().zip(all_arm_pats_diverge).enumerate() {
for (i, arm) in arms.iter().enumerate() {
if let Some(g) = &arm.guard {
self.diverges.set(pats_diverge);
self.diverges.set(Diverges::Maybe);
match g {
hir::Guard::If(e) => {
self.check_expr_has_type_or_error(e, tcx.types.bool, |_| {})
@ -116,7 +99,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
}
self.diverges.set(pats_diverge);
self.diverges.set(Diverges::Maybe);
let arm_ty = if source_if
&& if_no_else
&& i != 0
@ -200,16 +183,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
arms: &'tcx [hir::Arm<'tcx>],
source: hir::MatchSource,
) {
if self.diverges.get().is_always() {
use hir::MatchSource::*;
let msg = match source {
IfDesugar { .. } | IfLetDesugar { .. } => "block in `if` expression",
WhileDesugar { .. } | WhileLetDesugar { .. } => "block in `while` expression",
_ => "arm",
};
for arm in arms {
self.warn_if_unreachable(arm.body.hir_id, arm.body.span, msg);
}
use hir::MatchSource::*;
let msg = match source {
IfDesugar { .. } | IfLetDesugar { .. } => "block in `if` expression",
WhileDesugar { .. } | WhileLetDesugar { .. } => "block in `while` expression",
_ => "arm",
};
for arm in arms {
self.warn_if_unreachable(arm.body.hir_id, arm.body.span, msg);
}
}

@ -165,10 +165,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
// Hide the outer diverging and has_errors flags.
let old_diverges = self.diverges.get();
let old_has_errors = self.has_errors.get();
self.diverges.set(Diverges::Maybe);
self.has_errors.set(false);
let old_diverges = self.diverges.replace(Diverges::Maybe);
let old_has_errors = self.has_errors.replace(false);
let ty = self.check_expr_kind(expr, expected, needs);

@ -4429,10 +4429,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.warn_if_unreachable(stmt.hir_id, stmt.span, "statement");
// Hide the outer diverging and `has_errors` flags.
let old_diverges = self.diverges.get();
let old_has_errors = self.has_errors.get();
self.diverges.set(Diverges::Maybe);
self.has_errors.set(false);
let old_diverges = self.diverges.replace(Diverges::Maybe);
let old_has_errors = self.has_errors.replace(false);
match stmt.kind {
hir::StmtKind::Local(ref l) => {
@ -4442,7 +4440,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir::StmtKind::Item(_) => {}
hir::StmtKind::Expr(ref expr) => {
// Check with expected type of `()`.
self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit(), |err| {
self.suggest_semicolon_at_end(expr.span, err);
});

@ -1 +1 @@
Subproject commit ad3dbe10e1e654fb1f032a5dd9481d7cbaa00d65
Subproject commit f6449ba236db31995255ac5e4cad4ab88296a7c6

@ -1 +1 @@
Subproject commit fd0428f622feee209e6014b802f5717d48d9e978
Subproject commit 3e74853d1f9893cf2a47f28b658711d8f9f97b6b