diff options
| author | bors <bors@rust-lang.org> | 2021-06-19 19:46:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-06-19 19:46:02 +0000 |
| commit | 150fad30ea25e812d481a784d02c95d3394b234b (patch) | |
| tree | 064fbc91be4d645df03129d317e61ae7b97d00ee /compiler/rustc_mir_build/src | |
| parent | 6b354a13820a444f834a33365ae4a8d97d7d27ce (diff) | |
| parent | e44e65e8881f75e981ceb843d0e189ad55c6b4e3 (diff) | |
| download | rust-150fad30ea25e812d481a784d02c95d3394b234b.tar.gz rust-150fad30ea25e812d481a784d02c95d3394b234b.zip | |
Auto merge of #86460 - JohnTitor:use-static-in-pattern-err, r=oli-obk
Refactor `PatternError` structure Now we emit the `StaticInPattern` error precisely. Fixes #68395 r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_mir_build/src')
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/pattern/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 3225d302cb3..3ea76fb99d5 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -423,6 +423,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { _ => { let pattern_error = match res { Res::Def(DefKind::ConstParam, _) => PatternError::ConstParamInPattern(span), + Res::Def(DefKind::Static, _) => PatternError::StaticInPattern(span), _ => PatternError::NonConstPath(span), }; self.errors.push(pattern_error); @@ -468,11 +469,10 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { let instance = match ty::Instance::resolve(self.tcx, param_env_reveal_all, def_id, substs) { Ok(Some(i)) => i, Ok(None) => { - self.errors.push(if is_associated_const { - PatternError::AssocConstInPattern(span) - } else { - PatternError::StaticInPattern(span) - }); + // It should be assoc consts if there's no error but we cannot resolve it. + debug_assert!(is_associated_const); + + self.errors.push(PatternError::AssocConstInPattern(span)); return pat_from_kind(PatKind::Wild); } |
