Replace enum ==s with matches where it makes sense

This commit is contained in:
Maybe Waffle 2023-01-30 11:03:32 +00:00
parent f55b0022db
commit fd649a3cc5
16 changed files with 258 additions and 231 deletions

View file

@ -298,14 +298,15 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
self.r.record_partial_res(id, PartialRes::new(res));
}
if module.is_normal() {
if res == Res::Err {
Ok(ty::Visibility::Public)
} else {
let vis = ty::Visibility::Restricted(res.def_id());
if self.r.is_accessible_from(vis, parent_scope.module) {
Ok(vis.expect_local())
} else {
Err(VisResolutionError::AncestorOnly(path.span))
match res {
Res::Err => Ok(ty::Visibility::Public),
_ => {
let vis = ty::Visibility::Restricted(res.def_id());
if self.r.is_accessible_from(vis, parent_scope.module) {
Ok(vis.expect_local())
} else {
Err(VisResolutionError::AncestorOnly(path.span))
}
}
}
} else {

View file

@ -1552,12 +1552,12 @@ impl<'a> Resolver<'a> {
if b.is_extern_crate() && ident.span.rust_2018() {
help_msgs.push(format!("use `::{ident}` to refer to this {thing} unambiguously"))
}
if misc == AmbiguityErrorMisc::SuggestCrate {
help_msgs
.push(format!("use `crate::{ident}` to refer to this {thing} unambiguously"))
} else if misc == AmbiguityErrorMisc::SuggestSelf {
help_msgs
.push(format!("use `self::{ident}` to refer to this {thing} unambiguously"))
match misc {
AmbiguityErrorMisc::SuggestCrate => help_msgs
.push(format!("use `crate::{ident}` to refer to this {thing} unambiguously")),
AmbiguityErrorMisc::SuggestSelf => help_msgs
.push(format!("use `self::{ident}` to refer to this {thing} unambiguously")),
AmbiguityErrorMisc::FromPrelude | AmbiguityErrorMisc::None => {}
}
err.span_note(b.span, &note_msg);