Skip to content

Commit

Permalink
Update rustfmt to Google (project-oak#4900)
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsbinder authored Mar 14, 2024
1 parent 3e4e352 commit 8e812eb
Show file tree
Hide file tree
Showing 250 changed files with 4,349 additions and 6,069 deletions.
31 changes: 27 additions & 4 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
# Configures Rust code formatting for Oak.
# See https://github.com/rust-lang/rustfmt/blob/master/Configurations.md
comment_width = 100
format_code_in_doc_comments = true
#
# Google rustfmt configuration.

edition = "2021"
version = "Two"

# The "Default" setting has a heuristic which splits lines too aggresively.
# We are willing to revisit this setting in future versions of rustfmt.
# Bugs:
# * https://github.com/rust-lang/rustfmt/issues/3119
# * https://github.com/rust-lang/rustfmt/issues/3120
use_small_heuristics = "Max"
newline_style = "Unix"
wrap_comments = true
format_generated_files = false

#
# Overrides from Oak.
#
# These are the defaults, repeated to avoid reformatting when they change:
#
comment_width = 80
max_width = 100
#
# Non-default values from here:
#
format_code_in_doc_comments = true
normalize_doc_attributes = true
wrap_comments = true
imports_granularity = "Crate"
imports_layout = "mixed"
edition = "2021"
group_imports = "StdExternalCrate"
8 changes: 3 additions & 5 deletions enclave_apps/key_xor_test_app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use oak_restricted_kernel_sdk::{
entrypoint,
};

// Continuously reads single bytes from the communication channel, XORs them with a byte from the
// derived key and sends them back.
// Continuously reads single bytes from the communication channel, XORs them
// with a byte from the derived key and sends them back.
#[entrypoint]
fn run_server() -> ! {
let mut key = [0u8; 32];
Expand All @@ -36,9 +36,7 @@ fn run_server() -> ! {
let mut iter = key.iter().cycle();
let mut channel = FileDescriptorChannel::default();
loop {
channel
.read_exact(&mut byte[..])
.expect("couldn't read bytes");
channel.read_exact(&mut byte[..]).expect("couldn't read bytes");
byte[0] ^= iter.next().expect("iterator ran out");
channel.write_all(&byte[..]).expect("couldn't write bytes");
}
Expand Down
8 changes: 2 additions & 6 deletions enclave_apps/oak_echo_enclave_app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ fn start_echo_server() -> ! {

let service = oak_echo_service::EchoService { evidence_provider };
let server = oak_echo_service::proto::oak::echo::EchoServer::new(service);
start_blocking_server(
Box::<FileDescriptorChannel>::default(),
server,
&mut invocation_stats,
)
.expect("server encountered an unrecoverable error");
start_blocking_server(Box::<FileDescriptorChannel>::default(), server, &mut invocation_stats)
.expect("server encountered an unrecoverable error");
}
12 changes: 4 additions & 8 deletions enclave_apps/oak_functions_enclave_app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use oak_restricted_kernel_sdk::{
fn main() -> ! {
#[cfg(feature = "deny_sensitive_logging")]
{
// Only log warnings and errors to reduce the risk of accidentally leaking execution
// information through debug logs.
// Only log warnings and errors to reduce the risk of accidentally leaking
// execution information through debug logs.
log::set_max_level(log::LevelFilter::Warn);
}
let mut invocation_stats = StaticSampleStore::<1000>::new().unwrap();
Expand All @@ -50,10 +50,6 @@ fn main() -> ! {
);
let server =
oak_functions_enclave_service::proto::oak::functions::OakFunctionsServer::new(service);
start_blocking_server(
Box::<FileDescriptorChannel>::default(),
server,
&mut invocation_stats,
)
.expect("server encountered an unrecoverable error");
start_blocking_server(Box::<FileDescriptorChannel>::default(), server, &mut invocation_stats)
.expect("server encountered an unrecoverable error");
}
Loading

0 comments on commit 8e812eb

Please sign in to comment.