Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
CARGO_NET_RETRY: 10
CI: 1
RUST_BACKTRACE: short
RUSTFLAGS: -D warnings
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
RUSTUP_MAX_RETRIES: 10

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTFLAGS: -D warnings
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
RUSTUP_MAX_RETRIES: 10

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTFLAGS: -D warnings
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
RUSTUP_MAX_RETRIES: 10

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rustdoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTFLAGS: -D warnings
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
RUSTUP_MAX_RETRIES: 10

jobs:
Expand Down
4 changes: 1 addition & 3 deletions crates/base_db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use cfg::CfgOptions;
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::SmolStr;
use tt::TokenExpander;
use vfs::{file_set::FileSet, VfsPath};

pub use vfs::FileId;
use vfs::{file_set::FileSet, FileId, VfsPath};

/// Files are grouped into source roots. A source root is a directory on the
/// file systems which is watched for changes. Typically it corresponds to a
Expand Down
4 changes: 2 additions & 2 deletions crates/base_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pub use crate::{
change::Change,
input::{
CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env,
FileId, ProcMacroId, SourceRoot, SourceRootId,
ProcMacroId, SourceRoot, SourceRootId,
},
};
pub use salsa;
pub use vfs::{file_set::FileSet, VfsPath};
pub use vfs::{file_set::FileSet, FileId, VfsPath};

#[macro_export]
macro_rules! impl_intern_key {
Expand Down
6 changes: 3 additions & 3 deletions crates/hir_def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ pub(crate) struct LowerCtx {
}

impl LowerCtx {
pub fn new(db: &dyn DefDatabase, file_id: HirFileId) -> Self {
pub(crate) fn new(db: &dyn DefDatabase, file_id: HirFileId) -> Self {
LowerCtx { hygiene: Hygiene::new(db.upcast(), file_id) }
}
pub fn with_hygiene(hygiene: &Hygiene) -> Self {
pub(crate) fn with_hygiene(hygiene: &Hygiene) -> Self {
LowerCtx { hygiene: hygiene.clone() }
}

pub fn lower_path(&self, ast: ast::Path) -> Option<Path> {
pub(crate) fn lower_path(&self, ast: ast::Path) -> Option<Path> {
Path::from_src(ast, &self.hygiene)
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/hir_def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,12 @@ impl AsMacroCall for InFile<&ast::MacroCall> {
/// Helper wrapper for `AstId` with `ModPath`
#[derive(Clone, Debug, Eq, PartialEq)]
struct AstIdWithPath<T: ast::AstNode> {
pub ast_id: AstId<T>,
pub path: path::ModPath,
ast_id: AstId<T>,
path: path::ModPath,
}

impl<T: ast::AstNode> AstIdWithPath<T> {
pub fn new(file_id: HirFileId, ast_id: FileAstId<T>, path: path::ModPath) -> AstIdWithPath<T> {
fn new(file_id: HirFileId, ast_id: FileAstId<T>, path: path::ModPath) -> AstIdWithPath<T> {
AstIdWithPath { ast_id: AstId::new(file_id, ast_id), path }
}
}
Expand Down
14 changes: 7 additions & 7 deletions crates/hir_def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ enum ImportSource {

#[derive(Clone, Debug, Eq, PartialEq)]
struct Import {
pub path: ModPath,
pub alias: Option<ImportAlias>,
pub visibility: RawVisibility,
pub is_glob: bool,
pub is_prelude: bool,
pub is_extern_crate: bool,
pub is_macro_use: bool,
path: ModPath,
alias: Option<ImportAlias>,
visibility: RawVisibility,
is_glob: bool,
is_prelude: bool,
is_extern_crate: bool,
is_macro_use: bool,
source: ImportSource,
}

Expand Down
14 changes: 7 additions & 7 deletions crates/hir_def/src/test_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{db::DefDatabase, ModuleDefId};
crate::db::DefDatabaseStorage
)]
#[derive(Default)]
pub struct TestDB {
pub(crate) struct TestDB {
storage: salsa::Storage<TestDB>,
events: Mutex<Option<Vec<salsa::Event>>>,
}
Expand Down Expand Up @@ -72,7 +72,7 @@ impl FileLoader for TestDB {
}

impl TestDB {
pub fn module_for_file(&self, file_id: FileId) -> crate::ModuleId {
pub(crate) fn module_for_file(&self, file_id: FileId) -> crate::ModuleId {
for &krate in self.relevant_crates(file_id).iter() {
let crate_def_map = self.crate_def_map(krate);
for (local_id, data) in crate_def_map.modules.iter() {
Expand All @@ -84,13 +84,13 @@ impl TestDB {
panic!("Can't find module for file")
}

pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> {
pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> {
*self.events.lock().unwrap() = Some(Vec::new());
f();
self.events.lock().unwrap().take().unwrap()
}

pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
let events = self.log(f);
events
.into_iter()
Expand All @@ -105,7 +105,7 @@ impl TestDB {
.collect()
}

pub fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> {
pub(crate) fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> {
let mut files = Vec::new();
let crate_graph = self.crate_graph();
for krate in crate_graph.iter() {
Expand All @@ -129,7 +129,7 @@ impl TestDB {
.collect()
}

pub fn diagnostics<F: FnMut(&dyn Diagnostic)>(&self, mut cb: F) {
pub(crate) fn diagnostics<F: FnMut(&dyn Diagnostic)>(&self, mut cb: F) {
let crate_graph = self.crate_graph();
for krate in crate_graph.iter() {
let crate_def_map = self.crate_def_map(krate);
Expand All @@ -148,7 +148,7 @@ impl TestDB {
}
}

pub fn check_diagnostics(&self) {
pub(crate) fn check_diagnostics(&self) {
let db: &TestDB = self;
let annotations = db.extract_annotations();
assert!(!annotations.is_empty());
Expand Down
6 changes: 3 additions & 3 deletions crates/hir_ty/src/diagnostics/decl_check/case_conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/// Converts an identifier to an UpperCamelCase form.
/// Returns `None` if the string is already is UpperCamelCase.
pub fn to_camel_case(ident: &str) -> Option<String> {
pub(crate) fn to_camel_case(ident: &str) -> Option<String> {
if is_camel_case(ident) {
return None;
}
Expand Down Expand Up @@ -59,7 +59,7 @@ pub fn to_camel_case(ident: &str) -> Option<String> {

/// Converts an identifier to a lower_snake_case form.
/// Returns `None` if the string is already in lower_snake_case.
pub fn to_lower_snake_case(ident: &str) -> Option<String> {
pub(crate) fn to_lower_snake_case(ident: &str) -> Option<String> {
if is_lower_snake_case(ident) {
return None;
} else if is_upper_snake_case(ident) {
Expand All @@ -71,7 +71,7 @@ pub fn to_lower_snake_case(ident: &str) -> Option<String> {

/// Converts an identifier to an UPPER_SNAKE_CASE form.
/// Returns `None` if the string is already is UPPER_SNAKE_CASE.
pub fn to_upper_snake_case(ident: &str) -> Option<String> {
pub(crate) fn to_upper_snake_case(ident: &str) -> Option<String> {
if is_upper_snake_case(ident) {
return None;
} else if is_lower_snake_case(ident) {
Expand Down
15 changes: 4 additions & 11 deletions crates/hir_ty/src/diagnostics/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,10 @@ use crate::{
ApplicationTy, InferenceResult, Ty, TypeCtor,
};

pub use hir_def::{
body::{
scope::{ExprScopes, ScopeEntry, ScopeId},
Body, BodySourceMap, ExprPtr, ExprSource, PatPtr, PatSource,
},
expr::{
ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp,
MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, UnaryOp,
},
src::HasSource,
LocalFieldId, Lookup, VariantId,
pub(crate) use hir_def::{
body::{Body, BodySourceMap},
expr::{Expr, ExprId, MatchArm, Pat, PatId},
LocalFieldId, VariantId,
};

pub(super) struct ExprValidator<'a, 'b: 'a> {
Expand Down
8 changes: 4 additions & 4 deletions crates/hir_ty/src/diagnostics/unsafe_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ impl<'a, 'b> UnsafeValidator<'a, 'b> {
}
}

pub struct UnsafeExpr {
pub expr: ExprId,
pub inside_unsafe_block: bool,
pub(crate) struct UnsafeExpr {
pub(crate) expr: ExprId,
pub(crate) inside_unsafe_block: bool,
}

pub fn unsafe_expressions(
pub(crate) fn unsafe_expressions(
db: &dyn HirDatabase,
infer: &InferenceResult,
def: DefWithBodyId,
Expand Down
6 changes: 3 additions & 3 deletions crates/hir_ty/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ struct InferenceContext<'a> {

#[derive(Clone, Debug)]
struct BreakableContext {
pub may_break: bool,
pub break_ty: Ty,
pub label: Option<name::Name>,
may_break: bool,
break_ty: Ty,
label: Option<name::Name>,
}

fn find_breakable<'c>(
Expand Down
2 changes: 1 addition & 1 deletion crates/hir_ty/src/infer/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'a> InferenceContext<'a> {
}
}

pub fn callable_sig(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<Ty>, Ty)> {
pub(crate) fn callable_sig(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<Ty>, Ty)> {
match ty.callable_sig(self.db) {
Some(sig) => Some((sig.params().to_vec(), sig.ret().clone())),
None => self.callable_sig_from_fn_trait(ty, num_args),
Expand Down
35 changes: 22 additions & 13 deletions crates/hir_ty/src/infer/unify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ where
}

impl<T> Canonicalized<T> {
pub fn decanonicalize_ty(&self, mut ty: Ty) -> Ty {
pub(super) fn decanonicalize_ty(&self, mut ty: Ty) -> Ty {
ty.walk_mut_binders(
&mut |ty, binders| {
if let &mut Ty::Bound(bound) = ty {
Expand All @@ -141,7 +141,11 @@ impl<T> Canonicalized<T> {
ty
}

pub fn apply_solution(&self, ctx: &mut InferenceContext<'_>, solution: Canonical<Substs>) {
pub(super) fn apply_solution(
&self,
ctx: &mut InferenceContext<'_>,
solution: Canonical<Substs>,
) {
// the solution may contain new variables, which we need to convert to new inference vars
let new_vars = Substs(
solution
Expand All @@ -164,7 +168,7 @@ impl<T> Canonicalized<T> {
}
}

pub fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substs> {
pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substs> {
let mut table = InferenceTable::new();
let vars = Substs(
tys.kinds
Expand Down Expand Up @@ -199,41 +203,46 @@ pub(crate) struct InferenceTable {
}

impl InferenceTable {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
InferenceTable { var_unification_table: InPlaceUnificationTable::new() }
}

pub fn new_type_var(&mut self) -> Ty {
pub(crate) fn new_type_var(&mut self) -> Ty {
Ty::Infer(InferTy::TypeVar(self.var_unification_table.new_key(TypeVarValue::Unknown)))
}

pub fn new_integer_var(&mut self) -> Ty {
pub(crate) fn new_integer_var(&mut self) -> Ty {
Ty::Infer(InferTy::IntVar(self.var_unification_table.new_key(TypeVarValue::Unknown)))
}

pub fn new_float_var(&mut self) -> Ty {
pub(crate) fn new_float_var(&mut self) -> Ty {
Ty::Infer(InferTy::FloatVar(self.var_unification_table.new_key(TypeVarValue::Unknown)))
}

pub fn new_maybe_never_type_var(&mut self) -> Ty {
pub(crate) fn new_maybe_never_type_var(&mut self) -> Ty {
Ty::Infer(InferTy::MaybeNeverTypeVar(
self.var_unification_table.new_key(TypeVarValue::Unknown),
))
}

pub fn resolve_ty_completely(&mut self, ty: Ty) -> Ty {
pub(crate) fn resolve_ty_completely(&mut self, ty: Ty) -> Ty {
self.resolve_ty_completely_inner(&mut Vec::new(), ty)
}

pub fn resolve_ty_as_possible(&mut self, ty: Ty) -> Ty {
pub(crate) fn resolve_ty_as_possible(&mut self, ty: Ty) -> Ty {
self.resolve_ty_as_possible_inner(&mut Vec::new(), ty)
}

pub fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool {
pub(crate) fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool {
self.unify_inner(ty1, ty2, 0)
}

pub fn unify_substs(&mut self, substs1: &Substs, substs2: &Substs, depth: usize) -> bool {
pub(crate) fn unify_substs(
&mut self,
substs1: &Substs,
substs2: &Substs,
depth: usize,
) -> bool {
substs1.0.iter().zip(substs2.0.iter()).all(|(t1, t2)| self.unify_inner(t1, t2, depth))
}

Expand Down Expand Up @@ -331,7 +340,7 @@ impl InferenceTable {

/// If `ty` is a type variable with known type, returns that type;
/// otherwise, return ty.
pub fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> {
pub(crate) fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> {
let mut ty = Cow::Borrowed(ty);
// The type variable could resolve to a int/float variable. Hence try
// resolving up to three times; each type of variable shouldn't occur
Expand Down
3 changes: 1 addition & 2 deletions crates/hir_ty/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! The type system. We currently use this to infer types for completion, hover
//! information and various assists.

#[allow(unused)]
macro_rules! eprintln {
($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
Expand Down Expand Up @@ -1115,5 +1114,5 @@ pub struct ReturnTypeImplTraits {

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub(crate) struct ReturnTypeImplTrait {
pub bounds: Binders<Vec<GenericPredicate>>,
pub(crate) bounds: Binders<Vec<GenericPredicate>>,
}
6 changes: 3 additions & 3 deletions crates/hir_ty/src/test_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use test_utils::extract_annotations;
crate::db::HirDatabaseStorage
)]
#[derive(Default)]
pub struct TestDB {
pub(crate) struct TestDB {
storage: salsa::Storage<TestDB>,
events: Mutex<Option<Vec<salsa::Event>>>,
}
Expand Down Expand Up @@ -113,13 +113,13 @@ impl TestDB {
}

impl TestDB {
pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> {
pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> {
*self.events.lock().unwrap() = Some(Vec::new());
f();
self.events.lock().unwrap().take().unwrap()
}

pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
let events = self.log(f);
events
.into_iter()
Expand Down
Loading