From 0f48313565ed2620efbd9d0f2203b57f8f126e6a Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Fri, 14 Jun 2024 17:10:57 +0530 Subject: chore: upgrade to rust 1.79 (#24207) --- cli/cdp.rs | 153 +-------------------------------------- cli/factory.rs | 1 - cli/lsp/config.rs | 2 +- cli/lsp/path_to_regex.rs | 11 +-- cli/lsp/resolver.rs | 2 +- cli/lsp/testing/execution.rs | 2 +- cli/lsp/tsc.rs | 11 ++- cli/standalone/mod.rs | 5 +- cli/tools/bench/reporters.rs | 2 +- cli/tools/coverage/range_tree.rs | 2 +- cli/tools/registry/api.rs | 1 + cli/tools/registry/provenance.rs | 1 + cli/tools/test/channel.rs | 23 ++---- cli/tools/test/mod.rs | 4 +- cli/util/file_watcher.rs | 4 +- cli/worker.rs | 1 - 16 files changed, 31 insertions(+), 194 deletions(-) (limited to 'cli') diff --git a/cli/cdp.rs b/cli/cdp.rs index c4fbd226e..c5ff587dd 100644 --- a/cli/cdp.rs +++ b/cli/cdp.rs @@ -1,7 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. /// -use deno_core::serde_json; use deno_core::serde_json::Value; use serde::Deserialize; use serde::Deserializer; @@ -18,14 +17,6 @@ pub struct AwaitPromiseArgs { pub generate_preview: Option, } -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct AwaitPromiseResponse { - pub result: RemoteObject, - pub exception_details: Option, -} - /// #[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] @@ -72,14 +63,6 @@ pub struct CompileScriptArgs { pub execution_context_id: Option, } -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct CompileScriptResponse { - pub script_id: Option, - pub exception_details: Option, -} - /// #[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] @@ -147,9 +130,6 @@ pub struct GetPropertiesArgs { #[serde(rename_all = "camelCase")] pub struct GetPropertiesResponse { pub result: Vec, - pub internal_properties: Option>, - pub private_properties: Option>, - pub exception_details: Option, } /// @@ -176,13 +156,6 @@ pub struct QueryObjectsArgs { pub object_group: Option, } -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct QueryObjectsResponse { - pub objects: RemoteObject, -} - /// #[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] @@ -221,14 +194,6 @@ pub struct RunScriptArgs { pub await_promise: Option, } -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct RunScriptResponse { - pub result: RemoteObject, - pub exception_details: Option, -} - /// #[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] @@ -244,15 +209,11 @@ pub struct SetAsyncCallStackDepthArgs { pub struct RemoteObject { #[serde(rename = "type")] pub kind: String, - pub subtype: Option, - pub class_name: Option, #[serde(default, deserialize_with = "deserialize_some")] pub value: Option, pub unserializable_value: Option, pub description: Option, pub object_id: Option, - pub preview: Option, - pub custom_preview: Option, } // Any value that is present is considered Some value, including null. @@ -265,61 +226,12 @@ where Deserialize::deserialize(deserializer).map(Some) } -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct ObjectPreview { - #[serde(rename = "type")] - pub kind: String, - pub subtype: Option, - pub description: Option, - pub overflow: bool, - pub properties: Vec, - pub entries: Option>, -} - -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct PropertyPreview { - pub name: String, - #[serde(rename = "type")] - pub kind: String, - pub value: Option, - pub value_preview: Option, - pub subtype: Option, -} - -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct EntryPreview { - pub key: Option, - pub value: ObjectPreview, -} - -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct CustomPreview { - pub header: String, - pub body_getter_id: RemoteObjectId, -} - /// #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ExceptionDetails { - pub exception_id: u64, pub text: String, - pub line_number: u64, - pub column_number: u64, - pub script_id: Option, - pub url: Option, - pub stack_trace: Option, pub exception: Option, - pub execution_context_id: Option, - pub exception_meta_data: Option>, } impl ExceptionDetails { @@ -333,35 +245,6 @@ impl ExceptionDetails { } } -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct StackTrace { - pub description: Option, - pub call_frames: Vec, - pub parent: Option>, - pub parent_id: Option, -} - -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct CallFrame { - pub function_name: String, - pub script_id: ScriptId, - pub url: String, - pub line_number: u64, - pub column_number: u64, -} - -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct StackTraceId { - pub id: String, - pub debugger_id: Option, -} - /// #[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] @@ -384,38 +267,11 @@ impl From<&RemoteObject> for CallArgument { } } -/// +/// #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct PropertyDescriptor { pub name: String, - pub value: Option, - pub writable: Option, - pub get: Option, - pub set: Option, - pub configurable: bool, - pub enumerable: bool, - pub was_thrown: Option, - pub is_own: Option, - pub symbol: Option, -} - -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct InternalPropertyDescriptor { - pub name: String, - pub value: Option, -} - -/// -#[derive(Debug, Clone, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct PrivatePropertyDescriptor { - pub name: String, - pub value: Option, - pub get: Option, - pub set: Option, } /// @@ -433,9 +289,6 @@ pub type TimeDelta = u64; /// pub type UnserializableValue = String; -/// -pub type UniqueDebuggerId = String; - /// #[derive(Debug, Deserialize)] pub struct SetScriptSourceResponse { @@ -523,7 +376,6 @@ pub struct Notification { #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ExceptionThrown { - pub timestamp: f64, pub exception_details: ExceptionDetails, } @@ -539,8 +391,5 @@ pub struct ExecutionContextCreated { #[serde(rename_all = "camelCase")] pub struct ExecutionContextDescription { pub id: ExecutionContextId, - pub origin: String, - pub name: String, - pub unique_id: String, pub aux_data: Value, } diff --git a/cli/factory.rs b/cli/factory.rs index 5cae24c7c..ddd63e079 100644 --- a/cli/factory.rs +++ b/cli/factory.rs @@ -864,7 +864,6 @@ impl CliFactory { // integration. skip_op_registration: self.options.sub_command().is_run(), log_level: self.options.log_level().unwrap_or(log::Level::Info).into(), - coverage_dir: self.options.coverage_dir(), enable_op_summary_metrics: self.options.enable_op_summary_metrics(), enable_testing_features: self.options.enable_testing_features(), has_node_modules_dir: self.options.has_node_modules_dir(), diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index ae9ec6db8..327f725e4 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -1780,7 +1780,7 @@ impl ConfigTree { ); } } - self.first_folder = settings.first_folder.clone(); + self.first_folder.clone_from(&settings.first_folder); self.scopes = Arc::new(scopes); } diff --git a/cli/lsp/path_to_regex.rs b/cli/lsp/path_to_regex.rs index 10cd651d8..88d8a2ec6 100644 --- a/cli/lsp/path_to_regex.rs +++ b/cli/lsp/path_to_regex.rs @@ -795,8 +795,6 @@ impl Compiler { #[derive(Debug)] pub struct MatchResult { - pub path: String, - pub index: usize, pub params: HashMap, } @@ -824,9 +822,6 @@ impl Matcher { /// Match a string path, optionally returning the match result. pub fn matches(&self, path: &str) -> Option { let caps = self.re.captures(path).ok()??; - let m = caps.get(0)?; - let path = m.as_str().to_string(); - let index = m.start(); let mut params = HashMap::new(); if let Some(keys) = &self.maybe_keys { for (i, key) in keys.iter().enumerate() { @@ -852,11 +847,7 @@ impl Matcher { } } - Some(MatchResult { - path, - index, - params, - }) + Some(MatchResult { params }) } } diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs index c06bbfc8d..9790dfed7 100644 --- a/cli/lsp/resolver.rs +++ b/cli/lsp/resolver.rs @@ -502,7 +502,7 @@ impl RedirectResolver { } }; for (specifier, mut entry) in chain { - entry.destination = destination.clone(); + entry.destination.clone_from(&destination); self.entries.insert(specifier, Some(Arc::new(entry))); } destination diff --git a/cli/lsp/testing/execution.rs b/cli/lsp/testing/execution.rs index 6393c8642..b73bcd130 100644 --- a/cli/lsp/testing/execution.rs +++ b/cli/lsp/testing/execution.rs @@ -350,7 +350,7 @@ impl TestRun { test::TestEvent::Wait(id) => { reporter.report_wait(tests.read().get(&id).unwrap()); } - test::TestEvent::Output(_, output) => { + test::TestEvent::Output(output) => { reporter.report_output(&output); } test::TestEvent::Slow(id, elapsed) => { diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 76a33a532..5e5a509ac 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -385,7 +385,10 @@ impl TsServer { } None => None, }; - *self.inspector_server.lock() = maybe_inspector_server.clone(); + self + .inspector_server + .lock() + .clone_from(&maybe_inspector_server); // TODO(bartlomieju): why is the join_handle ignored here? Should we store it // on the `TsServer` struct. let receiver = self.receiver.lock().take().unwrap(); @@ -1718,7 +1721,7 @@ fn display_parts_to_string( "linkName" => { if let Some(link) = current_link.as_mut() { link.name = Some(part.text.clone()); - link.target = part.target.clone(); + link.target.clone_from(&part.target); } } "linkText" => { @@ -2271,7 +2274,7 @@ impl RenameLocations { let asset_or_doc = language_server.get_asset_or_document(&specifier)?; // ensure TextDocumentEdit for `location.file_name`. - if text_document_edit_map.get(&uri).is_none() { + if !text_document_edit_map.contains_key(&uri) { text_document_edit_map.insert( uri.clone(), lsp::TextDocumentEdit { @@ -3633,7 +3636,7 @@ impl CompletionEntry { .check_specifier(&import_specifier, specifier) .or_else(|| relative_specifier(specifier, &import_specifier)) { - display_source = new_module_specifier.clone(); + display_source.clone_from(&new_module_specifier); if new_module_specifier != import_data.module_specifier { specifier_rewrite = Some((import_data.module_specifier, new_module_specifier)); diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index b71e47ceb..e2a53e468 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -264,7 +264,9 @@ fn arc_u8_to_arc_str( // SAFETY: the string is valid UTF-8, and the layout Arc<[u8]> is the same as // Arc. This is proven by the From> impl for Arc<[u8]> from the // standard library. - Ok(unsafe { std::mem::transmute(arc_u8) }) + Ok(unsafe { + std::mem::transmute::, std::sync::Arc>(arc_u8) + }) } struct StandaloneModuleLoaderFactory { @@ -548,7 +550,6 @@ pub async fn run( CliMainWorkerOptions { argv: metadata.argv, log_level: WorkerLogLevel::Info, - coverage_dir: None, enable_op_summary_metrics: false, enable_testing_features: false, has_node_modules_dir, diff --git a/cli/tools/bench/reporters.rs b/cli/tools/bench/reporters.rs index b5229cf0a..690373dc8 100644 --- a/cli/tools/bench/reporters.rs +++ b/cli/tools/bench/reporters.rs @@ -169,7 +169,7 @@ impl BenchReporter for ConsoleReporter { fn report_register(&mut self, _desc: &BenchDescription) {} fn report_wait(&mut self, desc: &BenchDescription) { - self.name = desc.name.clone(); + self.name.clone_from(&desc.name); match &desc.group { None => {} diff --git a/cli/tools/coverage/range_tree.rs b/cli/tools/coverage/range_tree.rs index 027c7d9e7..bca52844c 100644 --- a/cli/tools/coverage/range_tree.rs +++ b/cli/tools/coverage/range_tree.rs @@ -150,7 +150,7 @@ impl<'rt> RangeTree<'rt> { Self::from_sorted_ranges_inner( rta, &mut ranges.iter().peekable(), - ::std::usize::MAX, + usize::MAX, 0, ) } diff --git a/cli/tools/registry/api.rs b/cli/tools/registry/api.rs index c7097267d..ee9579a19 100644 --- a/cli/tools/registry/api.rs +++ b/cli/tools/registry/api.rs @@ -39,6 +39,7 @@ pub struct OidcTokenResponse { #[derive(serde::Deserialize)] #[serde(rename_all = "camelCase")] pub struct PublishingTaskError { + #[allow(dead_code)] pub code: String, pub message: String, } diff --git a/cli/tools/registry/provenance.rs b/cli/tools/registry/provenance.rs index 7fa2be381..622e483d6 100644 --- a/cli/tools/registry/provenance.rs +++ b/cli/tools/registry/provenance.rs @@ -570,6 +570,7 @@ static DEFAULT_REKOR_URL: Lazy = Lazy::new(|| { #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct LogEntry { + #[allow(dead_code)] #[serde(rename = "logID")] pub log_id: String, pub log_index: u64, diff --git a/cli/tools/test/channel.rs b/cli/tools/test/channel.rs index a8ce7a955..9a003f2d5 100644 --- a/cli/tools/test/channel.rs +++ b/cli/tools/test/channel.rs @@ -1,7 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use super::TestEvent; -use super::TestStdioStream; use deno_core::futures::future::poll_fn; use deno_core::parking_lot; use deno_core::parking_lot::lock_api::RawMutex; @@ -105,7 +104,6 @@ impl TestEventReceiver { struct TestStream { id: usize, - which: TestStdioStream, read_opt: Option, sender: UnboundedSender<(usize, TestEvent)>, } @@ -113,7 +111,6 @@ struct TestStream { impl TestStream { fn new( id: usize, - which: TestStdioStream, pipe_reader: PipeRead, sender: UnboundedSender<(usize, TestEvent)>, ) -> std::io::Result { @@ -121,7 +118,6 @@ impl TestStream { let read_opt = Some(pipe_reader.into_async()?); Ok(Self { id, - which, read_opt, sender, }) @@ -135,7 +131,7 @@ impl TestStream { true } else if self .sender - .send((self.id, TestEvent::Output(self.which, buffer))) + .send((self.id, TestEvent::Output(buffer))) .is_err() { self.read_opt.take(); @@ -275,14 +271,9 @@ impl TestEventSenderFactory { .build() .unwrap(); runtime.block_on(tokio::task::unconstrained(async move { - let mut test_stdout = TestStream::new( - id, - TestStdioStream::Stdout, - stdout_reader, - sender.clone(), - )?; - let mut test_stderr = - TestStream::new(id, TestStdioStream::Stderr, stderr_reader, sender)?; + let mut test_stdout = + TestStream::new(id, stdout_reader, sender.clone())?; + let mut test_stderr = TestStream::new(id, stderr_reader, sender)?; // This ensures that the stdout and stderr streams in the select! loop below cannot starve each // other. @@ -488,7 +479,7 @@ mod tests { let mut count = 0; for message in messages { match message { - TestEvent::Output(_, vec) => { + TestEvent::Output(vec) => { assert_eq!(vec[0], expected); count += vec.len(); } @@ -619,7 +610,7 @@ mod tests { while let Some((_, message)) = receiver.recv().await { if i % 2 == 0 { let expected_text = format!("{:08x}", i / 2).into_bytes(); - let TestEvent::Output(TestStdioStream::Stderr, text) = message else { + let TestEvent::Output(text) = message else { panic!("Incorrect message: {message:?}"); }; assert_eq!(text, expected_text); @@ -665,7 +656,7 @@ mod tests { .unwrap(); drop(worker); let (_, message) = receiver.recv().await.unwrap(); - let TestEvent::Output(TestStdioStream::Stderr, text) = message else { + let TestEvent::Output(text) = message else { panic!("Incorrect message: {message:?}"); }; assert_eq!(text.as_slice(), b"hello"); diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index 7416b5a26..88b539470 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -454,7 +454,7 @@ pub enum TestEvent { Register(Arc), Plan(TestPlan), Wait(usize), - Output(TestStdioStream, Vec), + Output(Vec), Slow(usize, u64), Result(usize, TestResult, u64), UncaughtError(String, Box), @@ -1491,7 +1491,7 @@ pub async fn report_tests( reporter.report_wait(tests.get(&id).unwrap()); } } - TestEvent::Output(_, output) => { + TestEvent::Output(output) => { reporter.report_output(&output); } TestEvent::Slow(id, elapsed) => { diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index 247ae49d8..b2628760b 100644 --- a/cli/util/file_watcher.rs +++ b/cli/util/file_watcher.rs @@ -278,7 +278,9 @@ where deno_core::unsync::spawn(async move { loop { let received_changed_paths = watcher_receiver.recv().await; - *changed_paths_.borrow_mut() = received_changed_paths.clone(); + changed_paths_ + .borrow_mut() + .clone_from(&received_changed_paths); match *watcher_.restart_mode.lock() { WatcherRestartMode::Automatic => { diff --git a/cli/worker.rs b/cli/worker.rs index cb52b6101..f332fc6bb 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -102,7 +102,6 @@ pub type CreateCoverageCollectorCb = Box< pub struct CliMainWorkerOptions { pub argv: Vec, pub log_level: WorkerLogLevel, - pub coverage_dir: Option, pub enable_op_summary_metrics: bool, pub enable_testing_features: bool, pub has_node_modules_dir: bool, -- cgit v1.2.3