Skip to content

Change edition and style_edition to 2024 in rustfmt.toml#2050

Open
ImplOfAnImpl wants to merge 1 commit intoupdate_rust_editionfrom
update_style_edition_in_rustfmt_config
Open

Change edition and style_edition to 2024 in rustfmt.toml#2050
ImplOfAnImpl wants to merge 1 commit intoupdate_rust_editionfrom
update_style_edition_in_rustfmt_config

Conversation

@ImplOfAnImpl
Copy link
Copy Markdown
Contributor

To be precise, I removed style_edition completely, in which case it defaults to edition.

Most of the changes come from reordering of imports. These are not super useful, but there is no option to keep imports as they were, while having all other 2024 changes.

There are a few places where the code became a bit nicer-looking, e.g.

let mut chainstate_block_ids = vec![*tf
    .make_block_builder()
    .add_transaction(transaction.clone())
    .build_and_process(&mut rng)
    .unwrap()
    .unwrap()
    .block_id()];

became

let mut chainstate_block_ids = vec![
    *tf.make_block_builder()
        .add_transaction(transaction.clone())
        .build_and_process(&mut rng)
        .unwrap()
        .unwrap()
        .block_id(),
];

and

Ok(Json(json!(block
    .block
    .block_reward()
    .outputs()
    .iter()
    .map(|out| txoutput_to_json(out, &state.chain_config, &TokenDecimals::Single(None)))
    .collect::<Vec<_>>())))

became

Ok(Json(json!(
    block
        .block
        .block_reward()
        .outputs()
        .iter()
        .map(|out| txoutput_to_json(out, &state.chain_config, &TokenDecimals::Single(None)))
        .collect::<Vec<_>>()
)))

In general, it seems to format macro calls better now.
Also, they fixed a bug where a long string literal would cause the entire expression to not be formatted at all. (Though I'm not sure if it applies to all cases, e.g. in the past having an extra long string could break rustfmt completely, so that it wouldn't format anything in the whole file. No idea if this was fixed or not.)

But there are also places where it became uglier, e.g.

async fn get_last_transaction_global_index(&self)
    -> Result<Option<u64>, ApiServerStorageError>;

became

async fn get_last_transaction_global_index(&self)
-> Result<Option<u64>, ApiServerStorageError>;

But overall IMO the code looks better, so I'd say let's upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant