aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-11-02 13:08:53 +0000
committerGitHub <[email protected]>2020-11-02 13:08:53 +0000
commit731b38fa3c1694648e6c8e60f61820f9783343eb (patch)
treeb3f4e94e8eac9bb24296aacafacb100930bee59e /crates/hir_def/src
parent6507877e7039d4517682a4fc232356662f509d81 (diff)
parentb6101184537b1165cfdd5fc473e04ad4c5b7bffa (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/hir_def/src')
-rw-r--r--crates/hir_def/src/body/lower.rs6
-rw-r--r--crates/hir_def/src/lib.rs6
-rw-r--r--crates/hir_def/src/nameres/collector.rs14
-rw-r--r--crates/hir_def/src/test_db.rs14
4 files changed, 20 insertions, 20 deletions
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
47impl LowerCtx { 47impl 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)]
488struct AstIdWithPath<T: ast::AstNode> { 488struct 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
493impl<T: ast::AstNode> AstIdWithPath<T> { 493impl<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)]
124struct Import { 124struct 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)]
28pub struct TestDB { 28pub(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
74impl TestDB { 74impl 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());