diff options
| author | bors <bors@rust-lang.org> | 2024-12-25 06:07:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-12-25 06:07:04 +0000 |
| commit | 68b9e4f5f5566424b8edc2c75feefe3a4ee2fa72 (patch) | |
| tree | ca1fd24cb9ad8623ec1edc4ad85ab5c61ebf1352 /compiler | |
| parent | 41f2f5c0b7d5fb68685030edc62e66a21cae38ef (diff) | |
| parent | 1d101174451d735934b6442fd62f743deaf16c35 (diff) | |
| download | rust-68b9e4f5f5566424b8edc2c75feefe3a4ee2fa72.tar.gz rust-68b9e4f5f5566424b8edc2c75feefe3a4ee2fa72.zip | |
Auto merge of #134748 - DianQK:rollup-3y5fzcx, r=DianQK
Rollup of 3 pull requests Successful merges: - #134525 (Arbitrary self types v2: unstable doc updates.) - #134735 (Consider arm to diverge if guard diverges) - #134741 (Actually print all the relevant parts of a coroutine in verbose mode) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/_match.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 6 |
2 files changed, 16 insertions, 2 deletions
diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index 243313ee876..87300f5bb83 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -77,12 +77,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut prior_non_diverging_arms = vec![]; // Used only for diagnostics. let mut prior_arm = None; for arm in arms { + self.diverges.set(Diverges::Maybe); + if let Some(e) = &arm.guard { - self.diverges.set(Diverges::Maybe); self.check_expr_has_type_or_error(e, tcx.types.bool, |_| {}); + + // FIXME: If this is the first arm and the pattern is irrefutable, + // e.g. `_` or `x`, and the guard diverges, then the whole match + // may also be considered to diverge. We should warn on all subsequent + // arms, too, just like we do for diverging scrutinees above. } - self.diverges.set(Diverges::Maybe); + // N.B. We don't reset diverges here b/c we want to warn in the arm + // if the guard diverges, like: `x if { loop {} } => f()`, and we + // also want to consider the arm to diverge itself. let arm_ty = self.check_expr_with_expectation(arm.body, expected); all_arms_diverge &= self.diverges.get(); diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 8e89331ef03..9fe1caa4b58 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -841,6 +841,12 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { p!( " upvar_tys=", print(args.as_coroutine().tupled_upvars_ty()), + " resume_ty=", + print(args.as_coroutine().resume_ty()), + " yield_ty=", + print(args.as_coroutine().yield_ty()), + " return_ty=", + print(args.as_coroutine().return_ty()), " witness=", print(args.as_coroutine().witness()) ); |
