Refactor PatternError
structure
This commit is contained in:
parent
ec57c60c50
commit
bc243a7f55
9 changed files with 50 additions and 54 deletions
|
@ -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,9 @@ 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)
|
||||
});
|
||||
if is_associated_const {
|
||||
self.errors.push(PatternError::AssocConstInPattern(span));
|
||||
}
|
||||
|
||||
return pat_from_kind(PatKind::Wild);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue