diff --git a/Configurations.md b/Configurations.md index bd67caef09f..46d94eb1474 100644 --- a/Configurations.md +++ b/Configurations.md @@ -506,7 +506,7 @@ trait Lorem { dolor: Dolor, sit: Sit, amet: Amet, - consectetur: onsectetur, + consectetur: Consectetur, adipiscing: Adipiscing, elit: Elit, ); @@ -516,7 +516,7 @@ trait Lorem { dolor: Dolor, sit: Sit, amet: Amet, - consectetur: onsectetur, + consectetur: Consectetur, adipiscing: Adipiscing, elit: Elit, ) { @@ -569,7 +569,7 @@ trait Lorem { dolor: Dolor, sit: Sit, amet: Amet, - consectetur: onsectetur, + consectetur: Consectetur, adipiscing: Adipiscing, elit: Elit, ) { @@ -598,7 +598,7 @@ trait Lorem { dolor: Dolor, sit: Sit, amet: Amet, - consectetur: onsectetur, + consectetur: Consectetur, adipiscing: Adipiscing, elit: Elit); @@ -606,7 +606,7 @@ trait Lorem { dolor: Dolor, sit: Sit, amet: Amet, - consectetur: onsectetur, + consectetur: Consectetur, adipiscing: Adipiscing, elit: Elit) { // body diff --git a/Design.md b/Design.md index 43caa7b81f8..15b11d82844 100644 --- a/Design.md +++ b/Design.md @@ -151,7 +151,7 @@ for its configuration. Our visitor keeps track of the desired current indent due to blocks ( `block_indent`). Each `visit_*` method reformats code according to this indent, `config.comment_width()` and `config.max_width()`. Most reformatting done in the -`visit_*` methods is a bit hackey and is meant to be temporary until it can be +`visit_*` methods is a bit hacky and is meant to be temporary until it can be done properly. There are a bunch of methods called `rewrite_*`. There do the bulk of the diff --git a/README.md b/README.md index 4942c537437..2041a508074 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ are included as out of line modules from `src/lib.rs`. If `rustfmt` successfully reformatted the code it will exit with `0` exit status. Exit status `1` signals some unexpected error, like an unknown option or a failure to read a file. Exit status `2` is returned if there are syntax errors -in the input files. `rustfmt` can't format syntatically invalid code. Finally, +in the input files. `rustfmt` can't format syntactically invalid code. Finally, exit status `3` is returned if there are some issues which can't be resolved automatically. For example, if you have a very long comment line `rustfmt` doesn't split it. Instead it prints a warning and exits with `3`. @@ -209,7 +209,7 @@ options covering different styles. File an issue, or even better, submit a PR. * When you run rustfmt, place a file named `rustfmt.toml` or `.rustfmt.toml` in target file directory or its parents to override the default settings of rustfmt. You can generate a file containing the default configuration with - `rustfm --dump-default-config rustfmt.toml` and customize as needed. + `rustfmt --dump-default-config rustfmt.toml` and customize as needed. * After successful compilation, a `rustfmt` executable can be found in the target directory. * If you're having issues compiling Rustfmt (or compile errors when trying to diff --git a/src/chains.rs b/src/chains.rs index 20e0be36fe4..e02cef8e38e 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -152,8 +152,8 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) - }).collect::>>()?; // Total of all items excluding the last. - let extend_last_subexr = last_line_extendable(&parent_rewrite) && rewrites.is_empty(); - let almost_total = if extend_last_subexr { + let extend_last_subexpr = last_line_extendable(&parent_rewrite) && rewrites.is_empty(); + let almost_total = if extend_last_subexpr { last_line_width(&parent_rewrite) } else { rewrites.iter().fold(0, |a, b| a + b.len()) + parent_rewrite.len() @@ -195,7 +195,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) - // In particular, overflowing is effective when the last child is a method with a multi-lined // block-like argument (e.g. closure): // ``` - // parent.child1.chlid2.last_child(|a, b, c| { + // parent.child1.child2.last_child(|a, b, c| { // let x = foo(a, b, c); // let y = bar(a, b, c); // @@ -208,14 +208,14 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) - // `rewrite_last` rewrites the last child on its own line. We use a closure here instead of // directly calling `rewrite_chain_subexpr()` to avoid exponential blowup. let rewrite_last = || rewrite_chain_subexpr(last_subexpr, total_span, context, last_shape); - let (last_subexpr_str, fits_single_line) = if all_in_one_line || extend_last_subexr { + let (last_subexpr_str, fits_single_line) = if all_in_one_line || extend_last_subexpr { // First we try to 'overflow' the last child and see if it looks better than using // vertical layout. parent_shape.offset_left(almost_total).map(|shape| { if let Some(rw) = rewrite_chain_subexpr(last_subexpr, total_span, context, shape) { // We allow overflowing here only if both of the following conditions match: // 1. The entire chain fits in a single line expect the last child. - // 2. `last_chlid_str.lines().count() >= 5`. + // 2. `last_child_str.lines().count() >= 5`. let line_count = rw.lines().count(); let fits_single_line = almost_total + first_line_width(&rw) <= one_line_budget; if fits_single_line && line_count >= 5 { diff --git a/src/comment.rs b/src/comment.rs index 5112c333dee..8a34e3cbe66 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -170,7 +170,7 @@ pub fn combine_strs_with_missing_comments( // We have a missing comment between the first expression and the second expression. // Peek the the original source code and find out whether there is a newline between the first - // expression and the second expression or the missing comment. We will preserve the orginal + // expression and the second expression or the missing comment. We will preserve the original // layout whenever possible. let original_snippet = context.snippet(span); let prefer_same_line = if let Some(pos) = original_snippet.chars().position(|c| c == '/') { diff --git a/src/config.rs b/src/config.rs index 18969908c86..85008f2915a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -235,7 +235,7 @@ macro_rules! create_config { // Just like the Config struct but with each property wrapped // as Option. This is used to parse a rustfmt.toml that doesn't - // specity all properties of `Config`. + // specify all properties of `Config`. // We first parse into `PartialConfig`, then create a default `Config` // and overwrite the properties with corresponding values from `PartialConfig`. #[derive(Deserialize, Serialize, Clone)] diff --git a/src/expr.rs b/src/expr.rs index 212f05b52b8..9855c7e32d0 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -170,7 +170,7 @@ pub fn format_expr( ast::ExprKind::TupField(..) | ast::ExprKind::MethodCall(..) => rewrite_chain(expr, context, shape), ast::ExprKind::Mac(ref mac) => { - // Failure to rewrite a marco should not imply failure to + // Failure to rewrite a macro should not imply failure to // rewrite the expression. rewrite_macro(mac, None, context, shape, MacroPosition::Expression) .or_else(|| Some(context.snippet(expr.span))) diff --git a/src/issues.rs b/src/issues.rs index b81f902d59f..be30ff2d86e 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Objects for seeking through a char stream for occurences of TODO and FIXME. +// Objects for seeking through a char stream for occurrences of TODO and FIXME. // Depending on the loaded configuration, may also check that these have an // associated issue number. diff --git a/src/lists.rs b/src/lists.rs index bb75c9c60ad..73712033f6e 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -572,7 +572,7 @@ where let comment_end = match self.inner.peek() { Some(..) => { let mut block_open_index = post_snippet.find("/*"); - // check if it realy is a block comment (and not //*) + // check if it really is a block comment (and not //*) if let Some(i) = block_open_index { if i > 0 && &post_snippet[i - 1..i] == "/" { block_open_index = None; diff --git a/src/macros.rs b/src/macros.rs index 470f1e84fd8..9d665c4a0b2 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -15,7 +15,7 @@ // foo!( x, y, z ). The token x may represent an identifier in the code, but we // interpreted as an expression. // Macro uses which are not-list like, such as bar!(key => val), will not be -// reformated. +// reformatted. // List-like invocations with parentheses will be formatted as function calls, // and those with brackets will be formatted as array literals. diff --git a/src/patterns.rs b/src/patterns.rs index 4df36b87e4d..e4b24bafe2e 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -118,8 +118,8 @@ impl Rewrite for Pat { }; Some(result) } - PatKind::Struct(ref path, ref fields, elipses) => { - rewrite_struct_pat(path, fields, elipses, self.span, context, shape) + PatKind::Struct(ref path, ref fields, ellipsis) => { + rewrite_struct_pat(path, fields, ellipsis, self.span, context, shape) } // FIXME(#819) format pattern macros. PatKind::Mac(..) => Some(context.snippet(self.span)), @@ -130,7 +130,7 @@ impl Rewrite for Pat { fn rewrite_struct_pat( path: &ast::Path, fields: &[codemap::Spanned], - elipses: bool, + ellipsis: bool, span: Span, context: &RewriteContext, shape: Shape, @@ -139,15 +139,15 @@ fn rewrite_struct_pat( let path_shape = shape.sub_width(2)?; let path_str = rewrite_path(context, PathContext::Expr, None, path, path_shape)?; - if fields.is_empty() && !elipses { + if fields.is_empty() && !ellipsis { return Some(format!("{} {{}}", path_str)); } - let (elipses_str, terminator) = if elipses { (", ..", "..") } else { ("", "}") }; + let (ellipsis_str, terminator) = if ellipsis { (", ..", "..") } else { ("", "}") }; // 3 = ` { `, 2 = ` }`. let (h_shape, v_shape) = - struct_lit_shape(shape, context, path_str.len() + 3, elipses_str.len() + 2)?; + struct_lit_shape(shape, context, path_str.len() + 3, ellipsis_str.len() + 2)?; let items = itemize_list( context.codemap, @@ -169,7 +169,7 @@ fn rewrite_struct_pat( let mut fields_str = write_list(&item_vec, &fmt)?; let one_line_width = h_shape.map_or(0, |shape| shape.width); - if elipses { + if ellipsis { if fields_str.contains('\n') || fields_str.len() > one_line_width { // Add a missing trailing comma. if fmt.trailing_separator == SeparatorTactic::Never { @@ -180,7 +180,7 @@ fn rewrite_struct_pat( fields_str.push_str(".."); } else { if !fields_str.is_empty() { - // there are preceeding struct fields being matched on + // there are preceding struct fields being matched on if fmt.tactic == DefinitiveListTactic::Vertical { // if the tactic is Vertical, write_list already added a trailing , fields_str.push_str(" "); diff --git a/src/vertical.rs b/src/vertical.rs index f5636672422..3da31cb0aa3 100644 --- a/src/vertical.rs +++ b/src/vertical.rs @@ -183,7 +183,7 @@ pub fn rewrite_with_alignment( } } -fn struct_field_preix_max_min_width( +fn struct_field_prefix_max_min_width( context: &RewriteContext, fields: &[T], shape: Shape, @@ -219,7 +219,7 @@ fn rewrite_aligned_items_inner( // 1 = "," let item_shape = Shape::indented(item_indent, context.config).sub_width(1)?; let (mut field_prefix_max_width, field_prefix_min_width) = - struct_field_preix_max_min_width(context, fields, item_shape); + struct_field_prefix_max_min_width(context, fields, item_shape); let max_diff = field_prefix_max_width .checked_sub(field_prefix_min_width) .unwrap_or(0); diff --git a/src/visitor.rs b/src/visitor.rs index 7d75a1dd3bb..975d2cdf503 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -295,7 +295,7 @@ impl<'a> FmtVisitor<'a> { // complex in the module case. It is complex because the module could be // in a separate file and there might be attributes in both files, but // the AST lumps them all together. - let filterd_attrs; + let filtered_attrs; let mut attrs = &item.attrs; match item.node { ast::ItemKind::Mod(ref m) => { @@ -314,7 +314,7 @@ impl<'a> FmtVisitor<'a> { } else { // Module is not inline and should not be skipped. We want // to process only the attributes in the current file. - filterd_attrs = item.attrs + filtered_attrs = item.attrs .iter() .filter_map(|a| { let attr_file = self.codemap.lookup_char_pos(a.span.lo()).file; @@ -327,8 +327,8 @@ impl<'a> FmtVisitor<'a> { .collect::>(); // Assert because if we should skip it should be caught by // the above case. - assert!(!self.visit_attrs(&filterd_attrs, ast::AttrStyle::Outer)); - attrs = &filterd_attrs; + assert!(!self.visit_attrs(&filtered_attrs, ast::AttrStyle::Outer)); + attrs = &filtered_attrs; } } _ => if self.visit_attrs(&item.attrs, ast::AttrStyle::Outer) { diff --git a/tests/source/configs-struct_field_align_threshold-20.rs b/tests/source/configs-struct_field_align_threshold-20.rs index 3f37d72f3c6..e68340b027d 100644 --- a/tests/source/configs-struct_field_align_threshold-20.rs +++ b/tests/source/configs-struct_field_align_threshold-20.rs @@ -159,7 +159,7 @@ pub struct State ()> { now: F } pub struct State { now: F } -struct Palette { /// A map of indizes in the palette to a count of pixels in approximately that color +struct Palette { /// A map of indices in the palette to a count of pixels in approximately that color foo: i32} // Splitting a single line comment into a block previously had a misalignment diff --git a/tests/source/fn-simple.rs b/tests/source/fn-simple.rs index ff08b04c704..f1ce503ab0a 100644 --- a/tests/source/fn-simple.rs +++ b/tests/source/fn-simple.rs @@ -7,7 +7,7 @@ fn op(x: Typ, key : &[u8], upd : Box) -> (memcache::S "cool"} -fn weird_comment(/* /*/ double level */ comment */ x: Hello /*/*/* tripple, even */*/*/, +fn weird_comment(/* /*/ double level */ comment */ x: Hello /*/*/* triple, even */*/*/, // Does this work? y: World ) { diff --git a/tests/source/fn_args_density-vertical.rs b/tests/source/fn_args_density-vertical.rs index 7dd4dcbfc4d..b61c337dfb9 100644 --- a/tests/source/fn_args_density-vertical.rs +++ b/tests/source/fn_args_density-vertical.rs @@ -1,6 +1,6 @@ // rustfmt-fn_args_density: Vertical -// Empty list shoul stay on one line. +// Empty list should stay on one line. fn do_bar( ) -> u8 { diff --git a/tests/source/issue-1049.rs b/tests/source/issue-1049.rs index 03f10a1ba38..bcfba41e768 100644 --- a/tests/source/issue-1049.rs +++ b/tests/source/issue-1049.rs @@ -10,7 +10,7 @@ impl Handle { } } -// Long function without return type that should not be reformated. +// Long function without return type that should not be reformatted. fn veeeeeeeeeeeeeeeeeeeeery_long_name(a: FirstTypeeeeeeeeee, b: SecondTypeeeeeeeeeeeeeeeeeeeeeee) {} fn veeeeeeeeeeeeeeeeeeeeeery_long_name(a: FirstTypeeeeeeeeee, b: SecondTypeeeeeeeeeeeeeeeeeeeeeee) {} diff --git a/tests/source/issue-1468.rs b/tests/source/issue-1468.rs index 1b45aa5d616..4d0d4f0eb98 100644 --- a/tests/source/issue-1468.rs +++ b/tests/source/issue-1468.rs @@ -2,7 +2,7 @@ fn issue1468() { euc_jp_decoder_functions!({ let trail_minus_offset = byte.wrapping_sub(0xA1); // Fast-track Hiragana (60% according to Lunde) -// and Katakana (10% acconding to Lunde). +// and Katakana (10% according to Lunde). if jis0208_lead_minus_offset == 0x03 && trail_minus_offset < 0x53 { // Hiragana diff --git a/tests/source/match.rs b/tests/source/match.rs index 48a710e6f06..19d30b0dd00 100644 --- a/tests/source/match.rs +++ b/tests/source/match.rs @@ -193,7 +193,7 @@ fn issue355() { nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => println!("a", b), // Rewrite splits macro oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => vec!(1, 2), - // Macro support fails to recognise this macro as splitable + // Macro support fails to recognise this macro as splittable // We push the whole expr to a new line, TODO split this macro as well pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp => vec!(3; 4), // q, r and s: Rewrite splits match arm diff --git a/tests/source/structs.rs b/tests/source/structs.rs index b782c98635a..e63de8ecdb4 100644 --- a/tests/source/structs.rs +++ b/tests/source/structs.rs @@ -132,7 +132,7 @@ pub struct State ()> { now: F } pub struct State { now: F } -struct Palette { /// A map of indizes in the palette to a count of pixels in approximately that color +struct Palette { /// A map of indices in the palette to a count of pixels in approximately that color foo: i32} // Splitting a single line comment into a block previously had a misalignment diff --git a/tests/source/unions.rs b/tests/source/unions.rs index 107be79873c..fc2908e2d9e 100644 --- a/tests/source/unions.rs +++ b/tests/source/unions.rs @@ -93,7 +93,7 @@ pub union State ()> { now: F } pub union State { now: F } -union Palette { /// A map of indizes in the palette to a count of pixels in approximately that color +union Palette { /// A map of indices in the palette to a count of pixels in approximately that color foo: i32} // Splitting a single line comment into a block previously had a misalignment diff --git a/tests/target/configs-struct_field_align_threshold-20.rs b/tests/target/configs-struct_field_align_threshold-20.rs index da933a75c7d..7d8200a0146 100644 --- a/tests/target/configs-struct_field_align_threshold-20.rs +++ b/tests/target/configs-struct_field_align_threshold-20.rs @@ -161,7 +161,7 @@ pub struct State { } struct Palette { - /// A map of indizes in the palette to a count of pixels in approximately + /// A map of indices in the palette to a count of pixels in approximately /// that color foo: i32, } diff --git a/tests/target/fn-simple.rs b/tests/target/fn-simple.rs index 6bbdf4be95d..3b5e884d4a4 100644 --- a/tests/target/fn-simple.rs +++ b/tests/target/fn-simple.rs @@ -21,7 +21,7 @@ fn simple( fn weird_comment( // /*/ double level */ comment - x: Hello, // /*/* tripple, even */*/ + x: Hello, // /*/* triple, even */*/ // Does this work? y: World, ) { diff --git a/tests/target/fn_args_density-vertical.rs b/tests/target/fn_args_density-vertical.rs index dcc8478a138..477a48cc35f 100644 --- a/tests/target/fn_args_density-vertical.rs +++ b/tests/target/fn_args_density-vertical.rs @@ -1,6 +1,6 @@ // rustfmt-fn_args_density: Vertical -// Empty list shoul stay on one line. +// Empty list should stay on one line. fn do_bar() -> u8 { bar() } diff --git a/tests/target/issue-1049.rs b/tests/target/issue-1049.rs index 416db998065..c788519ca9a 100644 --- a/tests/target/issue-1049.rs +++ b/tests/target/issue-1049.rs @@ -16,7 +16,7 @@ impl Handle { } } -// Long function without return type that should not be reformated. +// Long function without return type that should not be reformatted. fn veeeeeeeeeeeeeeeeeeeeery_long_name(a: FirstTypeeeeeeeeee, b: SecondTypeeeeeeeeeeeeeeeeeeeeeee) {} fn veeeeeeeeeeeeeeeeeeeeeery_long_name(a: FirstTypeeeeeeeeee, b: SecondTypeeeeeeeeeeeeeeeeeeeeeee) { diff --git a/tests/target/issue-1468.rs b/tests/target/issue-1468.rs index e10c83d45ac..4c14a0f746a 100644 --- a/tests/target/issue-1468.rs +++ b/tests/target/issue-1468.rs @@ -2,7 +2,7 @@ fn issue1468() { euc_jp_decoder_functions!({ let trail_minus_offset = byte.wrapping_sub(0xA1); // Fast-track Hiragana (60% according to Lunde) - // and Katakana (10% acconding to Lunde). + // and Katakana (10% according to Lunde). if jis0208_lead_minus_offset == 0x03 && trail_minus_offset < 0x53 { // Hiragana handle.write_upper_bmp(0x3041 + trail_minus_offset as u16) diff --git a/tests/target/match.rs b/tests/target/match.rs index 3d879d18c20..676b8603f2c 100644 --- a/tests/target/match.rs +++ b/tests/target/match.rs @@ -189,7 +189,7 @@ fn issue355() { oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => { vec![1, 2] } - // Macro support fails to recognise this macro as splitable + // Macro support fails to recognise this macro as splittable // We push the whole expr to a new line, TODO split this macro as well pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp => { vec![3; 4] diff --git a/tests/target/structs.rs b/tests/target/structs.rs index 8284618bc39..5132162f3d5 100644 --- a/tests/target/structs.rs +++ b/tests/target/structs.rs @@ -134,7 +134,7 @@ pub struct State { } struct Palette { - /// A map of indizes in the palette to a count of pixels in approximately + /// A map of indices in the palette to a count of pixels in approximately /// that color foo: i32, } diff --git a/tests/target/unions.rs b/tests/target/unions.rs index cff00d064ff..ed7b842a411 100644 --- a/tests/target/unions.rs +++ b/tests/target/unions.rs @@ -90,7 +90,7 @@ pub union State { } union Palette { - /// A map of indizes in the palette to a count of pixels in approximately + /// A map of indices in the palette to a count of pixels in approximately /// that color foo: i32, }