diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-02 13:08:53 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-02 13:08:53 +0000 |
commit | 731b38fa3c1694648e6c8e60f61820f9783343eb (patch) | |
tree | b3f4e94e8eac9bb24296aacafacb100930bee59e /crates | |
parent | 6507877e7039d4517682a4fc232356662f509d81 (diff) | |
parent | b6101184537b1165cfdd5fc473e04ad4c5b7bffa (diff) |
Merge #6438
6438: Deny unreachable-pub r=matklad a=matklad
It's very useful when `pub` is equivalent to "this is crate's public
API", let's enforce this!
Ideally, we should enforce it for local `cargo test`, and only during
CI, but that needs https://github.com/rust-lang/cargo/issues/5034.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
29 files changed, 148 insertions, 149 deletions
diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index 87f0a0ce5..31907ed98 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs | |||
@@ -12,9 +12,7 @@ use cfg::CfgOptions; | |||
12 | use rustc_hash::{FxHashMap, FxHashSet}; | 12 | use rustc_hash::{FxHashMap, FxHashSet}; |
13 | use syntax::SmolStr; | 13 | use syntax::SmolStr; |
14 | use tt::TokenExpander; | 14 | use tt::TokenExpander; |
15 | use vfs::{file_set::FileSet, VfsPath}; | 15 | use vfs::{file_set::FileSet, FileId, VfsPath}; |
16 | |||
17 | pub use vfs::FileId; | ||
18 | 16 | ||
19 | /// Files are grouped into source roots. A source root is a directory on the | 17 | /// Files are grouped into source roots. A source root is a directory on the |
20 | /// file systems which is watched for changes. Typically it corresponds to a | 18 | /// file systems which is watched for changes. Typically it corresponds to a |
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index 0804202d6..ce75a5337 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs | |||
@@ -14,11 +14,11 @@ pub use crate::{ | |||
14 | change::Change, | 14 | change::Change, |
15 | input::{ | 15 | input::{ |
16 | CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, | 16 | CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, |
17 | FileId, ProcMacroId, SourceRoot, SourceRootId, | 17 | ProcMacroId, SourceRoot, SourceRootId, |
18 | }, | 18 | }, |
19 | }; | 19 | }; |
20 | pub use salsa; | 20 | pub use salsa; |
21 | pub use vfs::{file_set::FileSet, VfsPath}; | 21 | pub use vfs::{file_set::FileSet, FileId, VfsPath}; |
22 | 22 | ||
23 | #[macro_export] | 23 | #[macro_export] |
24 | macro_rules! impl_intern_key { | 24 | macro_rules! impl_intern_key { |
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index ddc267b83..1deaa90f2 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs | |||
@@ -45,14 +45,14 @@ pub(crate) struct LowerCtx { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | impl LowerCtx { | 47 | impl LowerCtx { |
48 | pub fn new(db: &dyn DefDatabase, file_id: HirFileId) -> Self { | 48 | pub(crate) fn new(db: &dyn DefDatabase, file_id: HirFileId) -> Self { |
49 | LowerCtx { hygiene: Hygiene::new(db.upcast(), file_id) } | 49 | LowerCtx { hygiene: Hygiene::new(db.upcast(), file_id) } |
50 | } | 50 | } |
51 | pub fn with_hygiene(hygiene: &Hygiene) -> Self { | 51 | pub(crate) fn with_hygiene(hygiene: &Hygiene) -> Self { |
52 | LowerCtx { hygiene: hygiene.clone() } | 52 | LowerCtx { hygiene: hygiene.clone() } |
53 | } | 53 | } |
54 | 54 | ||
55 | pub fn lower_path(&self, ast: ast::Path) -> Option<Path> { | 55 | pub(crate) fn lower_path(&self, ast: ast::Path) -> Option<Path> { |
56 | Path::from_src(ast, &self.hygiene) | 56 | Path::from_src(ast, &self.hygiene) |
57 | } | 57 | } |
58 | } | 58 | } |
diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs index f24a1dd77..1b22d1eec 100644 --- a/crates/hir_def/src/lib.rs +++ b/crates/hir_def/src/lib.rs | |||
@@ -486,12 +486,12 @@ impl AsMacroCall for InFile<&ast::MacroCall> { | |||
486 | /// Helper wrapper for `AstId` with `ModPath` | 486 | /// Helper wrapper for `AstId` with `ModPath` |
487 | #[derive(Clone, Debug, Eq, PartialEq)] | 487 | #[derive(Clone, Debug, Eq, PartialEq)] |
488 | struct AstIdWithPath<T: ast::AstNode> { | 488 | struct AstIdWithPath<T: ast::AstNode> { |
489 | pub ast_id: AstId<T>, | 489 | ast_id: AstId<T>, |
490 | pub path: path::ModPath, | 490 | path: path::ModPath, |
491 | } | 491 | } |
492 | 492 | ||
493 | impl<T: ast::AstNode> AstIdWithPath<T> { | 493 | impl<T: ast::AstNode> AstIdWithPath<T> { |
494 | pub fn new(file_id: HirFileId, ast_id: FileAstId<T>, path: path::ModPath) -> AstIdWithPath<T> { | 494 | fn new(file_id: HirFileId, ast_id: FileAstId<T>, path: path::ModPath) -> AstIdWithPath<T> { |
495 | AstIdWithPath { ast_id: AstId::new(file_id, ast_id), path } | 495 | AstIdWithPath { ast_id: AstId::new(file_id, ast_id), path } |
496 | } | 496 | } |
497 | } | 497 | } |
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 1ff45d244..59b6644c3 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -122,13 +122,13 @@ enum ImportSource { | |||
122 | 122 | ||
123 | #[derive(Clone, Debug, Eq, PartialEq)] | 123 | #[derive(Clone, Debug, Eq, PartialEq)] |
124 | struct Import { | 124 | struct Import { |
125 | pub path: ModPath, | 125 | path: ModPath, |
126 | pub alias: Option<ImportAlias>, | 126 | alias: Option<ImportAlias>, |
127 | pub visibility: RawVisibility, | 127 | visibility: RawVisibility, |
128 | pub is_glob: bool, | 128 | is_glob: bool, |
129 | pub is_prelude: bool, | 129 | is_prelude: bool, |
130 | pub is_extern_crate: bool, | 130 | is_extern_crate: bool, |
131 | pub is_macro_use: bool, | 131 | is_macro_use: bool, |
132 | source: ImportSource, | 132 | source: ImportSource, |
133 | } | 133 | } |
134 | 134 | ||
diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs index 2b36c824a..00fe711fe 100644 --- a/crates/hir_def/src/test_db.rs +++ b/crates/hir_def/src/test_db.rs | |||
@@ -25,7 +25,7 @@ use crate::{db::DefDatabase, ModuleDefId}; | |||
25 | crate::db::DefDatabaseStorage | 25 | crate::db::DefDatabaseStorage |
26 | )] | 26 | )] |
27 | #[derive(Default)] | 27 | #[derive(Default)] |
28 | pub struct TestDB { | 28 | pub(crate) struct TestDB { |
29 | storage: salsa::Storage<TestDB>, | 29 | storage: salsa::Storage<TestDB>, |
30 | events: Mutex<Option<Vec<salsa::Event>>>, | 30 | events: Mutex<Option<Vec<salsa::Event>>>, |
31 | } | 31 | } |
@@ -72,7 +72,7 @@ impl FileLoader for TestDB { | |||
72 | } | 72 | } |
73 | 73 | ||
74 | impl TestDB { | 74 | impl TestDB { |
75 | pub fn module_for_file(&self, file_id: FileId) -> crate::ModuleId { | 75 | pub(crate) fn module_for_file(&self, file_id: FileId) -> crate::ModuleId { |
76 | for &krate in self.relevant_crates(file_id).iter() { | 76 | for &krate in self.relevant_crates(file_id).iter() { |
77 | let crate_def_map = self.crate_def_map(krate); | 77 | let crate_def_map = self.crate_def_map(krate); |
78 | for (local_id, data) in crate_def_map.modules.iter() { | 78 | for (local_id, data) in crate_def_map.modules.iter() { |
@@ -84,13 +84,13 @@ impl TestDB { | |||
84 | panic!("Can't find module for file") | 84 | panic!("Can't find module for file") |
85 | } | 85 | } |
86 | 86 | ||
87 | pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> { | 87 | pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> { |
88 | *self.events.lock().unwrap() = Some(Vec::new()); | 88 | *self.events.lock().unwrap() = Some(Vec::new()); |
89 | f(); | 89 | f(); |
90 | self.events.lock().unwrap().take().unwrap() | 90 | self.events.lock().unwrap().take().unwrap() |
91 | } | 91 | } |
92 | 92 | ||
93 | pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { | 93 | pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { |
94 | let events = self.log(f); | 94 | let events = self.log(f); |
95 | events | 95 | events |
96 | .into_iter() | 96 | .into_iter() |
@@ -105,7 +105,7 @@ impl TestDB { | |||
105 | .collect() | 105 | .collect() |
106 | } | 106 | } |
107 | 107 | ||
108 | pub fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> { | 108 | pub(crate) fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> { |
109 | let mut files = Vec::new(); | 109 | let mut files = Vec::new(); |
110 | let crate_graph = self.crate_graph(); | 110 | let crate_graph = self.crate_graph(); |
111 | for krate in crate_graph.iter() { | 111 | for krate in crate_graph.iter() { |
@@ -129,7 +129,7 @@ impl TestDB { | |||
129 | .collect() | 129 | .collect() |
130 | } | 130 | } |
131 | 131 | ||
132 | pub fn diagnostics<F: FnMut(&dyn Diagnostic)>(&self, mut cb: F) { | 132 | pub(crate) fn diagnostics<F: FnMut(&dyn Diagnostic)>(&self, mut cb: F) { |
133 | let crate_graph = self.crate_graph(); | 133 | let crate_graph = self.crate_graph(); |
134 | for krate in crate_graph.iter() { | 134 | for krate in crate_graph.iter() { |
135 | let crate_def_map = self.crate_def_map(krate); | 135 | let crate_def_map = self.crate_def_map(krate); |
@@ -148,7 +148,7 @@ impl TestDB { | |||
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | pub fn check_diagnostics(&self) { | 151 | pub(crate) fn check_diagnostics(&self) { |
152 | let db: &TestDB = self; | 152 | let db: &TestDB = self; |
153 | let annotations = db.extract_annotations(); | 153 | let annotations = db.extract_annotations(); |
154 | assert!(!annotations.is_empty()); | 154 | assert!(!annotations.is_empty()); |
diff --git a/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs b/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs index b0144a289..14e4d92f0 100644 --- a/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs +++ b/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs | |||
@@ -6,7 +6,7 @@ | |||
6 | 6 | ||
7 | /// Converts an identifier to an UpperCamelCase form. | 7 | /// Converts an identifier to an UpperCamelCase form. |
8 | /// Returns `None` if the string is already is UpperCamelCase. | 8 | /// Returns `None` if the string is already is UpperCamelCase. |
9 | pub fn to_camel_case(ident: &str) -> Option<String> { | 9 | pub(crate) fn to_camel_case(ident: &str) -> Option<String> { |
10 | if is_camel_case(ident) { | 10 | if is_camel_case(ident) { |
11 | return None; | 11 | return None; |
12 | } | 12 | } |
@@ -59,7 +59,7 @@ pub fn to_camel_case(ident: &str) -> Option<String> { | |||
59 | 59 | ||
60 | /// Converts an identifier to a lower_snake_case form. | 60 | /// Converts an identifier to a lower_snake_case form. |
61 | /// Returns `None` if the string is already in lower_snake_case. | 61 | /// Returns `None` if the string is already in lower_snake_case. |
62 | pub fn to_lower_snake_case(ident: &str) -> Option<String> { | 62 | pub(crate) fn to_lower_snake_case(ident: &str) -> Option<String> { |
63 | if is_lower_snake_case(ident) { | 63 | if is_lower_snake_case(ident) { |
64 | return None; | 64 | return None; |
65 | } else if is_upper_snake_case(ident) { | 65 | } else if is_upper_snake_case(ident) { |
@@ -71,7 +71,7 @@ pub fn to_lower_snake_case(ident: &str) -> Option<String> { | |||
71 | 71 | ||
72 | /// Converts an identifier to an UPPER_SNAKE_CASE form. | 72 | /// Converts an identifier to an UPPER_SNAKE_CASE form. |
73 | /// Returns `None` if the string is already is UPPER_SNAKE_CASE. | 73 | /// Returns `None` if the string is already is UPPER_SNAKE_CASE. |
74 | pub fn to_upper_snake_case(ident: &str) -> Option<String> { | 74 | pub(crate) fn to_upper_snake_case(ident: &str) -> Option<String> { |
75 | if is_upper_snake_case(ident) { | 75 | if is_upper_snake_case(ident) { |
76 | return None; | 76 | return None; |
77 | } else if is_lower_snake_case(ident) { | 77 | } else if is_lower_snake_case(ident) { |
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 278a4b947..434b19354 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs | |||
@@ -17,17 +17,10 @@ use crate::{ | |||
17 | ApplicationTy, InferenceResult, Ty, TypeCtor, | 17 | ApplicationTy, InferenceResult, Ty, TypeCtor, |
18 | }; | 18 | }; |
19 | 19 | ||
20 | pub use hir_def::{ | 20 | pub(crate) use hir_def::{ |
21 | body::{ | 21 | body::{Body, BodySourceMap}, |
22 | scope::{ExprScopes, ScopeEntry, ScopeId}, | 22 | expr::{Expr, ExprId, MatchArm, Pat, PatId}, |
23 | Body, BodySourceMap, ExprPtr, ExprSource, PatPtr, PatSource, | 23 | LocalFieldId, VariantId, |
24 | }, | ||
25 | expr::{ | ||
26 | ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, | ||
27 | MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, UnaryOp, | ||
28 | }, | ||
29 | src::HasSource, | ||
30 | LocalFieldId, Lookup, VariantId, | ||
31 | }; | 24 | }; |
32 | 25 | ||
33 | pub(super) struct ExprValidator<'a, 'b: 'a> { | 26 | pub(super) struct ExprValidator<'a, 'b: 'a> { |
diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs index 2da9688ca..6dc862826 100644 --- a/crates/hir_ty/src/diagnostics/unsafe_check.rs +++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs | |||
@@ -59,12 +59,12 @@ impl<'a, 'b> UnsafeValidator<'a, 'b> { | |||
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | pub struct UnsafeExpr { | 62 | pub(crate) struct UnsafeExpr { |
63 | pub expr: ExprId, | 63 | pub(crate) expr: ExprId, |
64 | pub inside_unsafe_block: bool, | 64 | pub(crate) inside_unsafe_block: bool, |
65 | } | 65 | } |
66 | 66 | ||
67 | pub fn unsafe_expressions( | 67 | pub(crate) fn unsafe_expressions( |
68 | db: &dyn HirDatabase, | 68 | db: &dyn HirDatabase, |
69 | infer: &InferenceResult, | 69 | infer: &InferenceResult, |
70 | def: DefWithBodyId, | 70 | def: DefWithBodyId, |
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 644ebd42d..f4c1fa2f2 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -214,9 +214,9 @@ struct InferenceContext<'a> { | |||
214 | 214 | ||
215 | #[derive(Clone, Debug)] | 215 | #[derive(Clone, Debug)] |
216 | struct BreakableContext { | 216 | struct BreakableContext { |
217 | pub may_break: bool, | 217 | may_break: bool, |
218 | pub break_ty: Ty, | 218 | break_ty: Ty, |
219 | pub label: Option<name::Name>, | 219 | label: Option<name::Name>, |
220 | } | 220 | } |
221 | 221 | ||
222 | fn find_breakable<'c>( | 222 | fn find_breakable<'c>( |
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 8ac4cf89a..605951b10 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -107,7 +107,7 @@ impl<'a> InferenceContext<'a> { | |||
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | pub fn callable_sig(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<Ty>, Ty)> { | 110 | pub(crate) fn callable_sig(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<Ty>, Ty)> { |
111 | match ty.callable_sig(self.db) { | 111 | match ty.callable_sig(self.db) { |
112 | Some(sig) => Some((sig.params().to_vec(), sig.ret().clone())), | 112 | Some(sig) => Some((sig.params().to_vec(), sig.ret().clone())), |
113 | None => self.callable_sig_from_fn_trait(ty, num_args), | 113 | None => self.callable_sig_from_fn_trait(ty, num_args), |
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 2e895d911..2406a7361 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -127,7 +127,7 @@ where | |||
127 | } | 127 | } |
128 | 128 | ||
129 | impl<T> Canonicalized<T> { | 129 | impl<T> Canonicalized<T> { |
130 | pub fn decanonicalize_ty(&self, mut ty: Ty) -> Ty { | 130 | pub(super) fn decanonicalize_ty(&self, mut ty: Ty) -> Ty { |
131 | ty.walk_mut_binders( | 131 | ty.walk_mut_binders( |
132 | &mut |ty, binders| { | 132 | &mut |ty, binders| { |
133 | if let &mut Ty::Bound(bound) = ty { | 133 | if let &mut Ty::Bound(bound) = ty { |
@@ -141,7 +141,11 @@ impl<T> Canonicalized<T> { | |||
141 | ty | 141 | ty |
142 | } | 142 | } |
143 | 143 | ||
144 | pub fn apply_solution(&self, ctx: &mut InferenceContext<'_>, solution: Canonical<Substs>) { | 144 | pub(super) fn apply_solution( |
145 | &self, | ||
146 | ctx: &mut InferenceContext<'_>, | ||
147 | solution: Canonical<Substs>, | ||
148 | ) { | ||
145 | // the solution may contain new variables, which we need to convert to new inference vars | 149 | // the solution may contain new variables, which we need to convert to new inference vars |
146 | let new_vars = Substs( | 150 | let new_vars = Substs( |
147 | solution | 151 | solution |
@@ -164,7 +168,7 @@ impl<T> Canonicalized<T> { | |||
164 | } | 168 | } |
165 | } | 169 | } |
166 | 170 | ||
167 | pub fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substs> { | 171 | pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substs> { |
168 | let mut table = InferenceTable::new(); | 172 | let mut table = InferenceTable::new(); |
169 | let vars = Substs( | 173 | let vars = Substs( |
170 | tys.kinds | 174 | tys.kinds |
@@ -199,41 +203,46 @@ pub(crate) struct InferenceTable { | |||
199 | } | 203 | } |
200 | 204 | ||
201 | impl InferenceTable { | 205 | impl InferenceTable { |
202 | pub fn new() -> Self { | 206 | pub(crate) fn new() -> Self { |
203 | InferenceTable { var_unification_table: InPlaceUnificationTable::new() } | 207 | InferenceTable { var_unification_table: InPlaceUnificationTable::new() } |
204 | } | 208 | } |
205 | 209 | ||
206 | pub fn new_type_var(&mut self) -> Ty { | 210 | pub(crate) fn new_type_var(&mut self) -> Ty { |
207 | Ty::Infer(InferTy::TypeVar(self.var_unification_table.new_key(TypeVarValue::Unknown))) | 211 | Ty::Infer(InferTy::TypeVar(self.var_unification_table.new_key(TypeVarValue::Unknown))) |
208 | } | 212 | } |
209 | 213 | ||
210 | pub fn new_integer_var(&mut self) -> Ty { | 214 | pub(crate) fn new_integer_var(&mut self) -> Ty { |
211 | Ty::Infer(InferTy::IntVar(self.var_unification_table.new_key(TypeVarValue::Unknown))) | 215 | Ty::Infer(InferTy::IntVar(self.var_unification_table.new_key(TypeVarValue::Unknown))) |
212 | } | 216 | } |
213 | 217 | ||
214 | pub fn new_float_var(&mut self) -> Ty { | 218 | pub(crate) fn new_float_var(&mut self) -> Ty { |
215 | Ty::Infer(InferTy::FloatVar(self.var_unification_table.new_key(TypeVarValue::Unknown))) | 219 | Ty::Infer(InferTy::FloatVar(self.var_unification_table.new_key(TypeVarValue::Unknown))) |
216 | } | 220 | } |
217 | 221 | ||
218 | pub fn new_maybe_never_type_var(&mut self) -> Ty { | 222 | pub(crate) fn new_maybe_never_type_var(&mut self) -> Ty { |
219 | Ty::Infer(InferTy::MaybeNeverTypeVar( | 223 | Ty::Infer(InferTy::MaybeNeverTypeVar( |
220 | self.var_unification_table.new_key(TypeVarValue::Unknown), | 224 | self.var_unification_table.new_key(TypeVarValue::Unknown), |
221 | )) | 225 | )) |
222 | } | 226 | } |
223 | 227 | ||
224 | pub fn resolve_ty_completely(&mut self, ty: Ty) -> Ty { | 228 | pub(crate) fn resolve_ty_completely(&mut self, ty: Ty) -> Ty { |
225 | self.resolve_ty_completely_inner(&mut Vec::new(), ty) | 229 | self.resolve_ty_completely_inner(&mut Vec::new(), ty) |
226 | } | 230 | } |
227 | 231 | ||
228 | pub fn resolve_ty_as_possible(&mut self, ty: Ty) -> Ty { | 232 | pub(crate) fn resolve_ty_as_possible(&mut self, ty: Ty) -> Ty { |
229 | self.resolve_ty_as_possible_inner(&mut Vec::new(), ty) | 233 | self.resolve_ty_as_possible_inner(&mut Vec::new(), ty) |
230 | } | 234 | } |
231 | 235 | ||
232 | pub fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool { | 236 | pub(crate) fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool { |
233 | self.unify_inner(ty1, ty2, 0) | 237 | self.unify_inner(ty1, ty2, 0) |
234 | } | 238 | } |
235 | 239 | ||
236 | pub fn unify_substs(&mut self, substs1: &Substs, substs2: &Substs, depth: usize) -> bool { | 240 | pub(crate) fn unify_substs( |
241 | &mut self, | ||
242 | substs1: &Substs, | ||
243 | substs2: &Substs, | ||
244 | depth: usize, | ||
245 | ) -> bool { | ||
237 | substs1.0.iter().zip(substs2.0.iter()).all(|(t1, t2)| self.unify_inner(t1, t2, depth)) | 246 | substs1.0.iter().zip(substs2.0.iter()).all(|(t1, t2)| self.unify_inner(t1, t2, depth)) |
238 | } | 247 | } |
239 | 248 | ||
@@ -331,7 +340,7 @@ impl InferenceTable { | |||
331 | 340 | ||
332 | /// If `ty` is a type variable with known type, returns that type; | 341 | /// If `ty` is a type variable with known type, returns that type; |
333 | /// otherwise, return ty. | 342 | /// otherwise, return ty. |
334 | pub fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> { | 343 | pub(crate) fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> { |
335 | let mut ty = Cow::Borrowed(ty); | 344 | let mut ty = Cow::Borrowed(ty); |
336 | // The type variable could resolve to a int/float variable. Hence try | 345 | // The type variable could resolve to a int/float variable. Hence try |
337 | // resolving up to three times; each type of variable shouldn't occur | 346 | // resolving up to three times; each type of variable shouldn't occur |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 768d95eff..5a8c97198 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | //! The type system. We currently use this to infer types for completion, hover | 1 | //! The type system. We currently use this to infer types for completion, hover |
2 | //! information and various assists. | 2 | //! information and various assists. |
3 | |||
4 | #[allow(unused)] | 3 | #[allow(unused)] |
5 | macro_rules! eprintln { | 4 | macro_rules! eprintln { |
6 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; | 5 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; |
@@ -1115,5 +1114,5 @@ pub struct ReturnTypeImplTraits { | |||
1115 | 1114 | ||
1116 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 1115 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
1117 | pub(crate) struct ReturnTypeImplTrait { | 1116 | pub(crate) struct ReturnTypeImplTrait { |
1118 | pub bounds: Binders<Vec<GenericPredicate>>, | 1117 | pub(crate) bounds: Binders<Vec<GenericPredicate>>, |
1119 | } | 1118 | } |
diff --git a/crates/hir_ty/src/test_db.rs b/crates/hir_ty/src/test_db.rs index 15b8435e9..22254b765 100644 --- a/crates/hir_ty/src/test_db.rs +++ b/crates/hir_ty/src/test_db.rs | |||
@@ -21,7 +21,7 @@ use test_utils::extract_annotations; | |||
21 | crate::db::HirDatabaseStorage | 21 | crate::db::HirDatabaseStorage |
22 | )] | 22 | )] |
23 | #[derive(Default)] | 23 | #[derive(Default)] |
24 | pub struct TestDB { | 24 | pub(crate) struct TestDB { |
25 | storage: salsa::Storage<TestDB>, | 25 | storage: salsa::Storage<TestDB>, |
26 | events: Mutex<Option<Vec<salsa::Event>>>, | 26 | events: Mutex<Option<Vec<salsa::Event>>>, |
27 | } | 27 | } |
@@ -113,13 +113,13 @@ impl TestDB { | |||
113 | } | 113 | } |
114 | 114 | ||
115 | impl TestDB { | 115 | impl TestDB { |
116 | pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> { | 116 | pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> { |
117 | *self.events.lock().unwrap() = Some(Vec::new()); | 117 | *self.events.lock().unwrap() = Some(Vec::new()); |
118 | f(); | 118 | f(); |
119 | self.events.lock().unwrap().take().unwrap() | 119 | self.events.lock().unwrap().take().unwrap() |
120 | } | 120 | } |
121 | 121 | ||
122 | pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { | 122 | pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { |
123 | let events = self.log(f); | 123 | let events = self.log(f); |
124 | events | 124 | events |
125 | .into_iter() | 125 | .into_iter() |
diff --git a/crates/hir_ty/src/traits/chalk/tls.rs b/crates/hir_ty/src/traits/chalk/tls.rs index 3c9766550..75b16172e 100644 --- a/crates/hir_ty/src/traits/chalk/tls.rs +++ b/crates/hir_ty/src/traits/chalk/tls.rs | |||
@@ -8,12 +8,12 @@ use super::{from_chalk, Interner, TypeAliasAsAssocType}; | |||
8 | use crate::{db::HirDatabase, CallableDefId}; | 8 | use crate::{db::HirDatabase, CallableDefId}; |
9 | use hir_def::{AdtId, AssocContainerId, Lookup, TypeAliasId}; | 9 | use hir_def::{AdtId, AssocContainerId, Lookup, TypeAliasId}; |
10 | 10 | ||
11 | pub use unsafe_tls::{set_current_program, with_current_program}; | 11 | pub(crate) use unsafe_tls::{set_current_program, with_current_program}; |
12 | 12 | ||
13 | pub struct DebugContext<'a>(&'a dyn HirDatabase); | 13 | pub(crate) struct DebugContext<'a>(&'a dyn HirDatabase); |
14 | 14 | ||
15 | impl DebugContext<'_> { | 15 | impl DebugContext<'_> { |
16 | pub fn debug_struct_id( | 16 | pub(crate) fn debug_struct_id( |
17 | &self, | 17 | &self, |
18 | id: super::AdtId, | 18 | id: super::AdtId, |
19 | f: &mut fmt::Formatter<'_>, | 19 | f: &mut fmt::Formatter<'_>, |
@@ -26,7 +26,7 @@ impl DebugContext<'_> { | |||
26 | write!(f, "{}", name) | 26 | write!(f, "{}", name) |
27 | } | 27 | } |
28 | 28 | ||
29 | pub fn debug_trait_id( | 29 | pub(crate) fn debug_trait_id( |
30 | &self, | 30 | &self, |
31 | id: super::TraitId, | 31 | id: super::TraitId, |
32 | fmt: &mut fmt::Formatter<'_>, | 32 | fmt: &mut fmt::Formatter<'_>, |
@@ -36,7 +36,7 @@ impl DebugContext<'_> { | |||
36 | write!(fmt, "{}", trait_data.name) | 36 | write!(fmt, "{}", trait_data.name) |
37 | } | 37 | } |
38 | 38 | ||
39 | pub fn debug_assoc_type_id( | 39 | pub(crate) fn debug_assoc_type_id( |
40 | &self, | 40 | &self, |
41 | id: super::AssocTypeId, | 41 | id: super::AssocTypeId, |
42 | fmt: &mut fmt::Formatter<'_>, | 42 | fmt: &mut fmt::Formatter<'_>, |
@@ -51,7 +51,7 @@ impl DebugContext<'_> { | |||
51 | write!(fmt, "{}::{}", trait_data.name, type_alias_data.name) | 51 | write!(fmt, "{}::{}", trait_data.name, type_alias_data.name) |
52 | } | 52 | } |
53 | 53 | ||
54 | pub fn debug_opaque_ty_id( | 54 | pub(crate) fn debug_opaque_ty_id( |
55 | &self, | 55 | &self, |
56 | opaque_ty_id: chalk_ir::OpaqueTyId<Interner>, | 56 | opaque_ty_id: chalk_ir::OpaqueTyId<Interner>, |
57 | fmt: &mut fmt::Formatter<'_>, | 57 | fmt: &mut fmt::Formatter<'_>, |
@@ -59,7 +59,7 @@ impl DebugContext<'_> { | |||
59 | fmt.debug_struct("OpaqueTyId").field("index", &opaque_ty_id.0).finish() | 59 | fmt.debug_struct("OpaqueTyId").field("index", &opaque_ty_id.0).finish() |
60 | } | 60 | } |
61 | 61 | ||
62 | pub fn debug_alias( | 62 | pub(crate) fn debug_alias( |
63 | &self, | 63 | &self, |
64 | alias_ty: &AliasTy<Interner>, | 64 | alias_ty: &AliasTy<Interner>, |
65 | fmt: &mut fmt::Formatter<'_>, | 65 | fmt: &mut fmt::Formatter<'_>, |
@@ -70,7 +70,7 @@ impl DebugContext<'_> { | |||
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | pub fn debug_projection_ty( | 73 | pub(crate) fn debug_projection_ty( |
74 | &self, | 74 | &self, |
75 | projection_ty: &chalk_ir::ProjectionTy<Interner>, | 75 | projection_ty: &chalk_ir::ProjectionTy<Interner>, |
76 | fmt: &mut fmt::Formatter<'_>, | 76 | fmt: &mut fmt::Formatter<'_>, |
@@ -95,7 +95,7 @@ impl DebugContext<'_> { | |||
95 | write!(fmt, ">::{}", type_alias_data.name) | 95 | write!(fmt, ">::{}", type_alias_data.name) |
96 | } | 96 | } |
97 | 97 | ||
98 | pub fn debug_opaque_ty( | 98 | pub(crate) fn debug_opaque_ty( |
99 | &self, | 99 | &self, |
100 | opaque_ty: &chalk_ir::OpaqueTy<Interner>, | 100 | opaque_ty: &chalk_ir::OpaqueTy<Interner>, |
101 | fmt: &mut fmt::Formatter<'_>, | 101 | fmt: &mut fmt::Formatter<'_>, |
@@ -103,7 +103,7 @@ impl DebugContext<'_> { | |||
103 | write!(fmt, "{:?}", opaque_ty.opaque_ty_id) | 103 | write!(fmt, "{:?}", opaque_ty.opaque_ty_id) |
104 | } | 104 | } |
105 | 105 | ||
106 | pub fn debug_ty( | 106 | pub(crate) fn debug_ty( |
107 | &self, | 107 | &self, |
108 | ty: &chalk_ir::Ty<Interner>, | 108 | ty: &chalk_ir::Ty<Interner>, |
109 | fmt: &mut fmt::Formatter<'_>, | 109 | fmt: &mut fmt::Formatter<'_>, |
@@ -111,7 +111,7 @@ impl DebugContext<'_> { | |||
111 | write!(fmt, "{:?}", ty.data(&Interner)) | 111 | write!(fmt, "{:?}", ty.data(&Interner)) |
112 | } | 112 | } |
113 | 113 | ||
114 | pub fn debug_lifetime( | 114 | pub(crate) fn debug_lifetime( |
115 | &self, | 115 | &self, |
116 | lifetime: &Lifetime<Interner>, | 116 | lifetime: &Lifetime<Interner>, |
117 | fmt: &mut fmt::Formatter<'_>, | 117 | fmt: &mut fmt::Formatter<'_>, |
@@ -119,7 +119,7 @@ impl DebugContext<'_> { | |||
119 | write!(fmt, "{:?}", lifetime.data(&Interner)) | 119 | write!(fmt, "{:?}", lifetime.data(&Interner)) |
120 | } | 120 | } |
121 | 121 | ||
122 | pub fn debug_generic_arg( | 122 | pub(crate) fn debug_generic_arg( |
123 | &self, | 123 | &self, |
124 | parameter: &GenericArg<Interner>, | 124 | parameter: &GenericArg<Interner>, |
125 | fmt: &mut fmt::Formatter<'_>, | 125 | fmt: &mut fmt::Formatter<'_>, |
@@ -127,7 +127,7 @@ impl DebugContext<'_> { | |||
127 | write!(fmt, "{:?}", parameter.data(&Interner).inner_debug()) | 127 | write!(fmt, "{:?}", parameter.data(&Interner).inner_debug()) |
128 | } | 128 | } |
129 | 129 | ||
130 | pub fn debug_goal( | 130 | pub(crate) fn debug_goal( |
131 | &self, | 131 | &self, |
132 | goal: &Goal<Interner>, | 132 | goal: &Goal<Interner>, |
133 | fmt: &mut fmt::Formatter<'_>, | 133 | fmt: &mut fmt::Formatter<'_>, |
@@ -136,7 +136,7 @@ impl DebugContext<'_> { | |||
136 | write!(fmt, "{:?}", goal_data) | 136 | write!(fmt, "{:?}", goal_data) |
137 | } | 137 | } |
138 | 138 | ||
139 | pub fn debug_goals( | 139 | pub(crate) fn debug_goals( |
140 | &self, | 140 | &self, |
141 | goals: &Goals<Interner>, | 141 | goals: &Goals<Interner>, |
142 | fmt: &mut fmt::Formatter<'_>, | 142 | fmt: &mut fmt::Formatter<'_>, |
@@ -144,7 +144,7 @@ impl DebugContext<'_> { | |||
144 | write!(fmt, "{:?}", goals.debug(&Interner)) | 144 | write!(fmt, "{:?}", goals.debug(&Interner)) |
145 | } | 145 | } |
146 | 146 | ||
147 | pub fn debug_program_clause_implication( | 147 | pub(crate) fn debug_program_clause_implication( |
148 | &self, | 148 | &self, |
149 | pci: &ProgramClauseImplication<Interner>, | 149 | pci: &ProgramClauseImplication<Interner>, |
150 | fmt: &mut fmt::Formatter<'_>, | 150 | fmt: &mut fmt::Formatter<'_>, |
@@ -152,7 +152,7 @@ impl DebugContext<'_> { | |||
152 | write!(fmt, "{:?}", pci.debug(&Interner)) | 152 | write!(fmt, "{:?}", pci.debug(&Interner)) |
153 | } | 153 | } |
154 | 154 | ||
155 | pub fn debug_substitution( | 155 | pub(crate) fn debug_substitution( |
156 | &self, | 156 | &self, |
157 | substitution: &chalk_ir::Substitution<Interner>, | 157 | substitution: &chalk_ir::Substitution<Interner>, |
158 | fmt: &mut fmt::Formatter<'_>, | 158 | fmt: &mut fmt::Formatter<'_>, |
@@ -160,7 +160,7 @@ impl DebugContext<'_> { | |||
160 | write!(fmt, "{:?}", substitution.debug(&Interner)) | 160 | write!(fmt, "{:?}", substitution.debug(&Interner)) |
161 | } | 161 | } |
162 | 162 | ||
163 | pub fn debug_separator_trait_ref( | 163 | pub(crate) fn debug_separator_trait_ref( |
164 | &self, | 164 | &self, |
165 | separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>, | 165 | separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>, |
166 | fmt: &mut fmt::Formatter<'_>, | 166 | fmt: &mut fmt::Formatter<'_>, |
@@ -168,7 +168,7 @@ impl DebugContext<'_> { | |||
168 | write!(fmt, "{:?}", separator_trait_ref.debug(&Interner)) | 168 | write!(fmt, "{:?}", separator_trait_ref.debug(&Interner)) |
169 | } | 169 | } |
170 | 170 | ||
171 | pub fn debug_fn_def_id( | 171 | pub(crate) fn debug_fn_def_id( |
172 | &self, | 172 | &self, |
173 | fn_def_id: chalk_ir::FnDefId<Interner>, | 173 | fn_def_id: chalk_ir::FnDefId<Interner>, |
174 | fmt: &mut fmt::Formatter<'_>, | 174 | fmt: &mut fmt::Formatter<'_>, |
@@ -190,7 +190,7 @@ impl DebugContext<'_> { | |||
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | pub fn debug_const( | 193 | pub(crate) fn debug_const( |
194 | &self, | 194 | &self, |
195 | _constant: &chalk_ir::Const<Interner>, | 195 | _constant: &chalk_ir::Const<Interner>, |
196 | fmt: &mut fmt::Formatter<'_>, | 196 | fmt: &mut fmt::Formatter<'_>, |
@@ -198,42 +198,42 @@ impl DebugContext<'_> { | |||
198 | write!(fmt, "const") | 198 | write!(fmt, "const") |
199 | } | 199 | } |
200 | 200 | ||
201 | pub fn debug_variable_kinds( | 201 | pub(crate) fn debug_variable_kinds( |
202 | &self, | 202 | &self, |
203 | variable_kinds: &chalk_ir::VariableKinds<Interner>, | 203 | variable_kinds: &chalk_ir::VariableKinds<Interner>, |
204 | fmt: &mut fmt::Formatter<'_>, | 204 | fmt: &mut fmt::Formatter<'_>, |
205 | ) -> fmt::Result { | 205 | ) -> fmt::Result { |
206 | write!(fmt, "{:?}", variable_kinds.as_slice(&Interner)) | 206 | write!(fmt, "{:?}", variable_kinds.as_slice(&Interner)) |
207 | } | 207 | } |
208 | pub fn debug_variable_kinds_with_angles( | 208 | pub(crate) fn debug_variable_kinds_with_angles( |
209 | &self, | 209 | &self, |
210 | variable_kinds: &chalk_ir::VariableKinds<Interner>, | 210 | variable_kinds: &chalk_ir::VariableKinds<Interner>, |
211 | fmt: &mut fmt::Formatter<'_>, | 211 | fmt: &mut fmt::Formatter<'_>, |
212 | ) -> fmt::Result { | 212 | ) -> fmt::Result { |
213 | write!(fmt, "{:?}", variable_kinds.inner_debug(&Interner)) | 213 | write!(fmt, "{:?}", variable_kinds.inner_debug(&Interner)) |
214 | } | 214 | } |
215 | pub fn debug_canonical_var_kinds( | 215 | pub(crate) fn debug_canonical_var_kinds( |
216 | &self, | 216 | &self, |
217 | canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Interner>, | 217 | canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Interner>, |
218 | fmt: &mut fmt::Formatter<'_>, | 218 | fmt: &mut fmt::Formatter<'_>, |
219 | ) -> fmt::Result { | 219 | ) -> fmt::Result { |
220 | write!(fmt, "{:?}", canonical_var_kinds.as_slice(&Interner)) | 220 | write!(fmt, "{:?}", canonical_var_kinds.as_slice(&Interner)) |
221 | } | 221 | } |
222 | pub fn debug_program_clause( | 222 | pub(crate) fn debug_program_clause( |
223 | &self, | 223 | &self, |
224 | clause: &chalk_ir::ProgramClause<Interner>, | 224 | clause: &chalk_ir::ProgramClause<Interner>, |
225 | fmt: &mut fmt::Formatter<'_>, | 225 | fmt: &mut fmt::Formatter<'_>, |
226 | ) -> fmt::Result { | 226 | ) -> fmt::Result { |
227 | write!(fmt, "{:?}", clause.data(&Interner)) | 227 | write!(fmt, "{:?}", clause.data(&Interner)) |
228 | } | 228 | } |
229 | pub fn debug_program_clauses( | 229 | pub(crate) fn debug_program_clauses( |
230 | &self, | 230 | &self, |
231 | clauses: &chalk_ir::ProgramClauses<Interner>, | 231 | clauses: &chalk_ir::ProgramClauses<Interner>, |
232 | fmt: &mut fmt::Formatter<'_>, | 232 | fmt: &mut fmt::Formatter<'_>, |
233 | ) -> fmt::Result { | 233 | ) -> fmt::Result { |
234 | write!(fmt, "{:?}", clauses.as_slice(&Interner)) | 234 | write!(fmt, "{:?}", clauses.as_slice(&Interner)) |
235 | } | 235 | } |
236 | pub fn debug_quantified_where_clauses( | 236 | pub(crate) fn debug_quantified_where_clauses( |
237 | &self, | 237 | &self, |
238 | clauses: &chalk_ir::QuantifiedWhereClauses<Interner>, | 238 | clauses: &chalk_ir::QuantifiedWhereClauses<Interner>, |
239 | fmt: &mut fmt::Formatter<'_>, | 239 | fmt: &mut fmt::Formatter<'_>, |
@@ -249,7 +249,7 @@ mod unsafe_tls { | |||
249 | 249 | ||
250 | scoped_thread_local!(static PROGRAM: DebugContext); | 250 | scoped_thread_local!(static PROGRAM: DebugContext); |
251 | 251 | ||
252 | pub fn with_current_program<R>( | 252 | pub(crate) fn with_current_program<R>( |
253 | op: impl for<'a> FnOnce(Option<&'a DebugContext<'a>>) -> R, | 253 | op: impl for<'a> FnOnce(Option<&'a DebugContext<'a>>) -> R, |
254 | ) -> R { | 254 | ) -> R { |
255 | if PROGRAM.is_set() { | 255 | if PROGRAM.is_set() { |
@@ -259,7 +259,7 @@ mod unsafe_tls { | |||
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | pub fn set_current_program<OP, R>(p: &dyn HirDatabase, op: OP) -> R | 262 | pub(crate) fn set_current_program<OP, R>(p: &dyn HirDatabase, op: OP) -> R |
263 | where | 263 | where |
264 | OP: FnOnce() -> R, | 264 | OP: FnOnce() -> R, |
265 | { | 265 | { |
diff --git a/crates/mbe/src/mbe_expander/matcher.rs b/crates/mbe/src/mbe_expander/matcher.rs index b698b9832..39a8eefbd 100644 --- a/crates/mbe/src/mbe_expander/matcher.rs +++ b/crates/mbe/src/mbe_expander/matcher.rs | |||
@@ -61,16 +61,16 @@ macro_rules! err { | |||
61 | 61 | ||
62 | #[derive(Debug, Default)] | 62 | #[derive(Debug, Default)] |
63 | pub(super) struct Match { | 63 | pub(super) struct Match { |
64 | pub bindings: Bindings, | 64 | pub(super) bindings: Bindings, |
65 | /// We currently just keep the first error and count the rest to compare matches. | 65 | /// We currently just keep the first error and count the rest to compare matches. |
66 | pub err: Option<ExpandError>, | 66 | pub(super) err: Option<ExpandError>, |
67 | pub err_count: usize, | 67 | pub(super) err_count: usize, |
68 | /// How many top-level token trees were left to match. | 68 | /// How many top-level token trees were left to match. |
69 | pub unmatched_tts: usize, | 69 | pub(super) unmatched_tts: usize, |
70 | } | 70 | } |
71 | 71 | ||
72 | impl Match { | 72 | impl Match { |
73 | pub fn add_err(&mut self, err: ExpandError) { | 73 | pub(super) fn add_err(&mut self, err: ExpandError) { |
74 | let prev_err = self.err.take(); | 74 | let prev_err = self.err.take(); |
75 | self.err = prev_err.or(Some(err)); | 75 | self.err = prev_err.or(Some(err)); |
76 | self.err_count += 1; | 76 | self.err_count += 1; |
diff --git a/crates/mbe/src/subtree_source.rs b/crates/mbe/src/subtree_source.rs index 396ce8b16..38237cdcf 100644 --- a/crates/mbe/src/subtree_source.rs +++ b/crates/mbe/src/subtree_source.rs | |||
@@ -7,9 +7,9 @@ use tt::buffer::{Cursor, TokenBuffer}; | |||
7 | 7 | ||
8 | #[derive(Debug, Clone, Eq, PartialEq)] | 8 | #[derive(Debug, Clone, Eq, PartialEq)] |
9 | struct TtToken { | 9 | struct TtToken { |
10 | pub kind: SyntaxKind, | 10 | kind: SyntaxKind, |
11 | pub is_joint_to_next: bool, | 11 | is_joint_to_next: bool, |
12 | pub text: SmolStr, | 12 | text: SmolStr, |
13 | } | 13 | } |
14 | 14 | ||
15 | pub(crate) struct SubtreeTokenSource<'a> { | 15 | pub(crate) struct SubtreeTokenSource<'a> { |
@@ -30,7 +30,7 @@ impl<'a> SubtreeTokenSource<'a> { | |||
30 | } | 30 | } |
31 | 31 | ||
32 | impl<'a> SubtreeTokenSource<'a> { | 32 | impl<'a> SubtreeTokenSource<'a> { |
33 | pub fn new(buffer: &'a TokenBuffer) -> SubtreeTokenSource<'a> { | 33 | pub(crate) fn new(buffer: &'a TokenBuffer) -> SubtreeTokenSource<'a> { |
34 | let cursor = buffer.begin(); | 34 | let cursor = buffer.begin(); |
35 | 35 | ||
36 | let mut res = SubtreeTokenSource { | 36 | let mut res = SubtreeTokenSource { |
diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs index 51ffcaa78..907cb3db7 100644 --- a/crates/proc_macro_api/src/process.rs +++ b/crates/proc_macro_api/src/process.rs | |||
@@ -30,7 +30,7 @@ pub(crate) struct ProcMacroProcessThread { | |||
30 | } | 30 | } |
31 | 31 | ||
32 | impl ProcMacroProcessSrv { | 32 | impl ProcMacroProcessSrv { |
33 | pub fn run( | 33 | pub(crate) fn run( |
34 | process_path: PathBuf, | 34 | process_path: PathBuf, |
35 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, | 35 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, |
36 | ) -> io::Result<(ProcMacroProcessThread, ProcMacroProcessSrv)> { | 36 | ) -> io::Result<(ProcMacroProcessThread, ProcMacroProcessSrv)> { |
@@ -48,7 +48,7 @@ impl ProcMacroProcessSrv { | |||
48 | Ok((thread, srv)) | 48 | Ok((thread, srv)) |
49 | } | 49 | } |
50 | 50 | ||
51 | pub fn find_proc_macros( | 51 | pub(crate) fn find_proc_macros( |
52 | &self, | 52 | &self, |
53 | dylib_path: &Path, | 53 | dylib_path: &Path, |
54 | ) -> Result<Vec<(String, ProcMacroKind)>, tt::ExpansionError> { | 54 | ) -> Result<Vec<(String, ProcMacroKind)>, tt::ExpansionError> { |
@@ -58,7 +58,7 @@ impl ProcMacroProcessSrv { | |||
58 | Ok(result.macros) | 58 | Ok(result.macros) |
59 | } | 59 | } |
60 | 60 | ||
61 | pub fn custom_derive( | 61 | pub(crate) fn custom_derive( |
62 | &self, | 62 | &self, |
63 | dylib_path: &Path, | 63 | dylib_path: &Path, |
64 | subtree: &Subtree, | 64 | subtree: &Subtree, |
@@ -75,7 +75,7 @@ impl ProcMacroProcessSrv { | |||
75 | Ok(result.expansion) | 75 | Ok(result.expansion) |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError> | 78 | pub(crate) fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError> |
79 | where | 79 | where |
80 | R: TryFrom<Response, Error = &'static str>, | 80 | R: TryFrom<Response, Error = &'static str>, |
81 | { | 81 | { |
diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs index 47624163e..203109ca4 100644 --- a/crates/proc_macro_api/src/rpc.rs +++ b/crates/proc_macro_api/src/rpc.rs | |||
@@ -75,18 +75,18 @@ struct TokenIdDef(u32); | |||
75 | #[serde(remote = "Delimiter")] | 75 | #[serde(remote = "Delimiter")] |
76 | struct DelimiterDef { | 76 | struct DelimiterDef { |
77 | #[serde(with = "TokenIdDef")] | 77 | #[serde(with = "TokenIdDef")] |
78 | pub id: TokenId, | 78 | id: TokenId, |
79 | #[serde(with = "DelimiterKindDef")] | 79 | #[serde(with = "DelimiterKindDef")] |
80 | pub kind: DelimiterKind, | 80 | kind: DelimiterKind, |
81 | } | 81 | } |
82 | 82 | ||
83 | #[derive(Serialize, Deserialize)] | 83 | #[derive(Serialize, Deserialize)] |
84 | #[serde(remote = "Subtree")] | 84 | #[serde(remote = "Subtree")] |
85 | struct SubtreeDef { | 85 | struct SubtreeDef { |
86 | #[serde(default, with = "opt_delimiter_def")] | 86 | #[serde(default, with = "opt_delimiter_def")] |
87 | pub delimiter: Option<Delimiter>, | 87 | delimiter: Option<Delimiter>, |
88 | #[serde(with = "vec_token_tree")] | 88 | #[serde(with = "vec_token_tree")] |
89 | pub token_trees: Vec<TokenTree>, | 89 | token_trees: Vec<TokenTree>, |
90 | } | 90 | } |
91 | 91 | ||
92 | #[derive(Serialize, Deserialize)] | 92 | #[derive(Serialize, Deserialize)] |
@@ -112,19 +112,19 @@ enum LeafDef { | |||
112 | #[derive(Serialize, Deserialize)] | 112 | #[derive(Serialize, Deserialize)] |
113 | #[serde(remote = "Literal")] | 113 | #[serde(remote = "Literal")] |
114 | struct LiteralDef { | 114 | struct LiteralDef { |
115 | pub text: SmolStr, | 115 | text: SmolStr, |
116 | #[serde(with = "TokenIdDef")] | 116 | #[serde(with = "TokenIdDef")] |
117 | pub id: TokenId, | 117 | id: TokenId, |
118 | } | 118 | } |
119 | 119 | ||
120 | #[derive(Serialize, Deserialize)] | 120 | #[derive(Serialize, Deserialize)] |
121 | #[serde(remote = "Punct")] | 121 | #[serde(remote = "Punct")] |
122 | struct PunctDef { | 122 | struct PunctDef { |
123 | pub char: char, | 123 | char: char, |
124 | #[serde(with = "SpacingDef")] | 124 | #[serde(with = "SpacingDef")] |
125 | pub spacing: Spacing, | 125 | spacing: Spacing, |
126 | #[serde(with = "TokenIdDef")] | 126 | #[serde(with = "TokenIdDef")] |
127 | pub id: TokenId, | 127 | id: TokenId, |
128 | } | 128 | } |
129 | 129 | ||
130 | #[derive(Serialize, Deserialize)] | 130 | #[derive(Serialize, Deserialize)] |
@@ -137,16 +137,16 @@ enum SpacingDef { | |||
137 | #[derive(Serialize, Deserialize)] | 137 | #[derive(Serialize, Deserialize)] |
138 | #[serde(remote = "Ident")] | 138 | #[serde(remote = "Ident")] |
139 | struct IdentDef { | 139 | struct IdentDef { |
140 | pub text: SmolStr, | 140 | text: SmolStr, |
141 | #[serde(with = "TokenIdDef")] | 141 | #[serde(with = "TokenIdDef")] |
142 | pub id: TokenId, | 142 | id: TokenId, |
143 | } | 143 | } |
144 | 144 | ||
145 | mod opt_delimiter_def { | 145 | mod opt_delimiter_def { |
146 | use super::{Delimiter, DelimiterDef}; | 146 | use super::{Delimiter, DelimiterDef}; |
147 | use serde::{Deserialize, Deserializer, Serialize, Serializer}; | 147 | use serde::{Deserialize, Deserializer, Serialize, Serializer}; |
148 | 148 | ||
149 | pub fn serialize<S>(value: &Option<Delimiter>, serializer: S) -> Result<S::Ok, S::Error> | 149 | pub(super) fn serialize<S>(value: &Option<Delimiter>, serializer: S) -> Result<S::Ok, S::Error> |
150 | where | 150 | where |
151 | S: Serializer, | 151 | S: Serializer, |
152 | { | 152 | { |
@@ -155,7 +155,7 @@ mod opt_delimiter_def { | |||
155 | value.as_ref().map(Helper).serialize(serializer) | 155 | value.as_ref().map(Helper).serialize(serializer) |
156 | } | 156 | } |
157 | 157 | ||
158 | pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Delimiter>, D::Error> | 158 | pub(super) fn deserialize<'de, D>(deserializer: D) -> Result<Option<Delimiter>, D::Error> |
159 | where | 159 | where |
160 | D: Deserializer<'de>, | 160 | D: Deserializer<'de>, |
161 | { | 161 | { |
@@ -170,7 +170,7 @@ mod opt_subtree_def { | |||
170 | use super::{Subtree, SubtreeDef}; | 170 | use super::{Subtree, SubtreeDef}; |
171 | use serde::{Deserialize, Deserializer, Serialize, Serializer}; | 171 | use serde::{Deserialize, Deserializer, Serialize, Serializer}; |
172 | 172 | ||
173 | pub fn serialize<S>(value: &Option<Subtree>, serializer: S) -> Result<S::Ok, S::Error> | 173 | pub(super) fn serialize<S>(value: &Option<Subtree>, serializer: S) -> Result<S::Ok, S::Error> |
174 | where | 174 | where |
175 | S: Serializer, | 175 | S: Serializer, |
176 | { | 176 | { |
@@ -179,7 +179,7 @@ mod opt_subtree_def { | |||
179 | value.as_ref().map(Helper).serialize(serializer) | 179 | value.as_ref().map(Helper).serialize(serializer) |
180 | } | 180 | } |
181 | 181 | ||
182 | pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Subtree>, D::Error> | 182 | pub(super) fn deserialize<'de, D>(deserializer: D) -> Result<Option<Subtree>, D::Error> |
183 | where | 183 | where |
184 | D: Deserializer<'de>, | 184 | D: Deserializer<'de>, |
185 | { | 185 | { |
@@ -194,7 +194,7 @@ mod vec_token_tree { | |||
194 | use super::{TokenTree, TokenTreeDef}; | 194 | use super::{TokenTree, TokenTreeDef}; |
195 | use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; | 195 | use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; |
196 | 196 | ||
197 | pub fn serialize<S>(value: &Vec<TokenTree>, serializer: S) -> Result<S::Ok, S::Error> | 197 | pub(super) fn serialize<S>(value: &Vec<TokenTree>, serializer: S) -> Result<S::Ok, S::Error> |
198 | where | 198 | where |
199 | S: Serializer, | 199 | S: Serializer, |
200 | { | 200 | { |
@@ -209,7 +209,7 @@ mod vec_token_tree { | |||
209 | seq.end() | 209 | seq.end() |
210 | } | 210 | } |
211 | 211 | ||
212 | pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<TokenTree>, D::Error> | 212 | pub(super) fn deserialize<'de, D>(deserializer: D) -> Result<Vec<TokenTree>, D::Error> |
213 | where | 213 | where |
214 | D: Deserializer<'de>, | 214 | D: Deserializer<'de>, |
215 | { | 215 | { |
diff --git a/crates/proc_macro_srv/src/lib.rs b/crates/proc_macro_srv/src/lib.rs index 7e4e4ad50..6e890f8e2 100644 --- a/crates/proc_macro_srv/src/lib.rs +++ b/crates/proc_macro_srv/src/lib.rs | |||
@@ -9,6 +9,7 @@ | |||
9 | //! RA than `proc-macro2` token stream. | 9 | //! RA than `proc-macro2` token stream. |
10 | //! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable` | 10 | //! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable` |
11 | //! rustc rather than `unstable`. (Although in general ABI compatibility is still an issue)… | 11 | //! rustc rather than `unstable`. (Although in general ABI compatibility is still an issue)… |
12 | #![allow(unreachable_pub)] | ||
12 | 13 | ||
13 | #[allow(dead_code)] | 14 | #[allow(dead_code)] |
14 | #[doc(hidden)] | 15 | #[doc(hidden)] |
diff --git a/crates/profile/src/hprof.rs b/crates/profile/src/hprof.rs index 934cc8e37..8957ea016 100644 --- a/crates/profile/src/hprof.rs +++ b/crates/profile/src/hprof.rs | |||
@@ -27,7 +27,7 @@ pub fn init_from(spec: &str) { | |||
27 | filter.install(); | 27 | filter.install(); |
28 | } | 28 | } |
29 | 29 | ||
30 | pub type Label = &'static str; | 30 | type Label = &'static str; |
31 | 31 | ||
32 | /// This function starts a profiling scope in the current execution stack with a given description. | 32 | /// This function starts a profiling scope in the current execution stack with a given description. |
33 | /// It returns a `Profile` struct that measures elapsed time between this method invocation and `Profile` struct drop. | 33 | /// It returns a `Profile` struct that measures elapsed time between this method invocation and `Profile` struct drop. |
@@ -173,7 +173,7 @@ impl ProfileStack { | |||
173 | true | 173 | true |
174 | } | 174 | } |
175 | 175 | ||
176 | pub fn pop(&mut self, label: Label, detail: Option<String>) { | 176 | fn pop(&mut self, label: Label, detail: Option<String>) { |
177 | let start = self.starts.pop().unwrap(); | 177 | let start = self.starts.pop().unwrap(); |
178 | let duration = start.elapsed(); | 178 | let duration = start.elapsed(); |
179 | self.messages.finish(Message { duration, label, detail }); | 179 | self.messages.finish(Message { duration, label, detail }); |
diff --git a/crates/profile/src/tree.rs b/crates/profile/src/tree.rs index 096f58511..3fac1f36c 100644 --- a/crates/profile/src/tree.rs +++ b/crates/profile/src/tree.rs | |||
@@ -4,15 +4,15 @@ use std::ops; | |||
4 | use arena::Arena; | 4 | use arena::Arena; |
5 | 5 | ||
6 | #[derive(Default)] | 6 | #[derive(Default)] |
7 | pub struct Tree<T> { | 7 | pub(crate) struct Tree<T> { |
8 | nodes: Arena<Node<T>>, | 8 | nodes: Arena<Node<T>>, |
9 | current_path: Vec<(Idx<T>, Option<Idx<T>>)>, | 9 | current_path: Vec<(Idx<T>, Option<Idx<T>>)>, |
10 | } | 10 | } |
11 | 11 | ||
12 | pub type Idx<T> = arena::Idx<Node<T>>; | 12 | pub(crate) type Idx<T> = arena::Idx<Node<T>>; |
13 | 13 | ||
14 | impl<T> Tree<T> { | 14 | impl<T> Tree<T> { |
15 | pub fn start(&mut self) | 15 | pub(crate) fn start(&mut self) |
16 | where | 16 | where |
17 | T: Default, | 17 | T: Default, |
18 | { | 18 | { |
@@ -30,19 +30,19 @@ impl<T> Tree<T> { | |||
30 | self.current_path.push((me, None)); | 30 | self.current_path.push((me, None)); |
31 | } | 31 | } |
32 | 32 | ||
33 | pub fn finish(&mut self, data: T) { | 33 | pub(crate) fn finish(&mut self, data: T) { |
34 | let (me, _last_child) = self.current_path.pop().unwrap(); | 34 | let (me, _last_child) = self.current_path.pop().unwrap(); |
35 | self.nodes[me].data = data; | 35 | self.nodes[me].data = data; |
36 | } | 36 | } |
37 | 37 | ||
38 | pub fn root(&self) -> Option<Idx<T>> { | 38 | pub(crate) fn root(&self) -> Option<Idx<T>> { |
39 | self.nodes.iter().next().map(|(idx, _)| idx) | 39 | self.nodes.iter().next().map(|(idx, _)| idx) |
40 | } | 40 | } |
41 | 41 | ||
42 | pub fn children(&self, idx: Idx<T>) -> impl Iterator<Item = Idx<T>> + '_ { | 42 | pub(crate) fn children(&self, idx: Idx<T>) -> impl Iterator<Item = Idx<T>> + '_ { |
43 | NodeIter { nodes: &self.nodes, next: self.nodes[idx].first_child } | 43 | NodeIter { nodes: &self.nodes, next: self.nodes[idx].first_child } |
44 | } | 44 | } |
45 | pub fn clear(&mut self) { | 45 | pub(crate) fn clear(&mut self) { |
46 | self.nodes.clear(); | 46 | self.nodes.clear(); |
47 | self.current_path.clear(); | 47 | self.current_path.clear(); |
48 | } | 48 | } |
@@ -55,7 +55,7 @@ impl<T> ops::Index<Idx<T>> for Tree<T> { | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | pub struct Node<T> { | 58 | pub(crate) struct Node<T> { |
59 | data: T, | 59 | data: T, |
60 | first_child: Option<Idx<T>>, | 60 | first_child: Option<Idx<T>>, |
61 | next_sibling: Option<Idx<T>>, | 61 | next_sibling: Option<Idx<T>>, |
diff --git a/crates/syntax/src/ast.rs b/crates/syntax/src/ast.rs index d536bb1e7..8a0e3d27b 100644 --- a/crates/syntax/src/ast.rs +++ b/crates/syntax/src/ast.rs | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | 17 | ||
18 | pub use self::{ | 18 | pub use self::{ |
19 | expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, | 19 | expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, |
20 | generated::*, | 20 | generated::{nodes::*, tokens::*}, |
21 | node_ext::{ | 21 | node_ext::{ |
22 | AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, | 22 | AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, |
23 | StructKind, TypeBoundKind, VisibilityKind, | 23 | StructKind, TypeBoundKind, VisibilityKind, |
diff --git a/crates/syntax/src/ast/generated.rs b/crates/syntax/src/ast/generated.rs index 4a6f41ee7..843b43cf0 100644 --- a/crates/syntax/src/ast/generated.rs +++ b/crates/syntax/src/ast/generated.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | //! This file is actually hand-written, but the submodules are indeed generated. | 1 | //! This file is actually hand-written, but the submodules are indeed generated. |
2 | #[rustfmt::skip] | 2 | #[rustfmt::skip] |
3 | mod nodes; | 3 | pub(crate) mod nodes; |
4 | #[rustfmt::skip] | 4 | #[rustfmt::skip] |
5 | mod tokens; | 5 | pub(crate) mod tokens; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | AstNode, | 8 | AstNode, |
@@ -10,7 +10,7 @@ use crate::{ | |||
10 | SyntaxNode, | 10 | SyntaxNode, |
11 | }; | 11 | }; |
12 | 12 | ||
13 | pub use {nodes::*, tokens::*}; | 13 | pub(crate) use nodes::*; |
14 | 14 | ||
15 | // Stmt is the only nested enum, so it's easier to just hand-write it | 15 | // Stmt is the only nested enum, so it's easier to just hand-write it |
16 | impl AstNode for Stmt { | 16 | impl AstNode for Stmt { |
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index 849a1cdd6..e753b11bb 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs | |||
@@ -46,16 +46,19 @@ use text_edit::Indel; | |||
46 | pub use crate::{ | 46 | pub use crate::{ |
47 | algo::InsertPosition, | 47 | algo::InsertPosition, |
48 | ast::{AstNode, AstToken}, | 48 | ast::{AstNode, AstToken}, |
49 | parsing::{lex_single_syntax_kind, lex_single_valid_syntax_kind, tokenize, Token}, | 49 | parsing::lexer::{lex_single_syntax_kind, lex_single_valid_syntax_kind, tokenize, Token}, |
50 | ptr::{AstPtr, SyntaxNodePtr}, | 50 | ptr::{AstPtr, SyntaxNodePtr}, |
51 | syntax_error::SyntaxError, | 51 | syntax_error::SyntaxError, |
52 | syntax_node::{ | 52 | syntax_node::{ |
53 | Direction, GreenNode, NodeOrToken, SyntaxElement, SyntaxElementChildren, SyntaxNode, | 53 | SyntaxElement, SyntaxElementChildren, SyntaxNode, SyntaxNodeChildren, SyntaxToken, |
54 | SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, | 54 | SyntaxTreeBuilder, |
55 | }, | 55 | }, |
56 | }; | 56 | }; |
57 | pub use parser::{SyntaxKind, T}; | 57 | pub use parser::{SyntaxKind, T}; |
58 | pub use rowan::{SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset, WalkEvent}; | 58 | pub use rowan::{ |
59 | Direction, GreenNode, NodeOrToken, SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset, | ||
60 | WalkEvent, | ||
61 | }; | ||
59 | 62 | ||
60 | /// `Parse` is the result of the parsing: a syntax tree and a collection of | 63 | /// `Parse` is the result of the parsing: a syntax tree and a collection of |
61 | /// errors. | 64 | /// errors. |
diff --git a/crates/syntax/src/parsing.rs b/crates/syntax/src/parsing.rs index 68a39eb21..333bde54a 100644 --- a/crates/syntax/src/parsing.rs +++ b/crates/syntax/src/parsing.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Lexing, bridging to parser (which does the actual parsing) and | 1 | //! Lexing, bridging to parser (which does the actual parsing) and |
2 | //! incremental reparsing. | 2 | //! incremental reparsing. |
3 | 3 | ||
4 | mod lexer; | 4 | pub(crate) mod lexer; |
5 | mod text_token_source; | 5 | mod text_token_source; |
6 | mod text_tree_sink; | 6 | mod text_tree_sink; |
7 | mod reparsing; | 7 | mod reparsing; |
@@ -10,7 +10,7 @@ use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode}; | |||
10 | use text_token_source::TextTokenSource; | 10 | use text_token_source::TextTokenSource; |
11 | use text_tree_sink::TextTreeSink; | 11 | use text_tree_sink::TextTreeSink; |
12 | 12 | ||
13 | pub use lexer::*; | 13 | pub(crate) use lexer::*; |
14 | 14 | ||
15 | pub(crate) use self::reparsing::incremental_reparse; | 15 | pub(crate) use self::reparsing::incremental_reparse; |
16 | use parser::SyntaxKind; | 16 | use parser::SyntaxKind; |
diff --git a/crates/syntax/src/parsing/text_token_source.rs b/crates/syntax/src/parsing/text_token_source.rs index df866dc2b..0614194a5 100644 --- a/crates/syntax/src/parsing/text_token_source.rs +++ b/crates/syntax/src/parsing/text_token_source.rs | |||
@@ -65,7 +65,7 @@ fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> parser::Tok | |||
65 | 65 | ||
66 | impl<'t> TextTokenSource<'t> { | 66 | impl<'t> TextTokenSource<'t> { |
67 | /// Generate input from tokens(expect comment and whitespace). | 67 | /// Generate input from tokens(expect comment and whitespace). |
68 | pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> TextTokenSource<'t> { | 68 | pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> TextTokenSource<'t> { |
69 | let token_offset_pairs: Vec<_> = raw_tokens | 69 | let token_offset_pairs: Vec<_> = raw_tokens |
70 | .iter() | 70 | .iter() |
71 | .filter_map({ | 71 | .filter_map({ |
diff --git a/crates/syntax/src/syntax_node.rs b/crates/syntax/src/syntax_node.rs index b2abcbfbb..cc30138fa 100644 --- a/crates/syntax/src/syntax_node.rs +++ b/crates/syntax/src/syntax_node.rs | |||
@@ -10,9 +10,7 @@ use rowan::{GreenNodeBuilder, Language}; | |||
10 | 10 | ||
11 | use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; | 11 | use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; |
12 | 12 | ||
13 | pub use rowan::GreenNode; | 13 | pub(crate) use rowan::{GreenNode, GreenToken, NodeOrToken}; |
14 | |||
15 | pub(crate) use rowan::GreenToken; | ||
16 | 14 | ||
17 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 15 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
18 | pub enum RustLanguage {} | 16 | pub enum RustLanguage {} |
@@ -34,8 +32,6 @@ pub type SyntaxElement = rowan::SyntaxElement<RustLanguage>; | |||
34 | pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; | 32 | pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; |
35 | pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; | 33 | pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; |
36 | 34 | ||
37 | pub use rowan::{Direction, NodeOrToken}; | ||
38 | |||
39 | #[derive(Default)] | 35 | #[derive(Default)] |
40 | pub struct SyntaxTreeBuilder { | 36 | pub struct SyntaxTreeBuilder { |
41 | errors: Vec<SyntaxError>, | 37 | errors: Vec<SyntaxError>, |
diff --git a/crates/vfs/src/vfs_path.rs b/crates/vfs/src/vfs_path.rs index 022a0be1e..7a213fc3e 100644 --- a/crates/vfs/src/vfs_path.rs +++ b/crates/vfs/src/vfs_path.rs | |||
@@ -287,7 +287,7 @@ impl VirtualPath { | |||
287 | Some(res) | 287 | Some(res) |
288 | } | 288 | } |
289 | 289 | ||
290 | pub fn name_and_extension(&self) -> Option<(&str, Option<&str>)> { | 290 | pub(crate) fn name_and_extension(&self) -> Option<(&str, Option<&str>)> { |
291 | let file_path = if self.0.ends_with('/') { &self.0[..&self.0.len() - 1] } else { &self.0 }; | 291 | let file_path = if self.0.ends_with('/') { &self.0[..&self.0.len() - 1] } else { &self.0 }; |
292 | let file_name = match file_path.rfind('/') { | 292 | let file_name = match file_path.rfind('/') { |
293 | Some(position) => &file_path[position + 1..], | 293 | Some(position) => &file_path[position + 1..], |