Skip to content

Commit 8a47278

Browse files
authored
Remove some unused code, annotations. (#4476)
## Motivation In `test_utils` we `#![allow(unused_imports)]` because "items are only used by some tests" and "Rust will complain". That doesn't seem to be true, and if it were I don't see why the affected test shouldn't just import the items in question directly. ## Proposal Remove the attribute and the unused imports. Also, remove or restrict some similar attributes in other places. ## Test Plan CI ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 7e5b886 commit 8a47278

File tree

5 files changed

+16
-37
lines changed

5 files changed

+16
-37
lines changed

linera-execution/src/execution_state_actor.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,14 @@ where
414414
ExecutionError::UnauthorizedHttpRequest(url)
415415
);
416416

417-
#[cfg_attr(web, allow(unused_mut))]
418-
let mut request = Client::new()
417+
let request = Client::new()
419418
.request(request.method.into(), url)
420419
.body(request.body)
421420
.headers(headers);
422421
#[cfg(not(web))]
423-
{
424-
request = request.timeout(linera_base::time::Duration::from_millis(
425-
committee.policy().http_request_timeout_ms,
426-
));
427-
}
422+
let request = request.timeout(linera_base::time::Duration::from_millis(
423+
committee.policy().http_request_timeout_ms,
424+
));
428425

429426
let response = request.send().await?;
430427

linera-execution/src/test_utils/mock_application.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use std::{
77
collections::VecDeque,
88
fmt::{self, Debug, Display, Formatter},
9-
mem,
109
sync::{
1110
atomic::{AtomicUsize, Ordering},
1211
Arc, Mutex,
@@ -15,10 +14,7 @@ use std::{
1514

1615
#[cfg(web)]
1716
use js_sys::wasm_bindgen;
18-
use linera_base::{
19-
data_types::StreamUpdate,
20-
identifiers::{ChainId, StreamId},
21-
};
17+
use linera_base::data_types::StreamUpdate;
2218

2319
use crate::{
2420
ContractSyncRuntimeHandle, ExecutionError, ServiceSyncRuntimeHandle, UserContract,

linera-execution/src/test_utils/mod.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// Copyright (c) Zefchain Labs, Inc.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
// Some of these items are only used by some tests, but Rust will complain about unused
5-
// items for the tests where they aren't used
6-
#![allow(unused_imports)]
7-
84
mod mock_application;
95
#[cfg(with_revm)]
106
pub mod solidity;
@@ -13,28 +9,26 @@ mod system_execution_state;
139
use std::{collections::BTreeMap, sync::Arc, thread, vec};
1410

1511
use linera_base::{
16-
crypto::{AccountPublicKey, BcsSignable, CryptoHash, ValidatorPublicKey},
12+
crypto::{AccountPublicKey, ValidatorPublicKey},
1713
data_types::{
1814
Amount, Blob, BlockHeight, ChainDescription, ChainOrigin, CompressedBytecode, Epoch,
1915
InitialChainConfig, OracleResponse, Timestamp,
2016
},
21-
identifiers::{AccountOwner, ApplicationId, BlobId, BlobType, ChainId, ModuleId},
17+
identifiers::{AccountOwner, ApplicationId, BlobId, ChainId, ModuleId},
2218
ownership::ChainOwnership,
2319
vm::VmRuntime,
2420
};
25-
use linera_views::{context::Context, views::View, ViewError};
21+
use linera_views::{context::Context, views::View};
2622
use proptest::{prelude::any, strategy::Strategy};
27-
use serde::{Deserialize, Serialize};
2823

2924
pub use self::{
3025
mock_application::{ExpectedCall, MockApplication, MockApplicationInstance},
3126
system_execution_state::SystemExecutionState,
3227
};
3328
use crate::{
34-
committee::Committee, execution_state_actor::ExecutionRequest, ApplicationDescription,
35-
ExecutionRuntimeContext, ExecutionStateView, MessageContext, OperationContext, QueryContext,
36-
ServiceRuntimeEndpoint, ServiceRuntimeRequest, ServiceSyncRuntime, SystemExecutionStateView,
37-
TestExecutionRuntimeContext,
29+
committee::Committee, ApplicationDescription, ExecutionRuntimeContext, ExecutionStateView,
30+
MessageContext, OperationContext, QueryContext, ServiceRuntimeEndpoint, ServiceSyncRuntime,
31+
SystemExecutionStateView,
3832
};
3933

4034
pub fn dummy_committee() -> Committee {

linera-execution/src/test_utils/system_execution_state.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::{
55
collections::{BTreeMap, BTreeSet},
66
ops::Not,
7-
sync::Arc,
87
};
98

109
use custom_debug_derive::Debug;
@@ -15,21 +14,14 @@ use linera_base::{
1514
ownership::ChainOwnership,
1615
};
1716
use linera_views::{
18-
context::{Context, MemoryContext},
19-
random::generate_test_namespace,
17+
context::MemoryContext,
2018
views::{CryptoHashView, View},
21-
ViewError,
2219
};
2320

24-
use super::{
25-
dummy_chain_description, dummy_committees, AccountPublicKey, MockApplication,
26-
RegisterMockApplication, ValidatorPublicKey,
27-
};
21+
use super::{dummy_chain_description, dummy_committees, MockApplication, RegisterMockApplication};
2822
use crate::{
29-
committee::Committee, execution::UserAction, ApplicationDescription, ExecutionError,
30-
ExecutionRuntimeConfig, ExecutionRuntimeContext, ExecutionStateView, OperationContext,
31-
ResourceControlPolicy, ResourceController, ResourceTracker, TestExecutionRuntimeContext,
32-
UserContractCode,
23+
committee::Committee, ApplicationDescription, ExecutionRuntimeConfig, ExecutionRuntimeContext,
24+
ExecutionStateView, TestExecutionRuntimeContext,
3325
};
3426

3527
/// A system execution state, not represented as a view but as a simple struct.

linera-rpc/src/grpc/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ where
412412
}
413413

414414
fn log_request_outcome_and_latency(start: Instant, success: bool, method_name: &str) {
415-
#![allow(unused_variables)]
415+
#![cfg_attr(not(with_metrics), allow(unused_variables))]
416416
#[cfg(with_metrics)]
417417
{
418418
metrics::SERVER_REQUEST_LATENCY_PER_REQUEST_TYPE

0 commit comments

Comments
 (0)