mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
minor: correct some typos
This commit is contained in:
parent
b0be2967cc
commit
ba2910a3a7
20 changed files with 402 additions and 205 deletions
|
@ -13,7 +13,7 @@ use crate::{
|
|||
item_scope::ItemInNs,
|
||||
nameres::DefMap,
|
||||
path::{ModPath, PathKind},
|
||||
visibility::{Visibility, VisibilityExplicity},
|
||||
visibility::{Visibility, VisibilityExplicitness},
|
||||
CrateRootModuleId, ModuleDefId, ModuleId,
|
||||
};
|
||||
|
||||
|
@ -544,11 +544,11 @@ fn find_local_import_locations(
|
|||
if let Some((name, vis, declared)) = data.scope.name_of(item) {
|
||||
if vis.is_visible_from(db, from) {
|
||||
let is_pub_or_explicit = match vis {
|
||||
Visibility::Module(_, VisibilityExplicity::Explicit) => {
|
||||
Visibility::Module(_, VisibilityExplicitness::Explicit) => {
|
||||
cov_mark::hit!(explicit_private_imports);
|
||||
true
|
||||
}
|
||||
Visibility::Module(_, VisibilityExplicity::Implicit) => {
|
||||
Visibility::Module(_, VisibilityExplicitness::Implicit) => {
|
||||
cov_mark::hit!(discount_private_imports);
|
||||
false
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use syntax::ast;
|
|||
use crate::{
|
||||
db::DefDatabase,
|
||||
per_ns::PerNs,
|
||||
visibility::{Visibility, VisibilityExplicity},
|
||||
visibility::{Visibility, VisibilityExplicitness},
|
||||
AdtId, BuiltinType, ConstId, ExternCrateId, HasModule, ImplId, LocalModuleId, Lookup, MacroId,
|
||||
ModuleDefId, ModuleId, TraitId, UseId,
|
||||
};
|
||||
|
@ -653,14 +653,16 @@ impl ItemScope {
|
|||
.map(|(_, vis, _)| vis)
|
||||
.chain(self.values.values_mut().map(|(_, vis, _)| vis))
|
||||
.chain(self.unnamed_trait_imports.values_mut().map(|(vis, _)| vis))
|
||||
.for_each(|vis| *vis = Visibility::Module(this_module, VisibilityExplicity::Implicit));
|
||||
.for_each(|vis| {
|
||||
*vis = Visibility::Module(this_module, VisibilityExplicitness::Implicit)
|
||||
});
|
||||
|
||||
for (mac, vis, import) in self.macros.values_mut() {
|
||||
if matches!(mac, MacroId::ProcMacroId(_) if import.is_none()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*vis = Visibility::Module(this_module, VisibilityExplicity::Implicit);
|
||||
*vis = Visibility::Module(this_module, VisibilityExplicitness::Implicit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ use crate::{
|
|||
generics::{GenericParams, LifetimeParamData, TypeOrConstParamData},
|
||||
path::{path, AssociatedTypeBinding, GenericArgs, ImportAlias, ModPath, Path, PathKind},
|
||||
type_ref::{Mutability, TraitRef, TypeBound, TypeRef},
|
||||
visibility::{RawVisibility, VisibilityExplicity},
|
||||
visibility::{RawVisibility, VisibilityExplicitness},
|
||||
BlockId, Lookup,
|
||||
};
|
||||
|
||||
|
@ -253,10 +253,10 @@ impl ItemVisibilities {
|
|||
RawVisibility::Public => RawVisibilityId::PUB,
|
||||
RawVisibility::Module(path, explicitiy) if path.segments().is_empty() => {
|
||||
match (&path.kind, explicitiy) {
|
||||
(PathKind::Super(0), VisibilityExplicity::Explicit) => {
|
||||
(PathKind::Super(0), VisibilityExplicitness::Explicit) => {
|
||||
RawVisibilityId::PRIV_EXPLICIT
|
||||
}
|
||||
(PathKind::Super(0), VisibilityExplicity::Implicit) => {
|
||||
(PathKind::Super(0), VisibilityExplicitness::Implicit) => {
|
||||
RawVisibilityId::PRIV_IMPLICIT
|
||||
}
|
||||
(PathKind::Crate, _) => RawVisibilityId::PUB_CRATE,
|
||||
|
@ -270,11 +270,11 @@ impl ItemVisibilities {
|
|||
|
||||
static VIS_PUB: RawVisibility = RawVisibility::Public;
|
||||
static VIS_PRIV_IMPLICIT: RawVisibility =
|
||||
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Implicit);
|
||||
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicitness::Implicit);
|
||||
static VIS_PRIV_EXPLICIT: RawVisibility =
|
||||
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Explicit);
|
||||
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicitness::Explicit);
|
||||
static VIS_PUB_CRATE: RawVisibility =
|
||||
RawVisibility::Module(ModPath::from_kind(PathKind::Crate), VisibilityExplicity::Explicit);
|
||||
RawVisibility::Module(ModPath::from_kind(PathKind::Crate), VisibilityExplicitness::Explicit);
|
||||
|
||||
#[derive(Default, Debug, Eq, PartialEq)]
|
||||
struct ItemTreeData {
|
||||
|
|
|
@ -460,13 +460,13 @@ fn test_concat_expand() {
|
|||
#[rustc_builtin_macro]
|
||||
macro_rules! concat {}
|
||||
|
||||
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false, '"', '\0'); }
|
||||
fn main() { concat!("fo", "o", 0, r#"bar"#, "\n", false, '"', '\0'); }
|
||||
"##,
|
||||
expect![[r##"
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! concat {}
|
||||
|
||||
fn main() { "foor0bar\nfalse\"\u{0}"; }
|
||||
fn main() { "foo0bar\nfalse\"\u{0}"; }
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -544,11 +544,11 @@ fn test_proptest_arbitrary() {
|
|||
check(
|
||||
r#"
|
||||
macro_rules! arbitrary {
|
||||
([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
|
||||
([$($bounds : tt)*] $typ: ty, $strategy: ty, $params: ty;
|
||||
$args: ident => $logic: expr) => {
|
||||
impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
|
||||
type Parameters = $params;
|
||||
type Strategy = $strat;
|
||||
type Strategy = $strategy;
|
||||
fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
|
||||
$logic
|
||||
}
|
||||
|
@ -569,11 +569,11 @@ arbitrary!(
|
|||
"#,
|
||||
expect![[r#"
|
||||
macro_rules! arbitrary {
|
||||
([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
|
||||
([$($bounds : tt)*] $typ: ty, $strategy: ty, $params: ty;
|
||||
$args: ident => $logic: expr) => {
|
||||
impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
|
||||
type Parameters = $params;
|
||||
type Strategy = $strat;
|
||||
type Strategy = $strategy;
|
||||
fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
|
||||
$logic
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ use crate::{
|
|||
nameres::{diagnostics::DefDiagnostic, path_resolution::ResolveMode},
|
||||
path::ModPath,
|
||||
per_ns::PerNs,
|
||||
visibility::{Visibility, VisibilityExplicity},
|
||||
visibility::{Visibility, VisibilityExplicitness},
|
||||
AstId, BlockId, BlockLoc, CrateRootModuleId, EnumId, EnumVariantId, ExternCrateId, FunctionId,
|
||||
LocalModuleId, Lookup, MacroExpander, MacroId, ModuleId, ProcMacroId, UseId,
|
||||
};
|
||||
|
@ -336,7 +336,7 @@ impl DefMap {
|
|||
// this visibility for anything outside IDE, so that's probably OK.
|
||||
let visibility = Visibility::Module(
|
||||
ModuleId { krate, local_id, block: None },
|
||||
VisibilityExplicity::Implicit,
|
||||
VisibilityExplicitness::Implicit,
|
||||
);
|
||||
let module_data = ModuleData::new(
|
||||
ModuleOrigin::BlockExpr { block: block.ast_id, id: block_id },
|
||||
|
|
|
@ -87,7 +87,7 @@ impl DefMap {
|
|||
within_impl: bool,
|
||||
) -> Option<Visibility> {
|
||||
let mut vis = match visibility {
|
||||
RawVisibility::Module(path, explicity) => {
|
||||
RawVisibility::Module(path, explicitness) => {
|
||||
let (result, remaining) =
|
||||
self.resolve_path(db, original_module, path, BuiltinShadowMode::Module, None);
|
||||
if remaining.is_some() {
|
||||
|
@ -95,7 +95,7 @@ impl DefMap {
|
|||
}
|
||||
let types = result.take_types()?;
|
||||
match types {
|
||||
ModuleDefId::ModuleId(m) => Visibility::Module(m, *explicity),
|
||||
ModuleDefId::ModuleId(m) => Visibility::Module(m, *explicitness),
|
||||
// error: visibility needs to refer to module
|
||||
_ => {
|
||||
return None;
|
||||
|
|
|
@ -20,14 +20,17 @@ use crate::{
|
|||
pub enum RawVisibility {
|
||||
/// `pub(in module)`, `pub(crate)` or `pub(super)`. Also private, which is
|
||||
/// equivalent to `pub(self)`.
|
||||
Module(ModPath, VisibilityExplicity),
|
||||
Module(ModPath, VisibilityExplicitness),
|
||||
/// `pub`.
|
||||
Public,
|
||||
}
|
||||
|
||||
impl RawVisibility {
|
||||
pub(crate) const fn private() -> RawVisibility {
|
||||
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Implicit)
|
||||
RawVisibility::Module(
|
||||
ModPath::from_kind(PathKind::Super(0)),
|
||||
VisibilityExplicitness::Implicit,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn from_ast(
|
||||
|
@ -53,19 +56,19 @@ impl RawVisibility {
|
|||
None => return RawVisibility::private(),
|
||||
Some(path) => path,
|
||||
};
|
||||
RawVisibility::Module(path, VisibilityExplicity::Explicit)
|
||||
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
|
||||
}
|
||||
ast::VisibilityKind::PubCrate => {
|
||||
let path = ModPath::from_kind(PathKind::Crate);
|
||||
RawVisibility::Module(path, VisibilityExplicity::Explicit)
|
||||
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
|
||||
}
|
||||
ast::VisibilityKind::PubSuper => {
|
||||
let path = ModPath::from_kind(PathKind::Super(1));
|
||||
RawVisibility::Module(path, VisibilityExplicity::Explicit)
|
||||
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
|
||||
}
|
||||
ast::VisibilityKind::PubSelf => {
|
||||
let path = ModPath::from_kind(PathKind::Super(0));
|
||||
RawVisibility::Module(path, VisibilityExplicity::Explicit)
|
||||
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
|
||||
}
|
||||
ast::VisibilityKind::Pub => RawVisibility::Public,
|
||||
}
|
||||
|
@ -85,7 +88,7 @@ impl RawVisibility {
|
|||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Visibility {
|
||||
/// Visibility is restricted to a certain module.
|
||||
Module(ModuleId, VisibilityExplicity),
|
||||
Module(ModuleId, VisibilityExplicitness),
|
||||
/// Visibility is unrestricted.
|
||||
Public,
|
||||
}
|
||||
|
@ -206,12 +209,12 @@ impl Visibility {
|
|||
|
||||
/// Whether the item was imported through `pub(crate) use` or just `use`.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum VisibilityExplicity {
|
||||
pub enum VisibilityExplicitness {
|
||||
Explicit,
|
||||
Implicit,
|
||||
}
|
||||
|
||||
impl VisibilityExplicity {
|
||||
impl VisibilityExplicitness {
|
||||
pub fn is_explicit(&self) -> bool {
|
||||
matches!(self, Self::Explicit)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue