From ba8d6d1e4ea2590b31470171efc175b0301c5e1c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Nov 2020 16:31:38 +0100 Subject: Remove more unreachable pubs --- crates/ide/src/diagnostics/fixes.rs | 2 +- crates/ide/src/doc_links.rs | 9 ++++----- crates/ide/src/file_structure.rs | 2 +- crates/ide/src/join_lines.rs | 2 +- crates/ide/src/lib.rs | 14 ++++++++------ crates/ide/src/markdown_remove.rs | 3 +-- crates/ide/src/matching_brace.rs | 2 +- crates/ide/src/references.rs | 8 ++------ crates/ide/src/syntax_highlighting.rs | 9 +++++---- 9 files changed, 24 insertions(+), 27 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index 0c950003e..02e17ba43 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -25,7 +25,7 @@ use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePos /// A [Diagnostic] that potentially has a fix available. /// /// [Diagnostic]: hir::diagnostics::Diagnostic -pub trait DiagnosticWithFix: Diagnostic { +pub(crate) trait DiagnosticWithFix: Diagnostic { fn fix(&self, sema: &Semantics) -> Option; } diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index 250f10f9f..10263537a 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs @@ -1,7 +1,6 @@ //! Resolves and rewrites links in markdown documentation. -use std::convert::TryFrom; -use std::iter::once; +use std::{convert::TryFrom, iter::once}; use itertools::Itertools; use pulldown_cmark::{BrokenLink, CowStr, Event, InlineStr, LinkType, Options, Parser, Tag}; @@ -21,10 +20,10 @@ use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, use crate::{FilePosition, Semantics}; -pub type DocumentationLink = String; +pub(crate) type DocumentationLink = String; /// Rewrite documentation links in markdown to point to an online host (e.g. docs.rs) -pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition) -> String { +pub(crate) fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition) -> String { let mut cb = |link: BrokenLink| { Some(( /*url*/ link.reference.to_owned().into(), @@ -63,7 +62,7 @@ pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition) } /// Remove all links in markdown documentation. -pub fn remove_links(markdown: &str) -> String { +pub(crate) fn remove_links(markdown: &str) -> String { let mut drop_link = false; let mut opts = Options::empty(); diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index 6168fb837..415795e8c 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs @@ -27,7 +27,7 @@ pub struct StructureNode { // // | VS Code | kbd:[Ctrl+Shift+O] // |=== -pub fn file_structure(file: &SourceFile) -> Vec { +pub(crate) fn file_structure(file: &SourceFile) -> Vec { let mut res = Vec::new(); let mut stack = Vec::new(); diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs index e37702acd..b5a6f66fd 100644 --- a/crates/ide/src/join_lines.rs +++ b/crates/ide/src/join_lines.rs @@ -18,7 +18,7 @@ use text_edit::{TextEdit, TextEditBuilder}; // // | VS Code | **Rust Analyzer: Join lines** // |=== -pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { +pub(crate) fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { let range = if range.is_empty() { let syntax = file.syntax(); let text = syntax.text().slice(range.start()..); diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 4bc733b70..6288f7ea7 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -72,18 +72,20 @@ pub use crate::{ inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, markup::Markup, prime_caches::PrimeCachesProgress, - references::{ - Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult, RenameError, - }, + references::{rename::RenameError, Declaration, ReferenceSearchResult}, runnables::{Runnable, RunnableKind, TestId}, syntax_highlighting::{ - Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange, + tags::{Highlight, HighlightModifier, HighlightModifiers, HighlightTag}, + HighlightedRange, }, }; pub use completion::{ CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat, }; -pub use ide_db::call_info::CallInfo; +pub use ide_db::{ + call_info::CallInfo, + search::{Reference, ReferenceAccess, ReferenceKind}, +}; pub use assists::{ utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist, @@ -503,7 +505,7 @@ impl Analysis { position: FilePosition, new_name: &str, ) -> Cancelable, RenameError>> { - self.with_db(|db| references::rename(db, position, new_name)) + self.with_db(|db| references::rename::rename(db, position, new_name)) } pub fn structural_search_replace( diff --git a/crates/ide/src/markdown_remove.rs b/crates/ide/src/markdown_remove.rs index 02ad39dfb..3ec5c629e 100644 --- a/crates/ide/src/markdown_remove.rs +++ b/crates/ide/src/markdown_remove.rs @@ -1,11 +1,10 @@ //! Removes markdown from strings. - use pulldown_cmark::{Event, Parser, Tag}; /// Removes all markdown, keeping the text and code blocks /// /// Currently limited in styling, i.e. no ascii tables or lists -pub fn remove_markdown(markdown: &str) -> String { +pub(crate) fn remove_markdown(markdown: &str) -> String { let mut out = String::new(); let parser = Parser::new(markdown); diff --git a/crates/ide/src/matching_brace.rs b/crates/ide/src/matching_brace.rs index cb6abb0db..d70248afe 100644 --- a/crates/ide/src/matching_brace.rs +++ b/crates/ide/src/matching_brace.rs @@ -15,7 +15,7 @@ use test_utils::mark; // // | VS Code | **Rust Analyzer: Find matching brace** // |=== -pub fn matching_brace(file: &SourceFile, offset: TextSize) -> Option { +pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option { const BRACES: &[SyntaxKind] = &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]]; let (brace_token, brace_idx) = file diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index a517081d5..e05465b32 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs @@ -14,7 +14,8 @@ pub(crate) mod rename; use hir::Semantics; use ide_db::{ defs::{Definition, NameClass, NameRefClass}, - search::SearchScope, + search::Reference, + search::{ReferenceAccess, ReferenceKind, SearchScope}, RootDatabase, }; use syntax::{ @@ -25,11 +26,6 @@ use syntax::{ use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo}; -pub(crate) use self::rename::rename; -pub use self::rename::RenameError; - -pub use ide_db::search::{Reference, ReferenceAccess, ReferenceKind}; - #[derive(Debug, Clone)] pub struct ReferenceSearchResult { declaration: Declaration, diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 624a63075..efcc8ecfe 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -2,7 +2,7 @@ mod format; mod html; mod injection; mod macro_rules; -mod tags; +pub(crate) mod tags; #[cfg(test)] mod tests; @@ -20,12 +20,13 @@ use syntax::{ }; use crate::{ - syntax_highlighting::{format::FormatStringHighlighter, macro_rules::MacroRulesHighlighter}, - FileId, + syntax_highlighting::{ + format::FormatStringHighlighter, macro_rules::MacroRulesHighlighter, tags::Highlight, + }, + FileId, HighlightModifier, HighlightTag, }; pub(crate) use html::highlight_as_html; -pub use tags::{Highlight, HighlightModifier, HighlightModifiers, HighlightTag}; #[derive(Debug, Clone)] pub struct HighlightedRange { -- cgit v1.2.3