Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to Rust 1.65 #1441

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ commands:
jobs:
checks:
docker:
- image: cimg/rust:1.64.0
- image: cimg/rust:1.65.0
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
Expand All @@ -176,7 +176,7 @@ jobs:

build-and-test:
docker:
- image: cimg/rust:1.64.0
- image: cimg/rust:1.65.0
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.64-buster as builder
FROM rust:1.65-buster as builder
WORKDIR /app
ADD . /app
ENV PATH=$PATH:/root/.cargo/bin
Expand Down
2 changes: 1 addition & 1 deletion syncserver/src/db/tests/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn postbso(
) -> params::PostCollectionBso {
params::PostCollectionBso {
id: bid.to_owned(),
payload: payload.map(&str::to_owned),
payload: payload.map(str::to_owned),
sortindex,
ttl,
}
Expand Down
2 changes: 1 addition & 1 deletion syncserver/src/server/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn create_hawk_header(method: &str, port: u16, path: &str) -> String {
&SECRETS.master_secret,
)
.expect("hkdf_expand_32 failed in create_hawk_header");
let token_secret = base64::encode_config(&token_secret, base64::URL_SAFE);
let token_secret = base64::encode_config(token_secret, base64::URL_SAFE);
let request = RequestBuilder::new(method, host, port, path).request();
let credentials = Credentials {
id,
Expand Down
2 changes: 1 addition & 1 deletion syncserver/src/tokenserver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl From<&RequestHead> for LogItems {
items.insert_if_not_empty("ua.os.family", metrics_os);
items.insert_if_not_empty("ua.browser.family", metrics_browser);
items.insert_if_not_empty("ua.name", ua_result.name);
items.insert_if_not_empty("ua.os.ver", &ua_result.os_version.to_owned());
items.insert_if_not_empty("ua.os.ver", &ua_result.os_version);
items.insert_if_not_empty("ua.browser.ver", ua_result.version);
items.insert_if_not_empty("ua", ua_result.version);
}
Expand Down
2 changes: 1 addition & 1 deletion syncserver/src/web/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl HawkPayload {
&secrets.master_secret,
)
.map_err(|e| ApiErrorKind::Internal(format!("HKDF Error: {:?}", e)))?;
let token_secret = base64::encode_config(&token_secret, base64::URL_SAFE);
let token_secret = base64::encode_config(token_secret, base64::URL_SAFE);

let request = RequestBuilder::new(method, host, port, path).request();

Expand Down
2 changes: 1 addition & 1 deletion syncserver/src/web/extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ mod tests {
&SECRETS.master_secret,
)
.unwrap();
let token_secret = base64::encode_config(&token_secret, base64::URL_SAFE);
let token_secret = base64::encode_config(token_secret, base64::URL_SAFE);
let credentials = Credentials {
id,
key: Key::new(token_secret.as_bytes(), hawk::DigestAlgorithm::Sha256).unwrap(),
Expand Down
6 changes: 3 additions & 3 deletions tokenserver-common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct TokenserverError {
/// For internal use only. Used to report any additional context behind an error to
/// distinguish between similar errors in Sentry.
pub context: String,
pub backtrace: Backtrace,
pub backtrace: Box<Backtrace>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result_large_err clippy lint was saying that TokenserverError was too large. Boxing the backtrace field resolved the issue, but I don't quite understand why. This is the definition of Backtrace:

pub struct Backtrace {
    // Frames here are listed from top-to-bottom of the stack
    frames: Vec<BacktraceFrame>,
    // The index we believe is the actual start of the backtrace, omitting
    // frames like `Backtrace::new` and `backtrace::trace`.
    actual_start_index: usize,
}

Vecs are stored on the heap and usizes are trivially small, so 🤷🏻 it doesn't seem that big to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because its large-error-threshold is quite small, defaulting to 128.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I should have read through the rest of the lint's documentation

pub token_type: TokenType,
}

Expand Down Expand Up @@ -59,7 +59,7 @@ impl Default for TokenserverError {
description: "Unauthorized".to_owned(),
http_status: StatusCode::UNAUTHORIZED,
context: "Unauthorized".to_owned(),
backtrace: Backtrace::new(),
backtrace: Box::new(Backtrace::new()),
token_type: TokenType::Oauth,
}
}
Expand Down Expand Up @@ -254,7 +254,7 @@ impl From<DbError> for TokenserverError {
TokenserverError {
description: db_error.to_string(),
context: db_error.to_string(),
backtrace: db_error.backtrace,
backtrace: Box::new(db_error.backtrace),
http_status: if db_error.status.is_server_error() {
// Use the status code from the DbError if it already suggests an internal error;
// it might be more specific than `StatusCode::SERVICE_UNAVAILABLE`
Expand Down