From 73b0f9dc0461104021a11bdfed0f6f10820a9277 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 15 Sep 2021 21:22:06 +0300 Subject: [PATCH] internal: remove dead code --- crates/flycheck/src/lib.rs | 4 ++-- crates/hir/src/source_analyzer.rs | 3 --- crates/ide_completion/src/context.rs | 2 -- .../ide_completion/src/render/enum_variant.rs | 3 +-- crates/ide_db/src/call_info.rs | 9 -------- crates/ide_ssr/src/lib.rs | 1 - crates/ide_ssr/src/matching.rs | 21 ++----------------- crates/ide_ssr/src/parsing.rs | 2 +- crates/proc_macro_api/src/process.rs | 4 ++-- crates/vfs-notify/src/lib.rs | 4 ++-- 10 files changed, 10 insertions(+), 43 deletions(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index a636d865025..40dfe6f5117 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -55,7 +55,7 @@ impl fmt::Display for FlycheckConfig { pub struct FlycheckHandle { // XXX: drop order is significant sender: Sender, - thread: jod_thread::JoinHandle, + _thread: jod_thread::JoinHandle, } impl FlycheckHandle { @@ -71,7 +71,7 @@ impl FlycheckHandle { .name("Flycheck".to_owned()) .spawn(move || actor.run(receiver)) .expect("failed to spawn thread"); - FlycheckHandle { sender, thread } + FlycheckHandle { sender, _thread: thread } } /// Schedule a re-start of the cargo check worker. diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index b6ee5968fa2..960b290e266 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -43,7 +43,6 @@ pub(crate) struct SourceAnalyzer { body: Option>, body_source_map: Option>, infer: Option>, - scopes: Option>, } impl SourceAnalyzer { @@ -65,7 +64,6 @@ impl SourceAnalyzer { body: Some(body), body_source_map: Some(source_map), infer: Some(db.infer(def)), - scopes: Some(scopes), file_id: node.file_id, } } @@ -79,7 +77,6 @@ impl SourceAnalyzer { body: None, body_source_map: None, infer: None, - scopes: None, file_id: node.file_id, } } diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 1ec952d49c9..0fcefa69d6a 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -107,7 +107,6 @@ pub(crate) struct CompletionContext<'a> { pub(super) pattern_ctx: Option, pub(super) path_context: Option, - pub(super) active_parameter: Option, pub(super) locals: Vec<(String, Local)>, pub(super) incomplete_let: bool, @@ -170,7 +169,6 @@ impl<'a> CompletionContext<'a> { attribute_under_caret: None, previous_token: None, path_context: None, - active_parameter: ActiveParameter::at(db, position), locals, incomplete_let: false, no_completion_required: false, diff --git a/crates/ide_completion/src/render/enum_variant.rs b/crates/ide_completion/src/render/enum_variant.rs index 44a5ceb25ad..d5cfd8bba46 100644 --- a/crates/ide_completion/src/render/enum_variant.rs +++ b/crates/ide_completion/src/render/enum_variant.rs @@ -26,7 +26,6 @@ pub(crate) fn render_variant( #[derive(Debug)] struct EnumRender<'a> { ctx: RenderContext<'a>, - name: hir::Name, variant: hir::Variant, path: Option, qualified_name: hir::ModPath, @@ -58,7 +57,7 @@ impl<'a> EnumRender<'a> { ), }; - EnumRender { ctx, name, variant, path, qualified_name, short_qualified_name, variant_kind } + EnumRender { ctx, variant, path, qualified_name, short_qualified_name, variant_kind } } fn render(self, import_to_add: Option) -> CompletionItem { let mut item = CompletionItem::new( diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs index 016b0014396..3d32fddd939 100644 --- a/crates/ide_db/src/call_info.rs +++ b/crates/ide_db/src/call_info.rs @@ -154,15 +154,6 @@ pub struct ActiveParameter { } impl ActiveParameter { - pub fn at(db: &RootDatabase, position: FilePosition) -> Option { - let sema = Semantics::new(db); - let file = sema.parse(position.file_id); - let file = file.syntax(); - let token = file.token_at_offset(position.offset).next()?; - let token = sema.descend_into_macros(token); - Self::at_token(&sema, token) - } - pub fn at_token(sema: &Semantics, token: SyntaxToken) -> Option { let (signature, active_parameter) = call_info_impl(sema, token)?; diff --git a/crates/ide_ssr/src/lib.rs b/crates/ide_ssr/src/lib.rs index 47434f4af84..264ea753ef3 100644 --- a/crates/ide_ssr/src/lib.rs +++ b/crates/ide_ssr/src/lib.rs @@ -103,7 +103,6 @@ pub struct SsrRule { #[derive(Debug)] pub struct SsrPattern { - raw: parsing::RawPattern, parsed_rules: Vec, } diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs index 55147674d25..004bbeec5b3 100644 --- a/crates/ide_ssr/src/matching.rs +++ b/crates/ide_ssr/src/matching.rs @@ -61,9 +61,6 @@ pub struct Match { /// Information about a placeholder bound in a match. #[derive(Debug)] pub(crate) struct PlaceholderMatch { - /// The node that the placeholder matched to. If set, then we'll search for further matches - /// within this node. It isn't set when we match tokens within a macro call's token tree. - pub(crate) node: Option, pub(crate) range: FileRange, /// More matches, found within `node`. pub(crate) inner_matches: SsrMatches, @@ -186,7 +183,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { self.validate_range(&original_range)?; matches_out.placeholder_values.insert( placeholder.ident.clone(), - PlaceholderMatch::new(Some(code), original_range), + PlaceholderMatch::from_range(original_range), ); } return Ok(()); @@ -715,19 +712,14 @@ fn recording_match_fail_reasons() -> bool { } impl PlaceholderMatch { - fn new(node: Option<&SyntaxNode>, range: FileRange) -> Self { + fn from_range(range: FileRange) -> Self { Self { - node: node.cloned(), range, inner_matches: SsrMatches::default(), autoderef_count: 0, autoref_kind: ast::SelfParamKind::Owned, } } - - fn from_range(range: FileRange) -> Self { - Self::new(None, range) - } } impl NodeKind { @@ -788,7 +780,6 @@ impl PatternIterator { #[cfg(test)] mod tests { - use super::*; use crate::{MatchFinder, SsrRule}; #[test] @@ -803,14 +794,6 @@ mod tests { assert_eq!(matches.matches.len(), 1); assert_eq!(matches.matches[0].matched_node.text(), "foo(1+2)"); assert_eq!(matches.matches[0].placeholder_values.len(), 1); - assert_eq!( - matches.matches[0].placeholder_values[&Var("x".to_string())] - .node - .as_ref() - .unwrap() - .text(), - "1+2" - ); let edits = match_finder.edits(); assert_eq!(edits.len(), 1); diff --git a/crates/ide_ssr/src/parsing.rs b/crates/ide_ssr/src/parsing.rs index 5e757e70191..ed7c033e275 100644 --- a/crates/ide_ssr/src/parsing.rs +++ b/crates/ide_ssr/src/parsing.rs @@ -204,7 +204,7 @@ impl FromStr for SsrPattern { fn from_str(pattern_str: &str) -> Result { let raw_pattern = pattern_str.parse()?; let parsed_rules = ParsedRule::new(&raw_pattern, None)?; - Ok(SsrPattern { raw: raw_pattern, parsed_rules }) + Ok(SsrPattern { parsed_rules }) } } diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs index 16741fc0ad1..ff4c59447d8 100644 --- a/crates/proc_macro_api/src/process.rs +++ b/crates/proc_macro_api/src/process.rs @@ -16,7 +16,7 @@ use crate::{ #[derive(Debug)] pub(crate) struct ProcMacroProcessSrv { - process: Process, + _process: Process, stdin: ChildStdin, stdout: BufReader, } @@ -29,7 +29,7 @@ impl ProcMacroProcessSrv { let mut process = Process::run(process_path, args)?; let (stdin, stdout) = process.stdio().expect("couldn't access child stdio"); - let srv = ProcMacroProcessSrv { process, stdin, stdout }; + let srv = ProcMacroProcessSrv { _process: process, stdin, stdout }; Ok(srv) } diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index 637438bd66c..4fb34aed07a 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -18,7 +18,7 @@ use walkdir::WalkDir; pub struct NotifyHandle { // Relative order of fields below is significant. sender: Sender, - thread: jod_thread::JoinHandle, + _thread: jod_thread::JoinHandle, } #[derive(Debug)] @@ -35,7 +35,7 @@ impl loader::Handle for NotifyHandle { .name("VfsLoader".to_owned()) .spawn(move || actor.run(receiver)) .expect("failed to spawn thread"); - NotifyHandle { sender, thread } + NotifyHandle { sender, _thread: thread } } fn set_config(&mut self, config: loader::Config) { self.sender.send(Message::Config(config)).unwrap()