From 5d24e098713fde0ec54ae3185c5ad057800d3659 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Mon, 10 Jan 2022 14:20:48 -0800 Subject: [PATCH 1/2] simplify rustfmt config --- .github/workflows/rust.yml | 11 +- .vscode/settings.json | 8 - README.adoc | 22 +- dropshot/examples/basic.rs | 9 +- dropshot/examples/file_server.rs | 9 +- dropshot/examples/https.rs | 9 +- dropshot/examples/index.rs | 5 +- dropshot/examples/module-basic.rs | 9 +- dropshot/examples/module-shared-context.rs | 9 +- dropshot/examples/pagination-basic.rs | 17 +- .../examples/pagination-multiple-resources.rs | 51 ++--- .../examples/pagination-multiple-sorts.rs | 13 +- dropshot/examples/petstore.rs | 4 +- dropshot/src/api_description.rs | 63 ++---- dropshot/src/from_map.rs | 9 +- dropshot/src/handler.rs | 32 +-- dropshot/src/logging.rs | 40 ++-- dropshot/src/pagination.rs | 31 +-- dropshot/src/router.rs | 50 +++-- dropshot/src/server.rs | 23 +- dropshot/src/test_util.rs | 201 ++++++++++-------- dropshot/tests/test_config.rs | 15 +- dropshot/tests/test_demo.rs | 31 +-- dropshot/tests/test_pagination.rs | 69 +++--- dropshot/tests/test_tls.rs | 4 +- dropshot_endpoint/src/syn_parsing.rs | 7 +- rustfmt.toml | 92 -------- 27 files changed, 295 insertions(+), 548 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c56ac97b7..cdc2fe46f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,17 +14,12 @@ jobs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@230611dbd0eb52da1e1f4f7bc8bb0c3a339fc8b7 - - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 - with: - toolchain: nightly-2021-03-25 - default: false - components: rustfmt - name: Report cargo version - run: cargo +nightly-2021-03-25 --version + run: cargo --version - name: Report rustfmt version - run: cargo +nightly-2021-03-25 fmt -- --version + run: cargo fmt -- --version - name: Check style - run: cargo +nightly-2021-03-25 fmt -- --check + run: cargo fmt -- --check clippy-lint: runs-on: ubuntu-18.04 diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 020b10d8f..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rust-analyzer.rustfmt.overrideCommand": [ - "rustup", - "run", - "nightly-2021-03-25", - "rustfmt" - ] -} diff --git a/README.adoc b/README.adoc index b26cfc395..ab567a645 100644 --- a/README.adoc +++ b/README.adoc @@ -15,34 +15,16 @@ You can build the documentation yourself with: $ cargo +nightly doc ---- - == Contributing -For maintainers (e.g., publishing new releases and managing dependabot), see link:./MAINTAINERS.adoc[MAINTAINERS.adoc]. - -=== Building and testing - You can **build and run the whole test suite** with `cargo test`. The test suite runs cleanly and should remain clean. -=== Code formatting and lint - -Dropshot works with stable Rust versions, but for consistency the code is -_formatted_ with a specific version of `rustfmt`. To contribute to Dropshot, -you will need to have installed the `nightly-2021-03-25` version of the Rust -toolchain: - ----- -$ rustup install nightly-2021-03-25 ----- - -You can then **format the code** using `cargo +nightly-2021-03-25 fmt` or -`rustfmt +nightly-2021-03-25`. Make sure to run this before pushing changes. -The CI uses this version of `rustfmt` to check that the code is correctly -formatted. +You can format the code using `cargo fmt`. CI checks that code is correctly formatted. https://github.com/rust-lang/rust-clippy[Clippy] is used to check for common code issues. (We disable the style checks.) You can run it with `cargo clippy`. CI will run clippy as well. +For maintainers (e.g., publishing new releases and managing dependabot), see link:./MAINTAINERS.adoc[MAINTAINERS.adoc]. == Configuration reference diff --git a/dropshot/examples/basic.rs b/dropshot/examples/basic.rs index a69ba3876..139bf3d9c 100644 --- a/dropshot/examples/basic.rs +++ b/dropshot/examples/basic.rs @@ -35,9 +35,8 @@ async fn main() -> Result<(), String> { * For simplicity, we'll configure an "info"-level logger that writes to * stderr assuming that it's a terminal. */ - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Info, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }; let log = config_logging .to_logger("example-basic") .map_err(|error| format!("failed to create logger: {}", error))?; @@ -82,9 +81,7 @@ impl ExampleContext { * Return a new ExampleContext. */ pub fn new() -> ExampleContext { - ExampleContext { - counter: AtomicU64::new(0), - } + ExampleContext { counter: AtomicU64::new(0) } } } diff --git a/dropshot/examples/file_server.rs b/dropshot/examples/file_server.rs index c1ef23472..cbd1a7a6e 100644 --- a/dropshot/examples/file_server.rs +++ b/dropshot/examples/file_server.rs @@ -35,9 +35,8 @@ async fn main() -> Result<(), String> { * For simplicity, we'll configure an "info"-level logger that writes to * stderr assuming that it's a terminal. */ - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Info, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }; let log = config_logging .to_logger("example-basic") .map_err(|error| format!("failed to create logger: {}", error))?; @@ -51,9 +50,7 @@ async fn main() -> Result<(), String> { /* * Specify the directory we want to serve. */ - let context = FileServerContext { - base: PathBuf::from("."), - }; + let context = FileServerContext { base: PathBuf::from(".") }; /* * Set up the server. diff --git a/dropshot/examples/https.rs b/dropshot/examples/https.rs index e0d4f770d..4ea7d3842 100644 --- a/dropshot/examples/https.rs +++ b/dropshot/examples/https.rs @@ -83,9 +83,8 @@ async fn main() -> Result<(), String> { * For simplicity, we'll configure an "info"-level logger that writes to * stderr assuming that it's a terminal. */ - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Info, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }; let log = config_logging .to_logger("example-basic") .map_err(|error| format!("failed to create logger: {}", error))?; @@ -130,9 +129,7 @@ impl ExampleContext { * Return a new ExampleContext. */ pub fn new() -> ExampleContext { - ExampleContext { - counter: AtomicU64::new(0), - } + ExampleContext { counter: AtomicU64::new(0) } } } diff --git a/dropshot/examples/index.rs b/dropshot/examples/index.rs index a29a2ff0f..94499ce72 100644 --- a/dropshot/examples/index.rs +++ b/dropshot/examples/index.rs @@ -31,9 +31,8 @@ async fn main() -> Result<(), String> { * For simplicity, we'll configure an "info"-level logger that writes to * stderr assuming that it's a terminal. */ - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Info, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }; let log = config_logging .to_logger("example-basic") .map_err(|error| format!("failed to create logger: {}", error))?; diff --git a/dropshot/examples/module-basic.rs b/dropshot/examples/module-basic.rs index bbd6603b2..3b486d7c7 100644 --- a/dropshot/examples/module-basic.rs +++ b/dropshot/examples/module-basic.rs @@ -26,9 +26,8 @@ async fn main() -> Result<(), String> { * For simplicity, we'll configure an "info"-level logger that writes to * stderr assuming that it's a terminal. */ - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Info, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }; let log = config_logging .to_logger("example-basic") .map_err(|error| format!("failed to create logger: {}", error))?; @@ -73,9 +72,7 @@ impl ExampleContext { * Return a new ExampleContext. */ pub fn new() -> ExampleContext { - ExampleContext { - counter: AtomicU64::new(0), - } + ExampleContext { counter: AtomicU64::new(0) } } } diff --git a/dropshot/examples/module-shared-context.rs b/dropshot/examples/module-shared-context.rs index 9c3560664..367c48ee2 100644 --- a/dropshot/examples/module-shared-context.rs +++ b/dropshot/examples/module-shared-context.rs @@ -34,9 +34,8 @@ async fn main() -> Result<(), String> { * For simplicity, we'll configure an "info"-level logger that writes to * stderr assuming that it's a terminal. */ - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Info, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }; let log = config_logging .to_logger("example-basic") .map_err(|error| format!("failed to create logger: {}", error))?; @@ -102,9 +101,7 @@ impl ExampleContext { * Return a new ExampleContext. */ pub fn new() -> ExampleContext { - ExampleContext { - counter: AtomicU64::new(0), - } + ExampleContext { counter: AtomicU64::new(0) } } } diff --git a/dropshot/examples/pagination-basic.rs b/dropshot/examples/pagination-basic.rs index 175db90bd..4935654f4 100644 --- a/dropshot/examples/pagination-basic.rs +++ b/dropshot/examples/pagination-basic.rs @@ -91,9 +91,7 @@ async fn example_list_projects( .map(|(_, project)| project.clone()) .collect() } - WhichPage::Next(ProjectPage { - name: last_seen, - }) => { + WhichPage::Next(ProjectPage { name: last_seen }) => { /* Return a list of the first "limit" projects after this name. */ tree.range((Bound::Excluded(last_seen.clone()), Bound::Unbounded)) .take(limit) @@ -105,9 +103,7 @@ async fn example_list_projects( Ok(HttpResponseOk(ResultsPage::new( projects, &EmptyScanParams {}, - |p: &Project, _| ProjectPage { - name: p.name.clone(), - }, + |p: &Project, _| ProjectPage { name: p.name.clone() }, )?)) } @@ -126,9 +122,7 @@ async fn main() -> Result<(), String> { let mut tree = BTreeMap::new(); for n in 1..1000 { let name = format!("project{:03}", n); - let project = Project { - name: name.clone(), - }; + let project = Project { name: name.clone() }; tree.insert(name, project); } @@ -140,9 +134,8 @@ async fn main() -> Result<(), String> { bind_address: SocketAddr::from((Ipv4Addr::LOCALHOST, port)), ..Default::default() }; - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Debug, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Debug }; let log = config_logging .to_logger("example-pagination-basic") .map_err(|error| format!("failed to create logger: {}", error))?; diff --git a/dropshot/examples/pagination-multiple-resources.rs b/dropshot/examples/pagination-multiple-resources.rs index 1d9174f25..2184a4829 100644 --- a/dropshot/examples/pagination-multiple-resources.rs +++ b/dropshot/examples/pagination-multiple-resources.rs @@ -119,27 +119,25 @@ fn page_selector( scan_params: &ExScanParams, ) -> ExPageSelector { match scan_params { - ExScanParams { - sort: ExSortMode::ByIdAscending, - } => ExPageSelector::Id(Ascending, *item.id()), - ExScanParams { - sort: ExSortMode::ByIdDescending, - } => ExPageSelector::Id(Descending, *item.id()), - ExScanParams { - sort: ExSortMode::ByNameAscending, - } => ExPageSelector::Name(Ascending, item.name().to_string()), - ExScanParams { - sort: ExSortMode::ByNameDescending, - } => ExPageSelector::Name(Descending, item.name().to_string()), + ExScanParams { sort: ExSortMode::ByIdAscending } => { + ExPageSelector::Id(Ascending, *item.id()) + } + ExScanParams { sort: ExSortMode::ByIdDescending } => { + ExPageSelector::Id(Descending, *item.id()) + } + ExScanParams { sort: ExSortMode::ByNameAscending } => { + ExPageSelector::Name(Ascending, item.name().to_string()) + } + ExScanParams { sort: ExSortMode::ByNameDescending } => { + ExPageSelector::Name(Descending, item.name().to_string()) + } } } fn scan_params(p: &WhichPage) -> ExScanParams { ExScanParams { sort: match p { - WhichPage::First(ExScanParams { - sort, - }) => sort.clone(), + WhichPage::First(ExScanParams { sort }) => sort.clone(), WhichPage::Next(ExPageSelector::Id(Ascending, ..)) => { ExSortMode::ByIdAscending @@ -297,9 +295,8 @@ async fn main() -> Result<(), String> { bind_address: SocketAddr::from((Ipv4Addr::LOCALHOST, port)), ..Default::default() }; - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Debug, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Debug }; let log = config_logging .to_logger("example-pagination-basic") .map_err(|error| format!("failed to create logger: {}", error))?; @@ -346,26 +343,20 @@ impl DataCollection { }; for n in 1..1000 { let pname = format!("project{:03}", n); - let project = Arc::new(Project { - id: Uuid::new_v4(), - name: pname.clone(), - }); + let project = + Arc::new(Project { id: Uuid::new_v4(), name: pname.clone() }); data.projects_by_name.insert(pname.clone(), Arc::clone(&project)); data.projects_by_id.insert(project.id, project); let dname = format!("disk{:03}", n); - let disk = Arc::new(Disk { - id: Uuid::new_v4(), - name: dname.clone(), - }); + let disk = + Arc::new(Disk { id: Uuid::new_v4(), name: dname.clone() }); data.disks_by_name.insert(dname.clone(), Arc::clone(&disk)); data.disks_by_id.insert(disk.id, disk); let iname = format!("disk{:03}", n); - let instance = Arc::new(Instance { - id: Uuid::new_v4(), - name: iname.clone(), - }); + let instance = + Arc::new(Instance { id: Uuid::new_v4(), name: iname.clone() }); data.instances_by_name.insert(iname.clone(), Arc::clone(&instance)); data.instances_by_id.insert(instance.id, instance); } diff --git a/dropshot/examples/pagination-multiple-sorts.rs b/dropshot/examples/pagination-multiple-sorts.rs index ae075ecda..05ec2ce02 100644 --- a/dropshot/examples/pagination-multiple-sorts.rs +++ b/dropshot/examples/pagination-multiple-sorts.rs @@ -241,9 +241,7 @@ async fn example_list_projects( let data = rqctx.context(); let scan_params = ProjectScanParams { sort: match &pag_params.page { - WhichPage::First(ProjectScanParams { - sort, - }) => sort.clone(), + WhichPage::First(ProjectScanParams { sort }) => sort.clone(), WhichPage::Next(ProjectScanPageSelector::Name(Ascending, ..)) => { ProjectSort::ByNameAscending @@ -313,9 +311,8 @@ async fn main() -> Result<(), String> { bind_address: SocketAddr::from((Ipv4Addr::LOCALHOST, port)), ..Default::default() }; - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Debug, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Debug }; let log = config_logging .to_logger("example-pagination-basic") .map_err(|error| format!("failed to create logger: {}", error))?; @@ -341,9 +338,7 @@ fn print_example_requests(log: slog::Logger, addr: &SocketAddr) { ProjectSort::ByMtimeDescending, ]; for mode in all_modes { - let to_print = ProjectScanParams { - sort: mode, - }; + let to_print = ProjectScanParams { sort: mode }; let query_string = serde_urlencoded::to_string(to_print).unwrap(); let uri = Uri::builder() .scheme("http") diff --git a/dropshot/examples/petstore.rs b/dropshot/examples/petstore.rs index 1f410f4af..5040cd2dc 100644 --- a/dropshot/examples/petstore.rs +++ b/dropshot/examples/petstore.rs @@ -156,9 +156,7 @@ async fn find_pets_by_tags( tags: None, status: None, }; - tmp = FindByTagsScanParams { - tags: page_selector.tags.clone(), - }; + tmp = FindByTagsScanParams { tags: page_selector.tags.clone() }; (vec![pet], &tmp) } }; diff --git a/dropshot/src/api_description.rs b/dropshot/src/api_description.rs index 74a4a1d98..e578154dd 100644 --- a/dropshot/src/api_description.rs +++ b/dropshot/src/api_description.rs @@ -200,12 +200,10 @@ pub enum ApiSchemaGenerator { impl std::fmt::Debug for ApiSchemaGenerator { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - ApiSchemaGenerator::Gen { - .. - } => f.write_str("[schema generator]"), - ApiSchemaGenerator::Static { - schema, .. - } => f.write_str(format!("{:?}", schema).as_str()), + ApiSchemaGenerator::Gen { .. } => f.write_str("[schema generator]"), + ApiSchemaGenerator::Static { schema, .. } => { + f.write_str(format!("{:?}", schema).as_str()) + } } } } @@ -222,9 +220,7 @@ pub struct ApiDescription { impl ApiDescription { pub fn new() -> Self { - ApiDescription { - router: HttpRouter::new(), - } + ApiDescription { router: HttpRouter::new() } } /** @@ -370,10 +366,9 @@ impl ApiDescription { } /* Only body parameters should have unresolved schemas */ let (schema, dependencies) = match ¶m.schema { - ApiSchemaGenerator::Static { - schema, - dependencies, - } => (schema, dependencies), + ApiSchemaGenerator::Static { schema, dependencies } => { + (schema, dependencies) + } _ => unreachable!(), }; @@ -488,10 +483,7 @@ impl ApiDescription { }; let schema = match ¶m.schema { - ApiSchemaGenerator::Static { - schema, - dependencies, - } => { + ApiSchemaGenerator::Static { schema, dependencies } => { definitions.extend(dependencies.clone()); j2oas_schema(None, schema) } @@ -548,14 +540,10 @@ impl ApiDescription { }; let (name, js) = match ¶m.schema { - ApiSchemaGenerator::Gen { - name, - schema, - } => (Some(name()), schema(&mut generator)), - ApiSchemaGenerator::Static { - schema, - dependencies, - } => { + ApiSchemaGenerator::Gen { name, schema } => { + (Some(name()), schema(&mut generator)) + } + ApiSchemaGenerator::Static { schema, dependencies } => { definitions.extend(dependencies.clone()); (None, schema.as_ref().clone()) } @@ -588,14 +576,10 @@ impl ApiDescription { if let Some(schema) = &endpoint.response.schema { let (name, js) = match schema { - ApiSchemaGenerator::Gen { - name, - schema, - } => (Some(name()), schema(&mut generator)), - ApiSchemaGenerator::Static { - schema, - dependencies, - } => { + ApiSchemaGenerator::Gen { name, schema } => { + (Some(name()), schema(&mut generator)) + } + ApiSchemaGenerator::Static { schema, dependencies } => { definitions.extend(dependencies.clone()); (None, schema.as_ref().clone()) } @@ -1127,11 +1111,9 @@ fn box_reference_or( openapiv3::ReferenceOr::Item(schema) => { openapiv3::ReferenceOr::boxed_item(schema) } - openapiv3::ReferenceOr::Reference { - reference, - } => openapiv3::ReferenceOr::Reference { - reference, - }, + openapiv3::ReferenceOr::Reference { reference } => { + openapiv3::ReferenceOr::Reference { reference } + } } } @@ -1197,10 +1179,7 @@ impl<'a, Context: ServerContext> OpenApiDefinition<'a, Context> { version: version.to_string(), ..Default::default() }; - OpenApiDefinition { - api, - info, - } + OpenApiDefinition { api, info } } /** diff --git a/dropshot/src/from_map.rs b/dropshot/src/from_map.rs index 8cba81e6c..56b69cc4f 100644 --- a/dropshot/src/from_map.rs +++ b/dropshot/src/from_map.rs @@ -211,10 +211,7 @@ where MapDeserializer::Map(map) => { let xx = map.clone(); let x = Box::new(xx.into_iter()); - let m = MapMapAccess:: { - iter: x, - value: None, - }; + let m = MapMapAccess:: { iter: x, value: None }; visitor.visit_map(m) } MapDeserializer::Value(_) => Err(MapError( @@ -305,9 +302,7 @@ where V: Visitor<'de>, { self.value(|raw_value| { - visitor.visit_seq(MapSeqAccess { - iter: raw_value.as_seq()?, - }) + visitor.visit_seq(MapSeqAccess { iter: raw_value.as_seq()? }) }) } } diff --git a/dropshot/src/handler.rs b/dropshot/src/handler.rs index 831d446d8..4f1fd0507 100644 --- a/dropshot/src/handler.rs +++ b/dropshot/src/handler.rs @@ -572,9 +572,7 @@ where * TODO-correctness: are query strings defined to be urlencoded in this way? */ match serde_urlencoded::from_str(raw_query_string) { - Ok(q) => Ok(Query { - inner: q, - }), + Ok(q) => Ok(Query { inner: q }), Err(e) => Err(HttpError::for_bad_request( None, format!("unable to parse query string: {}", e), @@ -644,9 +642,7 @@ where rqctx: Arc>, ) -> Result, HttpError> { let params: PathType = http_extract_path_params(&rqctx.path_variables)?; - Ok(Path { - inner: params, - }) + Ok(Path { inner: params }) } fn metadata() -> ExtractorMetadata { @@ -692,10 +688,7 @@ struct ReferenceVisitor<'a> { impl<'a> ReferenceVisitor<'a> { fn new(generator: &'a schemars::gen::SchemaGenerator) -> Self { - Self { - generator, - dependencies: indexmap::IndexMap::new(), - } + Self { generator, dependencies: indexmap::IndexMap::new() } } fn dependencies( @@ -925,9 +918,7 @@ where let value: Result = serde_json::from_slice(&body_bytes); match value { - Ok(j) => Ok(TypedBody { - inner: j, - }), + Ok(j) => Ok(TypedBody { inner: j }), Err(e) => Err(HttpError::for_bad_request( None, format!("unable to parse body: {}", e), @@ -965,10 +956,7 @@ where }, vec![], ); - ExtractorMetadata { - paginated: false, - parameters: vec![body], - } + ExtractorMetadata { paginated: false, parameters: vec![body] } } } @@ -1021,9 +1009,7 @@ impl Extractor for UntypedBody { server.config.request_body_max_bytes, ) .await?; - Ok(UntypedBody { - content: body_bytes, - }) + Ok(UntypedBody { content: body_bytes }) } fn metadata() -> ExtractorMetadata { @@ -1084,11 +1070,7 @@ impl HttpResponse for Response { Ok(self) } fn metadata() -> ApiEndpointResponse { - ApiEndpointResponse { - schema: None, - success: None, - description: None, - } + ApiEndpointResponse { schema: None, success: None, description: None } } } diff --git a/dropshot/src/logging.rs b/dropshot/src/logging.rs index c1e6440ae..2ce9b4d47 100644 --- a/dropshot/src/logging.rs +++ b/dropshot/src/logging.rs @@ -80,20 +80,14 @@ impl ConfigLogging { log_name: S, ) -> Result { match self { - ConfigLogging::StderrTerminal { - level, - } => { + ConfigLogging::StderrTerminal { level } => { let decorator = slog_term::TermDecorator::new().build(); let drain = slog_term::FullFormat::new(decorator).build().fuse(); Ok(async_root_logger(level, drain)) } - ConfigLogging::File { - level, - path, - if_exists, - } => { + ConfigLogging::File { level, path, if_exists } => { let mut open_options = std::fs::OpenOptions::new(); open_options.write(true); open_options.create(true); @@ -528,12 +522,15 @@ mod test { let time_after = chrono::offset::Utc::now(); let log_records = read_bunyan_log(&logpath); let expected_hostname = hostname::get().unwrap().into_string().unwrap(); - verify_bunyan_records(log_records.iter(), &BunyanLogRecordSpec { - name: Some("test-logger".to_string()), - hostname: Some(expected_hostname.clone()), - v: Some(0), - pid: Some(std::process::id()), - }); + verify_bunyan_records( + log_records.iter(), + &BunyanLogRecordSpec { + name: Some("test-logger".to_string()), + hostname: Some(expected_hostname.clone()), + v: Some(0), + pid: Some(std::process::id()), + }, + ); verify_bunyan_records_sequential( log_records.iter(), Some(&time_before), @@ -570,12 +567,15 @@ mod test { } let log_records = read_bunyan_log(&logpath); - verify_bunyan_records(log_records.iter(), &BunyanLogRecordSpec { - name: Some("test-logger".to_string()), - hostname: Some(expected_hostname), - v: Some(0), - pid: Some(std::process::id()), - }); + verify_bunyan_records( + log_records.iter(), + &BunyanLogRecordSpec { + name: Some("test-logger".to_string()), + hostname: Some(expected_hostname), + v: Some(0), + pid: Some(std::process::id()), + }, + ); verify_bunyan_records_sequential( log_records.iter(), Some(&time_before), diff --git a/dropshot/src/pagination.rs b/dropshot/src/pagination.rs index 03a925733..ee3f30a62 100644 --- a/dropshot/src/pagination.rs +++ b/dropshot/src/pagination.rs @@ -175,10 +175,7 @@ impl ResultsPage { }) .transpose()?; - Ok(ResultsPage { - next_page, - items, - }) + Ok(ResultsPage { next_page, items }) } } @@ -436,10 +433,8 @@ fn serialize_page_token( page_start: PageSelector, ) -> Result { let token_bytes = { - let serialized_token = SerializedToken { - v: PaginationVersion::V1, - page_start, - }; + let serialized_token = + SerializedToken { v: PaginationVersion::V1, page_start }; let json_bytes = serde_json::to_vec(&serialized_token).map_err(|e| { @@ -544,9 +539,7 @@ mod test { * The most basic functionality is that if we serialize something and * then deserialize the result of that, we get back the original thing. */ - let before = MyToken { - x: 1025, - }; + let before = MyToken { x: 1025 }; let serialized = serialize_page_token(&before).unwrap(); let after: MyToken = deserialize_page_token(&serialized).unwrap(); assert_eq!(after.x, 1025); @@ -567,9 +560,8 @@ mod test { struct TokenWithStr { s: String, } - let input = TokenWithStr { - s: String::from_utf8(vec![b'e'; 352]).unwrap(), - }; + let input = + TokenWithStr { s: String::from_utf8(vec![b'e'; 352]).unwrap() }; let serialized = serialize_page_token(&input).unwrap(); assert_eq!(serialized.len(), super::MAX_TOKEN_LENGTH); let output: TokenWithStr = deserialize_page_token(&serialized).unwrap(); @@ -581,9 +573,8 @@ mod test { * Start by attempting to serialize a token larger than the maximum * allowed size. */ - let input = TokenWithStr { - s: String::from_utf8(vec![b'e'; 353]).unwrap(), - }; + let input = + TokenWithStr { s: String::from_utf8(vec![b'e'; 353]).unwrap() }; let error = serialize_page_token(&input).unwrap_err(); assert_eq!(error.status_code, http::StatusCode::INTERNAL_SERVER_ERROR); assert_eq!(error.external_message, "Internal Server Error"); @@ -764,10 +755,8 @@ mod test { } /* basic case */ - let token = serialize_page_token(&MyPageSelector { - the_page: 123, - }) - .unwrap(); + let token = + serialize_page_token(&MyPageSelector { the_page: 123 }).unwrap(); let (page_selector, limit) = parse_as_next_page(&format!("page_token={}", token)); assert_eq!(page_selector.the_page, 123); diff --git a/dropshot/src/router.rs b/dropshot/src/router.rs index 2a62bf7aa..16915af2f 100644 --- a/dropshot/src/router.rs +++ b/dropshot/src/router.rs @@ -262,10 +262,7 @@ pub struct RouterLookupResult<'a, Context: ServerContext> { impl HttpRouterNode { pub fn new() -> Self { - HttpRouterNode { - methods: BTreeMap::new(), - edges: None, - } + HttpRouterNode { methods: BTreeMap::new(), edges: None } } } @@ -274,9 +271,7 @@ impl HttpRouter { * Returns a new `HttpRouter` with no routes configured. */ pub fn new() -> Self { - HttpRouter { - root: Box::new(HttpRouterNode::new()), - } + HttpRouter { root: Box::new(HttpRouterNode::new()) } } /** @@ -1232,9 +1227,10 @@ mod test { .lookup_route(&Method::GET, "/projects/p12345".into()) .unwrap(); assert_eq!(result.handler.label(), "h5"); - assert_eq!(result.variables.keys().collect::>(), vec![ - "project_id" - ]); + assert_eq!( + result.variables.keys().collect::>(), + vec!["project_id"] + ); assert_eq!( *result.variables.get("project_id").unwrap(), VariableValue::String("p12345".to_string()) @@ -1288,11 +1284,10 @@ mod test { ) .unwrap(); assert_eq!(result.handler.label(), "h6"); - assert_eq!(result.variables.keys().collect::>(), vec![ - "fwrule_id", - "instance_id", - "project_id" - ]); + assert_eq!( + result.variables.keys().collect::>(), + vec!["fwrule_id", "instance_id", "project_id"] + ); assert_eq!( *result.variables.get("project_id").unwrap(), VariableValue::String("p1".to_string()) @@ -1377,10 +1372,16 @@ mod test { "/projects/{project_id}/instances", )); let ret: Vec<_> = router.into_iter().map(|x| (x.0, x.1)).collect(); - assert_eq!(ret, vec![ - ("/".to_string(), "GET".to_string(),), - ("/projects/{project_id}/instances".to_string(), "GET".to_string(),), - ]); + assert_eq!( + ret, + vec![ + ("/".to_string(), "GET".to_string(),), + ( + "/projects/{project_id}/instances".to_string(), + "GET".to_string(), + ), + ] + ); } #[test] @@ -1397,10 +1398,13 @@ mod test { "/", )); let ret: Vec<_> = router.into_iter().map(|x| (x.0, x.1)).collect(); - assert_eq!(ret, vec![ - ("/".to_string(), "GET".to_string(),), - ("/".to_string(), "POST".to_string(),), - ]); + assert_eq!( + ret, + vec![ + ("/".to_string(), "GET".to_string(),), + ("/".to_string(), "POST".to_string(),), + ] + ); } #[test] diff --git a/dropshot/src/server.rs b/dropshot/src/server.rs index 1ae9f995e..06a16ff73 100644 --- a/dropshot/src/server.rs +++ b/dropshot/src/server.rs @@ -267,10 +267,7 @@ struct TlsConn { impl TlsConn { fn new(stream: TlsStream, remote_addr: SocketAddr) -> TlsConn { - TlsConn { - stream, - remote_addr, - } + TlsConn { stream, remote_addr } } fn remote_addr(&self) -> SocketAddr { @@ -803,9 +800,7 @@ impl ServerConnectionHandler { * will be made available to the handler. */ fn new(server: Arc>) -> Self { - ServerConnectionHandler { - server, - } + ServerConnectionHandler { server } } } @@ -865,10 +860,7 @@ impl ServerRequestHandler { * will be provided to the handler function. */ fn new(server: Arc>, remote_addr: SocketAddr) -> Self { - ServerRequestHandler { - server, - remote_addr, - } + ServerRequestHandler { server, remote_addr } } } @@ -974,9 +966,8 @@ mod test { let mut api = ApiDescription::new(); api.register(handler).unwrap(); - let config_logging = ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Warn, - }; + let config_logging = + ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Warn }; let log_context = LogContext::new("test server", &config_logging); let log = &log_context.log; @@ -984,9 +975,7 @@ mod test { .unwrap() .start(); - (server, TestConfig { - log_context, - }) + (server, TestConfig { log_context }) } async fn single_client_request(addr: SocketAddr, log: &slog::Logger) { diff --git a/dropshot/src/test_util.rs b/dropshot/src/test_util.rs index afe1947d8..4cfdc3680 100644 --- a/dropshot/src/test_util.rs +++ b/dropshot/src/test_util.rs @@ -47,10 +47,7 @@ struct AllowedHeader<'a> { impl<'a> AllowedHeader<'a> { const fn new(name: &'a str) -> Self { - Self { - name, - value: AllowedValue::Any, - } + Self { name, value: AllowedValue::Any } } } @@ -399,11 +396,7 @@ impl LogContext { * environment variable or other flag. */ let (log_path, log_config) = match initial_config_logging { - ConfigLogging::File { - level, - path: dummy_path, - if_exists, - } => { + ConfigLogging::File { level, path: dummy_path, if_exists } => { assert_eq!( dummy_path, "UNUSED", "for test suite logging configuration, when mode = \ @@ -414,20 +407,20 @@ impl LogContext { let new_path = log_file_for_test(test_name); let new_path_str = new_path.as_path().display().to_string(); eprintln!("log file: {:?}", new_path_str); - (Some(new_path), ConfigLogging::File { - level: level.clone(), - path: new_path_str, - if_exists: if_exists.clone(), - }) + ( + Some(new_path), + ConfigLogging::File { + level: level.clone(), + path: new_path_str, + if_exists: if_exists.clone(), + }, + ) } other_config => (None, other_config.clone()), }; let log = log_config.to_logger(test_name).unwrap(); - LogContext { - log, - log_path, - } + LogContext { log, log_path } } /** @@ -487,12 +480,7 @@ impl TestContext { let client_log = log.new(o!("http_client" => "dropshot test suite")); let client_testctx = ClientTestContext::new(server_addr, client_log); - TestContext { - client_testctx, - server, - log, - log_context, - } + TestContext { client_testctx, server, log, log_context } } /** @@ -889,72 +877,93 @@ mod test { /* Test case: nothing to check. */ let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: None, - hostname: None, - pid: None, - v: None, - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: None, + hostname: None, + pid: None, + v: None, + }, + ); /* Test case: check name, no problem. */ let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: Some("n1".to_string()), - hostname: None, - pid: None, - v: None, - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: Some("n1".to_string()), + hostname: None, + pid: None, + v: None, + }, + ); /* Test case: check hostname, no problem. */ let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: None, - hostname: Some("h1".to_string()), - pid: None, - v: None, - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: None, + hostname: Some("h1".to_string()), + pid: None, + v: None, + }, + ); /* Test case: check pid, no problem. */ let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: None, - hostname: None, - pid: Some(1), - v: None, - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: None, + hostname: None, + pid: Some(1), + v: None, + }, + ); /* Test case: check hostname, no problem. */ let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: None, - hostname: None, - pid: None, - v: Some(0), - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: None, + hostname: None, + pid: None, + v: Some(0), + }, + ); /* Test case: check all, no problem. */ let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: Some("n1".to_string()), - hostname: Some("h1".to_string()), - pid: Some(1), - v: Some(0), - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: Some("n1".to_string()), + hostname: Some("h1".to_string()), + pid: Some(1), + v: Some(0), + }, + ); /* Test case: check multiple records, no problem. */ let records: Vec<&BunyanLogRecord> = vec![&r1, &r2]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: Some("n1".to_string()), - hostname: None, - pid: Some(1), - v: None, - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: Some("n1".to_string()), + hostname: None, + pid: Some(1), + v: None, + }, + ); } /* @@ -967,12 +976,15 @@ mod test { let r1 = make_dummy_record(); let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: Some("n2".to_string()), - hostname: None, - pid: None, - v: None, - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: Some("n2".to_string()), + hostname: None, + pid: None, + v: None, + }, + ); } #[test] @@ -981,12 +993,15 @@ mod test { let r1 = make_dummy_record(); let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: None, - hostname: Some("h2".to_string()), - pid: None, - v: None, - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: None, + hostname: Some("h2".to_string()), + pid: None, + v: None, + }, + ); } #[test] @@ -995,12 +1010,15 @@ mod test { let r1 = make_dummy_record(); let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: None, - hostname: None, - pid: Some(2), - v: None, - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: None, + hostname: None, + pid: Some(2), + v: None, + }, + ); } #[test] @@ -1009,12 +1027,15 @@ mod test { let r1 = make_dummy_record(); let records: Vec<&BunyanLogRecord> = vec![&r1]; let iter = records.iter().map(|x| *x); - verify_bunyan_records(iter, &BunyanLogRecordSpec { - name: None, - hostname: None, - pid: None, - v: Some(1), - }); + verify_bunyan_records( + iter, + &BunyanLogRecordSpec { + name: None, + hostname: None, + pid: None, + v: Some(1), + }, + ); } /* diff --git a/dropshot/tests/test_config.rs b/dropshot/tests/test_config.rs index 913bd43d6..f5724ef25 100644 --- a/dropshot/tests/test_config.rs +++ b/dropshot/tests/test_config.rs @@ -272,9 +272,7 @@ async fn test_config_bind_address_http() { } } - let test_config = ConfigBindServerHttp { - log, - }; + let test_config = ConfigBindServerHttp { log }; let bind_port = 12215; test_config_bind_server::<_, ConfigBindServerHttp>(test_config, bind_port) .await; @@ -302,9 +300,7 @@ async fn test_config_bind_address_https() { hyper_rustls::HttpsConnector, > { // Configure TLS to trust the self-signed cert - let mut root_store = rustls::RootCertStore { - roots: vec![], - }; + let mut root_store = rustls::RootCertStore { roots: vec![] }; root_store .add(&self.certs[self.certs.len() - 1]) .expect("adding root cert"); @@ -345,12 +341,7 @@ async fn test_config_bind_address_https() { // Generate key for the server let (certs, key) = common::generate_tls_key(); let (cert_file, key_file) = common::tls_key_to_file(&certs, &key); - let test_config = ConfigBindServerHttps { - log, - certs, - cert_file, - key_file, - }; + let test_config = ConfigBindServerHttps { log, certs, cert_file, key_file }; /* This must be different than the bind_port used in the http test. */ let bind_port = 12217; diff --git a/dropshot/tests/test_demo.rs b/dropshot/tests/test_demo.rs index ffc98a6c4..54c61ee6a 100644 --- a/dropshot/tests/test_demo.rs +++ b/dropshot/tests/test_demo.rs @@ -200,10 +200,7 @@ async fn test_demo2json() { let testctx = common::test_setup("demo2json", api); /* Test case: optional field */ - let input = DemoJsonBody { - test1: "bar".to_string(), - test2: None, - }; + let input = DemoJsonBody { test1: "bar".to_string(), test2: None }; let mut response = testctx .client_testctx .make_request( @@ -219,10 +216,7 @@ async fn test_demo2json() { assert_eq!(json.test2, None); /* Test case: both fields populated */ - let input = DemoJsonBody { - test1: "bar".to_string(), - test2: Some(15), - }; + let input = DemoJsonBody { test1: "bar".to_string(), test2: Some(15) }; let mut response = testctx .client_testctx .make_request( @@ -294,10 +288,7 @@ async fn test_demo3json() { let testctx = common::test_setup("demo3json", api); /* Test case: everything filled in. */ - let json_input = DemoJsonBody { - test1: "bart".to_string(), - test2: Some(0), - }; + let json_input = DemoJsonBody { test1: "bart".to_string(), test2: Some(0) }; let mut response = testctx .client_testctx @@ -316,10 +307,7 @@ async fn test_demo3json() { assert_eq!(json.query.test2.unwrap(), 2); /* Test case: error parsing query */ - let json_input = DemoJsonBody { - test1: "bart".to_string(), - test2: Some(0), - }; + let json_input = DemoJsonBody { test1: "bart".to_string(), test2: Some(0) }; let error = testctx .client_testctx .make_request( @@ -680,10 +668,8 @@ async fn demo_handler_args_3( query: Query, json: TypedBody, ) -> Result, HttpError> { - let combined = DemoJsonAndQuery { - query: query.into_inner(), - json: json.into_inner(), - }; + let combined = + DemoJsonAndQuery { query: query.into_inner(), json: json.into_inner() }; http_echo(&combined) } @@ -760,10 +746,7 @@ async fn demo_handler_untyped_body( None }; - Ok(HttpResponseOk(DemoUntyped { - nbytes, - as_utf8, - })) + Ok(HttpResponseOk(DemoUntyped { nbytes, as_utf8 })) } #[derive(Deserialize, Serialize, JsonSchema)] diff --git a/dropshot/tests/test_pagination.rs b/dropshot/tests/test_pagination.rs index c94d94356..0cd5f2370 100644 --- a/dropshot/tests/test_pagination.rs +++ b/dropshot/tests/test_pagination.rs @@ -156,9 +156,7 @@ struct IntegersPageSelector { } fn page_selector_for(n: &u16, _p: &EmptyScanParams) -> IntegersPageSelector { - IntegersPageSelector { - last_seen: *n, - } + IntegersPageSelector { last_seen: *n } } /** @@ -206,9 +204,7 @@ async fn api_integers( let start = match &pag_params.page { WhichPage::First(..) => 0, - WhichPage::Next(IntegersPageSelector { - last_seen, - }) => *last_seen, + WhichPage::Next(IntegersPageSelector { last_seen }) => *last_seen, }; Ok(HttpResponseOk(ResultsPage::new( @@ -471,9 +467,7 @@ async fn api_with_extra_params( let start = match &pag_params.page { WhichPage::First(..) => 0, - WhichPage::Next(IntegersPageSelector { - last_seen, - }) => *last_seen, + WhichPage::Next(IntegersPageSelector { last_seen }) => *last_seen, }; Ok(HttpResponseOk(ExtraResultsPage { @@ -565,9 +559,7 @@ async fn api_with_required_params( let limit = rqctx.page_limit(&pag_params)?.get() as u16; let start = match &pag_params.page { - WhichPage::First(ReqScanParams { - doit, - }) => { + WhichPage::First(ReqScanParams { doit }) => { if !doit { return Err(HttpError::for_bad_request( None, @@ -577,9 +569,7 @@ async fn api_with_required_params( 0 } - WhichPage::Next(IntegersPageSelector { - last_seen, - }) => *last_seen, + WhichPage::Next(IntegersPageSelector { last_seen }) => *last_seen, }; Ok(HttpResponseOk(ResultsPage::new( @@ -685,10 +675,9 @@ async fn api_dictionary( let (bound, scan_params) = match &pag_params.page { WhichPage::First(scan) => (Bound::Unbounded, scan), - WhichPage::Next(DictionaryPageSelector { - scan, - last_seen, - }) => (Bound::Excluded(last_seen), scan), + WhichPage::Next(DictionaryPageSelector { scan, last_seen }) => { + (Bound::Excluded(last_seen), scan) + } }; let (range_bounds, reverse) = match scan_params.order { @@ -701,10 +690,7 @@ async fn api_dictionary( if reverse { Box::new(iter) } else { Box::new(iter.rev()) }; let iter = iter.filter_map(|word| { if word.len() >= scan_params.min_length { - Some(DictionaryWord { - word: word.to_string(), - length: word.len(), - }) + Some(DictionaryWord { word: word.to_string(), length: word.len() }) } else { None } @@ -779,11 +765,10 @@ async fn test_paginate_dictionary() { .await; let found_words = page.items.iter().map(|dw| dw.word.as_str()).collect::>(); - assert_eq!(found_words, vec![ - "Addressograph", - "Aristotelean", - "Aristotelian", - ]); + assert_eq!( + found_words, + vec!["Addressograph", "Aristotelean", "Aristotelian",] + ); let token = page.next_page.unwrap(); let page = objects_list_page::( &client, @@ -792,11 +777,10 @@ async fn test_paginate_dictionary() { .await; let found_words = page.items.iter().map(|dw| dw.word.as_str()).collect::>(); - assert_eq!(found_words, vec![ - "Bhagavadgita", - "Brontosaurus", - "Cantabrigian", - ]); + assert_eq!( + found_words, + vec!["Bhagavadgita", "Brontosaurus", "Cantabrigian",] + ); /* * Let's page through the filtered collection one item at a time. This is @@ -883,11 +867,14 @@ impl Drop for ExampleContext { * process and a ClientTestContext for making requests against that server. */ async fn start_example(path: &str, port: u16) -> ExampleContext { - let logctx = LogContext::new(path, &ConfigLogging::File { - level: ConfigLoggingLevel::Info, - path: "UNUSED".to_string(), - if_exists: ConfigLoggingIfExists::Fail, - }); + let logctx = LogContext::new( + path, + &ConfigLogging::File { + level: ConfigLoggingLevel::Info, + path: "UNUSED".to_string(), + if_exists: ConfigLoggingIfExists::Fail, + }, + ); let log = logctx.log.new(o!()); let cmd_path = { @@ -921,11 +908,7 @@ async fn start_example(path: &str, port: u16) -> ExampleContext { let client = ClientTestContext::new(server_addr, logctx.log.new(o!())); let url = client.url("/"); let raw_client = Client::new(); - let rv = ExampleContext { - child, - client, - logctx: Some(logctx), - }; + let rv = ExampleContext { child, client, logctx: Some(logctx) }; while start.elapsed().as_secs() < 10 { trace!(&log, "making test request to see if the server is up"); diff --git a/dropshot/tests/test_tls.rs b/dropshot/tests/test_tls.rs index adb93a02e..6dd15f556 100644 --- a/dropshot/tests/test_tls.rs +++ b/dropshot/tests/test_tls.rs @@ -85,9 +85,7 @@ fn make_server( fn make_pki_verifier( certs: &Vec, ) -> impl rustls::client::ServerCertVerifier { - let mut root_store = rustls::RootCertStore { - roots: vec![], - }; + let mut root_store = rustls::RootCertStore { roots: vec![] }; root_store.add(&certs[certs.len() - 1]).expect("adding root cert"); rustls::client::WebPkiVerifier::new(root_store, None) } diff --git a/dropshot_endpoint/src/syn_parsing.rs b/dropshot_endpoint/src/syn_parsing.rs index 85658850d..800d7c392 100644 --- a/dropshot_endpoint/src/syn_parsing.rs +++ b/dropshot_endpoint/src/syn_parsing.rs @@ -20,12 +20,7 @@ impl Parse for ItemFnForSignature { let vis: Visibility = input.parse()?; let sig: Signature = input.parse()?; let block = input.parse()?; - Ok(ItemFnForSignature { - attrs, - vis, - sig, - _block: block, - }) + Ok(ItemFnForSignature { attrs, vis, sig, _block: block }) } } diff --git a/rustfmt.toml b/rustfmt.toml index 1ddc8ac0d..11297fdbe 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -3,96 +3,4 @@ # --------------------------------------------------------------------------- max_width = 80 use_small_heuristics = "max" -unstable_features = true edition = "2018" - -# -# --------------------------------------------------------------------------- -# Unstable features that we customize locally -# --------------------------------------------------------------------------- -# -# We would like to use "wrap_comments = true" and "comment_width = 80", but -# there are several issues with our use of it today, including rustfmt#4079 and -# rustfmt#4020. -# -# "overflow_delimited_expr" and "struct_lit_single_line" are both fairly minor, -# but improve readability. -# -format_strings = true -overflow_delimited_expr = true -struct_lit_single_line = false - -# -# --------------------------------------------------------------------------- -# Below are all other flags that we do NOT customize. We specify these -# explicitly here to minimize churn if the upstream defaults change. If you -# modify any of these, move them above this line! -# -# The following can be generated by starting with: -# -# rustfmt +nightly --print-config=default -# -# and removing anything that we've configured above. -# --------------------------------------------------------------------------- -# -hard_tabs = false -tab_spaces = 4 -newline_style = "Auto" -indent_style = "Block" -wrap_comments = false -format_code_in_doc_comments = false -comment_width = 80 -normalize_comments = false -normalize_doc_attributes = false -license_template_path = "" -format_macro_matchers = false -format_macro_bodies = true -empty_item_single_line = true -fn_single_line = false -where_single_line = false -imports_indent = "Block" -imports_layout = "Mixed" -imports_granularity = "Preserve" -group_imports = "Preserve" -reorder_imports = true -reorder_modules = true -reorder_impl_items = false -type_punctuation_density = "Wide" -space_before_colon = false -space_after_colon = true -spaces_around_ranges = false -binop_separator = "Front" -remove_nested_parens = true -combine_control_expr = true -struct_field_align_threshold = 0 -enum_discrim_align_threshold = 0 -match_arm_blocks = true -match_arm_leading_pipes = "Never" -force_multiline_blocks = false -fn_args_layout = "Tall" -brace_style = "SameLineWhere" -control_brace_style = "AlwaysSameLine" -trailing_semicolon = true -trailing_comma = "Vertical" -match_block_trailing_comma = false -blank_lines_upper_bound = 1 -blank_lines_lower_bound = 0 -version = "One" -inline_attribute_width = 0 -merge_derives = true -use_try_shorthand = false -use_field_init_shorthand = false -force_explicit_abi = true -condense_wildcard_suffixes = false -color = "Auto" -required_version = "1.4.36" -disable_all_formatting = false -skip_children = false -hide_parse_errors = false -error_on_line_overflow = false -error_on_unformatted = false -report_todo = "Never" -report_fixme = "Never" -ignore = [] -emit_mode = "Files" -make_backup = false From e36fc2a8f773d7e0bf564926f3f0e5a16a6550de Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Mon, 10 Jan 2022 14:51:55 -0800 Subject: [PATCH 2/2] remove actions-rs --- .github/workflows/rust.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cdc2fe46f..6d8ccf2b8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -39,11 +39,6 @@ jobs: os: [ubuntu-18.04, windows-2019, macos-10.15] steps: - uses: actions/checkout@230611dbd0eb52da1e1f4f7bc8bb0c3a339fc8b7 - # Temporary fork until https://github.com/actions-rs/toolchain/pull/209 is merged - - uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 - with: - profile: minimal - override: true - name: Report cargo version run: cargo --version - name: Report rustc version