Skip to content

Commit 0f0cfe5

Browse files
authored
chore(turbopack): Add comment_width = 100 to rustfmt.toml (#68541)
The default `comment_width` is `80`, which is a mismatch with the `max_width` of `100`. Previous discussion: https://vercel.slack.com/archives/C03EWR7LGEN/p1716332166435329 Ran `cargo fmt` after making this change. It seems to mostly just fix bullet points. Other places it likely can't differentiate between wrapped text and intentional newlines. I don't plan on going through and manually re-wrapping of all of the comments, but over time this should get fixed as people change comments.
1 parent 9dc685e commit 0f0cfe5

File tree

25 files changed

+101
-127
lines changed

25 files changed

+101
-127
lines changed

.rustfmt.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
max_width = 100
22

3+
comment_width = 100
4+
wrap_comments = true
5+
36
tab_spaces = 4
47
hard_tabs = false
58

69
format_strings = true
710
use_field_init_shorthand = true
8-
wrap_comments = true
911

1012
imports_granularity = "Crate"
1113
group_imports = "StdExternalCrate"

crates/next-api/src/dynamic_imports.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ pub(crate) async fn collect_evaluated_chunk_group(
109109
/// If an import is specified as dynamic, next.js does few things:
110110
/// - Runs a next_dynamic [transform to the source file](https://github.com/vercel/next.js/blob/ae1b89984d26b2af3658001fa19a19e1e77c312d/packages/next-swc/crates/next-transform-dynamic/src/lib.rs#L22)
111111
/// - This transform will [inject `loadableGenerated` property](https://github.com/vercel/next.js/blob/ae1b89984d26b2af3658001fa19a19e1e77c312d/packages/next-swc/crates/next-transform-dynamic/tests/fixture/wrapped-import/output-webpack-dev.js#L5),
112-
/// which contains the list of the import ids in the form of `${origin} ->
113-
/// ${imported}`.
114-
/// - Emits `react-loadable-manifest.json` which contains the mapping of the
115-
/// import ids to the chunk ids.
112+
/// which contains the list of the import ids in the form of `${origin} -> ${imported}`.
113+
/// - Emits `react-loadable-manifest.json` which contains the mapping of the import ids to the chunk
114+
/// ids.
116115
/// - Webpack: [implementation](https://github.com/vercel/next.js/blob/ae1b89984d26b2af3658001fa19a19e1e77c312d/packages/next/src/build/webpack/plugins/react-loadable-plugin.ts)
117116
/// - Turbopack: [implementation 1](https://github.com/vercel/next.js/pull/56389/files#diff-3cac9d9bfe73e0619e6407f21f6fe652da0719d0ec9074ff813ad3e416d0eb1a),
118117
/// [implementation 2](https://github.com/vercel/next.js/pull/56389/files#diff-791951bbe1fa09bcbad9be9173412d0848168f7d658758f11b6e8888a021552c),
@@ -124,17 +123,16 @@ pub(crate) async fn collect_evaluated_chunk_group(
124123
/// - Server embeds those into __NEXT_DATA__ and [send to the client.](https://github.com/vercel/next.js/blob/ad42b610c25b72561ad367b82b1c7383fd2a5dd2/packages/next/src/server/render.tsx#L1453)
125124
/// - When client boots up, pass it to the [client preload](https://github.com/vercel/next.js/blob/ad42b610c25b72561ad367b82b1c7383fd2a5dd2/packages/next/src/client/index.tsx#L943)
126125
/// - Loadable runtime [injects preload fn](https://github.com/vercel/next.js/blob/ad42b610c25b72561ad367b82b1c7383fd2a5dd2/packages/next/src/shared/lib/loadable.shared-runtime.tsx#L281)
127-
/// to wait until all the dynamic components are being loaded, this ensures
128-
/// hydration mismatch won't occur
126+
/// to wait until all the dynamic components are being loaded, this ensures hydration mismatch
127+
/// won't occur
129128
#[tracing::instrument(level = Level::INFO, name = "collecting next/dynamic imports", skip_all)]
130129
pub(crate) async fn collect_next_dynamic_imports(
131130
server_entries: impl IntoIterator<Item = Vc<Box<dyn Module>>>,
132131
client_asset_context: Vc<Box<dyn AssetContext>>,
133132
) -> Result<IndexMap<Vc<Box<dyn Module>>, DynamicImportedModules>> {
134133
// Traverse referenced modules graph, collect all of the dynamic imports:
135134
// - Read the Program AST of the Module, this is the origin (A)
136-
// - If there's `dynamic(import(B))`, then B is the module that is being
137-
// imported
135+
// - If there's `dynamic(import(B))`, then B is the module that is being imported
138136
// Returned import mappings are in the form of
139137
// (Module<A>, Vec<(B, Module<B>)>) (where B is the raw import source string,
140138
// and Module<B> is the actual resolved Module)

crates/next-core/src/next_app/app_route_entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use crate::{
2222
/// Computes the entry for a Next.js app route.
2323
/// # Arguments
2424
///
25-
/// * `original_segment_config` - A next segment config to be specified
26-
/// explicitly for the given source.
25+
/// * `original_segment_config` - A next segment config to be specified explicitly for the given
26+
/// source.
2727
/// For some cases `source` may not be the original but the handler (dynamic
2828
/// metadata) which will lose segment config.
2929
#[turbo_tasks::function]

crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use turbopack_core::{
99
use turbopack_ecmascript::chunk::EcmascriptChunkPlaceable;
1010

1111
/// An [EcmascriptClientReferenceModule] is a marker module, used by the
12-
/// [super::ecmascript_client_reference_proxy_module::EcmascriptClientReferenceProxyModule] to indicate which client reference
13-
/// should appear in the client reference manifest.
12+
/// [super::ecmascript_client_reference_proxy_module::EcmascriptClientReferenceProxyModule] to
13+
/// indicate which client reference should appear in the client reference manifest.
1414
#[turbo_tasks::value]
1515
pub struct EcmascriptClientReferenceModule {
1616
pub server_ident: Vc<AssetIdent>,
@@ -24,8 +24,8 @@ impl EcmascriptClientReferenceModule {
2424
///
2525
/// # Arguments
2626
///
27-
/// * `server_ident` - The identifier of the server module, used to identify
28-
/// the client reference.
27+
/// * `server_ident` - The identifier of the server module, used to identify the client
28+
/// reference.
2929
/// * `client_module` - The client module.
3030
/// * `ssr_module` - The SSR module.
3131
#[turbo_tasks::function]

crates/next-core/src/next_font/local/font_fallback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ fn calc_average_width(font: &mut Font<DynamicFontTableProvider>) -> Option<f32>
145145
/// font file:
146146
/// - Most of the text will have normal weight, use the one closest to 400
147147
/// - Most of the text will have normal style, prefer normal over italic
148-
/// - If two font files have the same distance from normal weight, the thinner
149-
/// one will most likely be the bulk of the text
148+
/// - If two font files have the same distance from normal weight, the thinner one will most likely
149+
/// be the bulk of the text
150150
fn pick_font_for_fallback_generation(
151151
font_descriptors: &FontDescriptors,
152152
) -> Result<&FontDescriptor> {

crates/next-core/src/next_font/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ pub(crate) enum FontFamilyType {
4343
}
4444

4545
/// Returns a uniquely scoped version of the font family, e.g.`__Roboto_c123b8`
46-
/// * `ty` - Whether to generate a scoped classname for the main font or its
47-
/// fallback equivalent, e.g. `__Roboto_Fallback_c123b8`
46+
/// * `ty` - Whether to generate a scoped classname for the main font or its fallback equivalent,
47+
/// e.g. `__Roboto_Fallback_c123b8`
4848
/// * `font_family_name` - The font name to scope, e.g. `Roboto`
4949
/// * `request_hash` - The hash value of the font request
5050
#[turbo_tasks::function]

crates/next-custom-transforms/src/transforms/dynamic.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ pub enum NextDynamicMode {
6666
/// the React Loadable Webpack plugin.
6767
Webpack,
6868
/// In Turbopack mode:
69-
/// * in development, each `dynamic()` call will generate a key containing
70-
/// both the imported module id and the chunks it needs. This removes the
71-
/// need for a manifest entry
72-
/// * during build, each `dynamic()` call will import the module through the
73-
/// given transition, which takes care of adding an entry to the manifest
74-
/// and returning an asset that exports the entry's key.
69+
/// * in development, each `dynamic()` call will generate a key containing both the imported
70+
/// module id and the chunks it needs. This removes the need for a manifest entry
71+
/// * during build, each `dynamic()` call will import the module through the given transition,
72+
/// which takes care of adding an entry to the manifest and returning an asset that exports
73+
/// the entry's key.
7574
Turbopack { dynamic_transition_name: String },
7675
}
7776

crates/next-custom-transforms/src/transforms/strip_page_exports.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ impl PageMode {
5151
}
5252

5353
/// A transform that either:
54-
/// * strips Next.js data exports (getServerSideProps, getStaticProps,
55-
/// getStaticPaths); or
54+
/// * strips Next.js data exports (getServerSideProps, getStaticProps, getStaticPaths); or
5655
/// * strips the default export.
5756
///
5857
/// Note: This transform requires running `resolver` **before** running it.

turbopack/crates/turbo-tasks-fs/src/glob.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ enum GlobPart {
3535
// - file*.js = File(file), AnyFile, File(.js)
3636
// - dir/file.js = File(dir), PathSeparator, File(file.js)
3737
// - **/*.js = AnyDirectories, PathSeparator, AnyFile, File(.js)
38-
// - {a/**,*}/file = Alternatives([File(a), PathSeparator, AnyDirectories],
39-
// [AnyFile]), PathSeparator, File(file)
38+
// - {a/**,*}/file = Alternatives([File(a), PathSeparator, AnyDirectories], [AnyFile]),
39+
// PathSeparator, File(file)
4040

4141
// Note: a/**/b does match a/b, so we need some special logic about path
4242
// separators

turbopack/crates/turbo-tasks-fs/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,9 @@ impl DiskFileSystem {
282282
///
283283
/// * `name` - Name of the filesystem.
284284
/// * `root` - Path to the given filesystem's root.
285-
/// * `ignored_subpaths` - A list of subpaths that should not trigger
286-
/// invalidation. This should be a full path, since it is possible that
287-
/// root & project dir is different and requires to ignore specific
288-
/// subpaths from each.
285+
/// * `ignored_subpaths` - A list of subpaths that should not trigger invalidation. This should
286+
/// be a full path, since it is possible that root & project dir is different and requires to
287+
/// ignore specific subpaths from each.
289288
#[turbo_tasks::function]
290289
pub async fn new(name: RcStr, root: RcStr, ignored_subpaths: Vec<RcStr>) -> Result<Vc<Self>> {
291290
mark_stateful();
@@ -1043,8 +1042,7 @@ impl FileSystemPath {
10431042
///
10441043
/// * [`None`], if there is no file name;
10451044
/// * The entire file name if there is no embedded `.`;
1046-
/// * The entire file name if the file name begins with `.` and has no other
1047-
/// `.`s within;
1045+
/// * The entire file name if the file name begins with `.` and has no other `.`s within;
10481046
/// * Otherwise, the portion of the file name before the final `.`
10491047
#[turbo_tasks::function]
10501048
pub async fn file_stem(self: Vc<Self>) -> Result<Vc<Option<RcStr>>> {

0 commit comments

Comments
 (0)